diff options
Diffstat (limited to 'src/newt/classes/com/sun')
9 files changed, 56 insertions, 40 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java index dbae30a4b..8665aff6f 100755 --- a/src/newt/classes/com/sun/javafx/newt/NewtFactory.java +++ b/src/newt/classes/com/sun/javafx/newt/NewtFactory.java @@ -80,18 +80,26 @@ public abstract class NewtFactory { * Create a Window entity, incl native creation */ public static Window createWindow(Screen screen, Capabilities caps) { - return Window.create(NativeWindowFactory.getNativeWindowType(true), screen, caps); + return Window.create(0, NativeWindowFactory.getNativeWindowType(true), screen, caps, false); } public static Window createWindow(Screen screen, Capabilities caps, boolean undecorated) { - return Window.create(NativeWindowFactory.getNativeWindowType(true), screen, caps, undecorated); + return Window.create(0, NativeWindowFactory.getNativeWindowType(true), screen, caps, undecorated); + } + + public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) { + return Window.create(parentWindowHandle, NativeWindowFactory.getNativeWindowType(true), screen, caps, undecorated); } /** * Create a Window entity using the given implementation type, incl native creation */ public static Window createWindow(String type, Screen screen, Capabilities caps) { - return Window.create(type, screen, caps); + return Window.create(0, type, screen, caps, false); + } + + public static Window createWindow(long parentWindowHandle, String type, Screen screen, Capabilities caps, boolean undecorated) { + return Window.create(parentWindowHandle, type, screen, caps, undecorated); } /** diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java index 46eaf402f..3321715c3 100755 --- a/src/newt/classes/com/sun/javafx/newt/Window.java +++ b/src/newt/classes/com/sun/javafx/newt/Window.java @@ -82,18 +82,14 @@ public abstract class Window implements NativeWindow return windowClass; } - protected static Window create(String type, Screen screen, Capabilities caps) { - return create(type, screen, caps, false); - } - - protected static Window create(String type, Screen screen, Capabilities caps, boolean undecorated) { + protected static Window create(long parentWindowHandle, String type, Screen screen, Capabilities caps, boolean undecorated) { try { Class windowClass = getWindowClass(type); Window window = (Window) windowClass.newInstance(); window.invalidate(); window.screen = screen; window.setUndecorated(undecorated); - window.createNative(caps); + window.createNative(parentWindowHandle, caps); return window; } catch (Throwable t) { t.printStackTrace(); @@ -128,10 +124,13 @@ public abstract class Window implements NativeWindow /** * Create native windowHandle, ie creates a new native invisible window. * + * The parentWindowHandle may be null, in which case no window parenting + * is requested. + * * Shall use the capabilities to determine the graphics configuration * and shall set the chosen capabilities. */ - protected abstract void createNative(Capabilities caps); + protected abstract void createNative(long parentWindowHandle, Capabilities caps); protected abstract void closeNative(); diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java index b3908d759..1682181f5 100644 --- a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java @@ -78,7 +78,7 @@ public class AWTWindow extends Window { }); } - protected void createNative(final Capabilities caps) { + protected void createNative(long parentWindowHandle, final Capabilities caps) { final AWTWindow awtWindow = this; diff --git a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java b/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java index ca7954a1c..b3d141c43 100755 --- a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java @@ -128,6 +128,8 @@ public class MacWindow extends Window { private static final int NSModeSwitchFunctionKey = 0xF747; private volatile long surfaceHandle; + private long parentWindowHandle; + // non fullscreen dimensions .. private int nfs_width, nfs_height, nfs_x, nfs_y; private final Insets insets = new Insets(0,0,0,0); @@ -139,7 +141,8 @@ public class MacWindow extends Window { public MacWindow() { } - protected void createNative(Capabilities caps) { + protected void createNative(long parentWindowHandle, Capabilities caps) { + this.parentWindowHandle=parentWindowHandle; config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); @@ -188,7 +191,7 @@ public class MacWindow extends Window { public void run() { nsViewLock.lock(); try { - createWindow(false); + createWindow(parentWindowHandle, false); } finally { nsViewLock.unlock(); } @@ -258,7 +261,7 @@ public class MacWindow extends Window { try { if(DEBUG_IMPLEMENTATION) System.out.println("MacWindow.VisibleAction "+visible+" "+Thread.currentThread().getName()); if (visible) { - createWindow(false); + createWindow(parentWindowHandle, false); if (windowHandle != 0) { makeKeyAndOrderFront(windowHandle); } @@ -372,7 +375,7 @@ public class MacWindow extends Window { if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { System.err.println("MacWindow fs: "+fullscreen+" "+x+"/"+y+" "+width+"x"+height); } - createWindow(true); + createWindow(parentWindowHandle, true); if (windowHandle != 0) { makeKeyAndOrderFront(windowHandle); } @@ -546,7 +549,7 @@ public class MacWindow extends Window { super.sendKeyEvent(eventType, modifiers, key, keyChar); } - private void createWindow(boolean recreate) { + private void createWindow(long parentWindowHandle, boolean recreate) { if(0!=windowHandle && !recreate) { return; } @@ -561,7 +564,8 @@ public class MacWindow extends Window { } else { surfaceHandle = 0; } - windowHandle = createWindow0(getX(), getY(), getWidth(), getHeight(), fullscreen, + windowHandle = createWindow0(parentWindowHandle, + getX(), getY(), getWidth(), getHeight(), fullscreen, (isUndecorated() ? NSBorderlessWindowMask : NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), @@ -580,7 +584,7 @@ public class MacWindow extends Window { } protected static native boolean initIDs(); - private native long createWindow0(int x, int y, int w, int h, + private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java index c5e625186..1404fea7c 100644 --- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java @@ -135,21 +135,16 @@ public class GLWindow extends Window implements GLAutoDrawable { return create(null, caps, undecorated); } - /** Creates a new GLWindow referring to the given window, and with the given GLCapabilities. */ - public static GLWindow create(Window window, GLCapabilities caps) { - return create(window, caps, false); - } - - public static GLWindow create(Window window, - GLCapabilities caps, - boolean undecorated) { - if (caps == null) { - caps = new GLCapabilities(null); // default .. - } - + /** Either or: window (prio), or caps and undecorated (2nd choice) */ + private static GLWindow create(Window window, + GLCapabilities caps, + boolean undecorated) { Display display; boolean ownerOfDisplayAndScreen=false; if (window == null) { + if (caps == null) { + caps = new GLCapabilities(null); // default .. + } ownerOfDisplayAndScreen = true; display = NewtFactory.createDisplay(null); // local display Screen screen = NewtFactory.createScreen(display, 0); // screen 0 @@ -177,7 +172,7 @@ public class GLWindow extends Window implements GLAutoDrawable { runPumpMessages = onoff; } - protected void createNative(Capabilities caps) { + protected void createNative(long parentWindowHandle, Capabilities caps) { shouldNotCallThis(); } diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java index ddee07c49..e3d7c2042 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/broadcom/BCEGLWindow.java @@ -49,7 +49,10 @@ public class BCEGLWindow extends Window { public BCEGLWindow() { } - protected void createNative(Capabilities caps) { + protected void createNative(long parentWindowHandle, Capabilities caps) { + if(0!=parentWindowHandle) { + throw new RuntimeException("Window parenting not supported (yet)"); + } // query a good configuration .. even thought we drop this one // and reuse the EGLUtil choosen one later. config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen()); diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java index 1265fa9e2..fd5711b08 100755 --- a/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/opengl/kd/KDWindow.java @@ -53,7 +53,10 @@ public class KDWindow extends Window { public KDWindow() { } - protected void createNative(Capabilities caps) { + protected void createNative(long parentWindowHandle, Capabilities caps) { + if(0!=parentWindowHandle) { + throw new RuntimeException("Window parenting not supported (yet)"); + } config = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, getScreen().getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java index f725874ef..749c67313 100755 --- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java @@ -92,14 +92,16 @@ public class WindowsWindow extends Window { } } - protected void createNative(Capabilities caps) { + protected void createNative(long parentWindowHandle, Capabilities caps) { WindowsScreen screen = (WindowsScreen) getScreen(); WindowsDisplay display = (WindowsDisplay) screen.getDisplay(); config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen()); if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } - windowHandle = CreateWindow(display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(), 0, undecorated, x, y, width, height); + windowHandle = CreateWindow(parentWindowHandle, + display.getWindowClassAtom(), display.WINDOW_CLASS_NAME, display.getHInstance(), + 0, undecorated, x, y, width, height); if (windowHandle == 0) { throw new NativeWindowException("Error creating window"); } @@ -211,7 +213,8 @@ public class WindowsWindow extends Window { // Internals only // protected static native boolean initIDs(); - private native long CreateWindow(int wndClassAtom, String wndName, + private native long CreateWindow(long parentWindowHandle, + int wndClassAtom, String wndName, long hInstance, long visualID, boolean isUndecorated, int x, int y, int width, int height); diff --git a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java index 380c968d1..3d6104789 100755 --- a/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/newt/classes/com/sun/javafx/newt/x11/X11Window.java @@ -50,7 +50,7 @@ public class X11Window extends Window { public X11Window() { } - protected void createNative(Capabilities caps) { + protected void createNative(long parentWindowHandle, Capabilities caps) { X11Screen screen = (X11Screen) getScreen(); X11Display display = (X11Display) screen.getDisplay(); config = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration(caps, null, screen.getGraphicsScreen()); @@ -59,8 +59,9 @@ public class X11Window extends Window { } X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config; long visualID = x11config.getVisualID(); - long w = CreateWindow(display.getHandle(), screen.getIndex(), visualID, - display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height); + long w = CreateWindow(parentWindowHandle, + display.getHandle(), screen.getIndex(), visualID, + display.getJavaObjectAtom(), display.getWindowDeleteAtom(), x, y, width, height); if (w == 0 || w!=windowHandle) { throw new NativeWindowException("Error creating window: "+w); } @@ -140,7 +141,7 @@ public class X11Window extends Window { // protected static native boolean initIDs(); - private native long CreateWindow(long display, int screen_index, + private native long CreateWindow(long parentWindowHandle, long display, int screen_index, long visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height); private native void CloseWindow(long display, long windowHandle, long javaObjectAtom); private native void setVisible0(long display, long windowHandle, boolean visible); |