diff options
Diffstat (limited to 'src/classes/com/sun/javafx/newt')
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Display.java | 2 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/NewtFactory.java | 42 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Screen.java | 2 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Window.java | 15 | ||||
-rw-r--r-- | src/classes/com/sun/javafx/newt/awt/AWTWindow.java | 10 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/windows/WindowsWindow.java | 4 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/x11/X11Window.java | 4 |
7 files changed, 69 insertions, 10 deletions
diff --git a/src/classes/com/sun/javafx/newt/Display.java b/src/classes/com/sun/javafx/newt/Display.java index cd3aa75d0..988283aa3 100755 --- a/src/classes/com/sun/javafx/newt/Display.java +++ b/src/classes/com/sun/javafx/newt/Display.java @@ -45,7 +45,7 @@ public abstract class Display { displayClass = Class.forName("com.sun.javafx.newt.windows.WindowsDisplay"); } else if (NewtFactory.X11.equals(type)) { displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display"); - } else if (NewtFactory.MACOSX.equals(type)) { + } else if (NewtFactory.AWT.equals(type)) { displayClass = Class.forName("com.sun.javafx.newt.awt.AWTDisplay"); } else { throw new RuntimeException("Unknown display type \"" + type + "\""); diff --git a/src/classes/com/sun/javafx/newt/NewtFactory.java b/src/classes/com/sun/javafx/newt/NewtFactory.java index 9f19be289..feb623caa 100755 --- a/src/classes/com/sun/javafx/newt/NewtFactory.java +++ b/src/classes/com/sun/javafx/newt/NewtFactory.java @@ -49,6 +49,9 @@ public abstract class NewtFactory { /** Mac OS X window type */ public static final String MACOSX = "MacOSX"; + /** Generic AWT wrapped window type, if available */ + public static final String AWT = "AWT"; + /** Creates a Window of the default type for the current operating system. */ public static String getWindowType() { String osName = System.getProperty("os.name"); @@ -57,7 +60,11 @@ public abstract class NewtFactory { if (osNameLowerCase.startsWith("wind")) { windowType = WINDOWS; } else if (osNameLowerCase.startsWith("mac os x")) { - windowType = MACOSX; + // For the time being, use the AWT on Mac OS X since + // there's no advantage to avoiding its usage -- this + // would change if we were running on the iPhone and + // didn't have an AWT + windowType = AWT; } else { windowType = X11; } @@ -72,6 +79,13 @@ public abstract class NewtFactory { } /** + * Create a Display entity using the given implementation type, incl native creation + */ + public static Display createDisplay(String type, String name) { + return Display.create(type, name); + } + + /** * Create a Screen entity, incl native creation */ public static Screen createScreen(Display display, int index) { @@ -79,6 +93,13 @@ public abstract class NewtFactory { } /** + * Create a Screen entity using the given implementation type, incl native creation + */ + public static Screen createScreen(String type, Display display, int index) { + return Screen.create(type, display, index); + } + + /** * Create a Window entity, incl native creation */ public static Window createWindow(Screen screen, long visualID) { @@ -86,6 +107,13 @@ public abstract class NewtFactory { } /** + * Create a Window entity using the given implementation type, incl native creation + */ + public static Window createWindow(String type, Screen screen, long visualID) { + return Window.create(type, screen, visualID); + } + + /** * Instantiate a Display entity using the native handle. */ public static Display wrapDisplay(String name, long handle) { @@ -108,5 +136,17 @@ public abstract class NewtFactory { return Window.wrapHandle(getWindowType(), screen, visualID, windowHandle, fullscreen, visible, x, y, width, height); } + + private static final boolean instanceOf(Object obj, String clazzName) { + Class clazz = obj.getClass(); + do { + if(clazz.getName().equals(clazzName)) { + return true; + } + clazz = clazz.getSuperclass(); + } while (clazz!=null); + return false; + } + } diff --git a/src/classes/com/sun/javafx/newt/Screen.java b/src/classes/com/sun/javafx/newt/Screen.java index 67322b97f..efb75577c 100755 --- a/src/classes/com/sun/javafx/newt/Screen.java +++ b/src/classes/com/sun/javafx/newt/Screen.java @@ -45,7 +45,7 @@ public abstract class Screen { screenClass = Class.forName("com.sun.javafx.newt.windows.WindowsScreen"); } else if (NewtFactory.X11.equals(type)) { screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen"); - } else if (NewtFactory.MACOSX.equals(type)) { + } else if (NewtFactory.AWT.equals(type)) { screenClass = Class.forName("com.sun.javafx.newt.awt.AWTScreen"); } else { throw new RuntimeException("Unknown window type \"" + type + "\""); diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index faf98d3d0..1486091e8 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -55,11 +55,7 @@ public abstract class Window implements NativeWindow windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow"); } else if (NewtFactory.X11.equals(type)) { windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window"); - } else if (NewtFactory.MACOSX.equals(type)) { - // For the time being, use the AWT on Mac OS X since - // there's no advantage to avoiding its usage -- this - // would change if we were running on the iPhone and - // didn't have an AWT + } else if (NewtFactory.AWT.equals(type)) { windowClass = Class.forName("com.sun.javafx.newt.awt.AWTWindow"); } else { throw new RuntimeException("Unknown window type \"" + type + "\""); @@ -106,6 +102,8 @@ public abstract class Window implements NativeWindow } } + public abstract boolean isTerminalObject(); + /** * create native windowHandle, ie creates a new native invisible window */ @@ -142,9 +140,12 @@ public abstract class Window implements NativeWindow protected abstract void dispatchMessages(int eventMask); public String toString() { - return "Window[handle "+windowHandle+ + return "NEWT-Window[windowHandle "+getWindowHandle()+ + ", surfaceHandle "+getSurfaceHandle()+ ", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ", visible "+isVisible()+"]"; + ", visible "+isVisible()+ + ", wrappedWindow "+getWrappedWindow()+ + ", terminalObject "+isTerminalObject()+"]"; } protected Screen screen; diff --git a/src/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/classes/com/sun/javafx/newt/awt/AWTWindow.java index b7ac5c5d6..1e0f8d6ee 100644 --- a/src/classes/com/sun/javafx/newt/awt/AWTWindow.java +++ b/src/classes/com/sun/javafx/newt/awt/AWTWindow.java @@ -57,6 +57,10 @@ public class AWTWindow extends Window { private int displayWidth; private int displayHeight; + public final boolean isTerminalObject() { + return false; + } + protected void createNative() { runOnEDT(new Runnable() { public void run() { @@ -162,6 +166,9 @@ public class AWTWindow extends Window { e.getKeyCode(), e.getKeyChar()); } } + if(DEBUG_MOUSE_EVENT) { + System.out.println("dispatchMessages: in event:"+w.getEvent()); + } } } while (w != null); } @@ -199,6 +206,9 @@ public class AWTWindow extends Window { } private void enqueueEvent(boolean isMouseEvent, int type, InputEvent e) { + if(DEBUG_MOUSE_EVENT) { + System.out.println("enqueueEvent: mouse"+isMouseEvent+", event: "+e); + } AWTEventWrapper wrapper = new AWTEventWrapper(isMouseEvent,type, e); synchronized(this) { events.add(wrapper); diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java index 3ee6dbb0f..00ecd5973 100755 --- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java @@ -52,6 +52,10 @@ public class WindowsWindow extends Window { public WindowsWindow() { } + public final boolean isTerminalObject() { + return true; + } + public long getSurfaceHandle() { if (hdc == 0) { hdc = GetDC(windowHandle); diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java index 101ee813b..290b1e506 100755 --- a/src/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java @@ -53,6 +53,10 @@ public class X11Window extends Window { public X11Window() { } + public final boolean isTerminalObject() { + return true; + } + protected void createNative() { long w = CreateWindow(getDisplayHandle(), getScreenHandle(), getScreenIndex(), visualID, x, y, width, height); if (w == 0 || w!=windowHandle) { |