diff options
author | Sven Gothel <[email protected]> | 2008-05-30 13:35:03 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2008-05-30 13:35:03 +0000 |
commit | acdd8ef2e4af64871c62b8b9b84af83a32fd1aba (patch) | |
tree | 6fcd5b019550b31b2b2235fbe25c174628ffeb0b /src/classes/com/sun/javafx/newt/Window.java | |
parent | efcbd94ea40dd4fb532707765535bd1af1639a03 (diff) |
Completing com.sun.javafx.newt.* package, WIP, working under X11/ES1.1.
- Fixed:
- EGLDrawable[Factory]
- Object target is a 'long[3]' with [display, screen, window]
native handles.
Depending on the platform, display and screen handles may be 0.
- Moved EGL.eglGetDisplay and EGL.eglInitialize
from EGLDrawableFactory -> EGLDrawable,
since the factory has no notion of the native handles,
but the display is necessary.
- newt.*:
- Added Display and Screen abstraction
- Added 'long[] Window.getHandles()',
to feed EGLDrawableFactory.getGLDrawable() with the 3 native handles.
- MouseEvent:
- Java: Clicked and Dragged working
- native/X11: SelectInput with proper args
- KeyEvent:
- native/X11: added XSetInputFocus and XLookupString
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1652 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/javafx/newt/Window.java')
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Window.java | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index 2bfcf1265..27610cdf2 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -37,6 +37,9 @@ import java.util.ArrayList; import java.util.Iterator; public abstract class Window { + public static final boolean DEBUG_MOUSE_EVENT = false; + public static final boolean DEBUG_KEY_EVENT = false; + /** OpenKODE window type */ public static final String KD = "KD"; @@ -50,7 +53,7 @@ public abstract class Window { public static final String MACOSX = "MacOSX"; /** Creates a Window of the default type for the current operating system. */ - public static Window create(long visualID) { + public static Window create(Screen screen, long visualID) { String osName = System.getProperty("os.name"); String osNameLowerCase = osName.toLowerCase(); String windowType; @@ -62,7 +65,7 @@ public abstract class Window { windowType = X11; } Window window = create(windowType); - window.initNative(visualID); + window.initNative(screen, visualID); return window; } @@ -87,7 +90,19 @@ public abstract class Window { } } - protected abstract void initNative(long visualID); + + /** + * [ display, screen, window ] + */ + public long[] getHandles() { + long[] handles = new long[3]; + handles[0] = getScreen().getDisplay().getHandle(); + handles[1] = getScreen().getHandle(); + handles[2] = getWindowHandle(); + return handles; + } + + protected abstract void initNative(Screen screen, long visualID); public abstract void setVisible(boolean visible); public abstract void setSize(int width, int height); @@ -101,9 +116,18 @@ public abstract class Window { public abstract boolean isFullscreen(); public abstract int getDisplayWidth(); public abstract int getDisplayHeight(); + + public abstract Screen getScreen(); public abstract long getWindowHandle(); + public abstract void pumpMessages(); + public String toString() { + return "Window[handle "+getWindowHandle()+ + ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + ", visible "+isVisible()+"]"; + } + // // MouseListener Support // @@ -132,6 +156,10 @@ public abstract class Window { public static final int ClickTimeout = 200; private void sendMouseEvent(int eventType, int modifiers, int x, int y, int button) { + if(DEBUG_MOUSE_EVENT) { + System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+ + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button); + } long when = System.currentTimeMillis(); MouseEvent eClicked = null; MouseEvent e = null; @@ -151,18 +179,26 @@ public abstract class Window { if(when-lastMousePressed<ClickTimeout) { eClicked = new MouseEvent(true, MouseEvent.EVENT_MOUSE_CLICKED, this, when, modifiers, x, y, lastMouseClickCount, button); + } else { + lastMouseClickCount=0; + lastMousePressed=0; } - lastMouseClickCount=0; - lastMousePressed=0; } else if(MouseEvent.EVENT_MOUSE_MOVED==eventType && 1==lastMouseClickCount) { - e = new MouseEvent(true, eventType, this, when, + e = new MouseEvent(true, MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, x, y, 1, button); } else { e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button); } + if(DEBUG_MOUSE_EVENT) { + System.out.println("sendMouseEvent: event: "+e); + if(null!=eClicked) { + System.out.println("sendMouseEvent: event Clicked: "+eClicked); + } + } + for(Iterator i = mouseListener.iterator(); i.hasNext(); ) { switch(eventType) { case MouseEvent.EVENT_MOUSE_ENTERED: @@ -175,9 +211,10 @@ public abstract class Window { ((MouseListener)i.next()).mousePressed(e); break; case MouseEvent.EVENT_MOUSE_RELEASED: - ((MouseListener)i.next()).mouseReleased(e); + MouseListener ml = (MouseListener)i.next(); + ml.mouseReleased(e); if(null!=eClicked) { - ((MouseListener)i.next()).mouseClicked(eClicked); + ml.mouseClicked(eClicked); } break; case MouseEvent.EVENT_MOUSE_MOVED: @@ -217,6 +254,9 @@ public abstract class Window { private void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { KeyEvent e = new KeyEvent(true, eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar); + if(DEBUG_KEY_EVENT) { + System.out.println("sendKeyEvent: "+e); + } for(Iterator i = keyListener.iterator(); i.hasNext(); ) { switch(eventType) { case KeyEvent.EVENT_KEY_PRESSED: |