diff options
Diffstat (limited to 'src')
12 files changed, 73 insertions, 49 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); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index a93157c3f..d59a61e42 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -237,10 +237,10 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_initIDs /* * Class: com_sun_javafx_newt_macosx_MacWindow * Method: createWindow0 - * Signature: (IIIIZIIIJ)J + * Signature: (JIIIIZIIIJ)J */ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_createWindow0 - (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, jboolean fullscreen, jint styleMask, + (JNIEnv *env, jobject jthis, jlong parent, jint x, jint y, jint w, jint h, jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -264,6 +264,12 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_macosx_MacWindow_createWindow0 backing: (NSBackingStoreType) bufferingType screen: screen] retain]; + /** FIXME: test .. + NSWindow* parentWindow = (NSWindow*) ((intptr_t) parent); + if(NULL!=parentWindow) { + [window setParentWindow: parentWindow]; + } */ + if (fullscreen) { [window setOpaque: YES]; } else { diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index edc3f0796..a171f34b2 100755 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -1032,10 +1032,10 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_initID /* * Class: com_sun_javafx_newt_windows_WindowsWindow * Method: CreateWindow - * Signature: (ILjava/lang/String;JJZIIII)J + * Signature: (JILjava/lang/String;JJZIIII)J */ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWindow - (JNIEnv *env, jobject obj, jint wndClassAtom, jstring jWndName, jlong hInstance, jlong visualID, + (JNIEnv *env, jobject obj, jlong parent, jint wndClassAtom, jstring jWndName, jlong hInstance, jlong visualID, jboolean bIsUndecorated, jint jx, jint jy, jint defaultWidth, jint defaultHeight) { @@ -1063,7 +1063,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_windows_WindowsWindow_CreateWin window = CreateWindow(MAKEINTATOM(wndClassAtom), wndName, windowStyle, x, y, width, height, - NULL, NULL, + (HWND)parent, NULL, (HINSTANCE) hInstance, NULL); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 8651a8cea..1e7cd3bba 100755 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -511,17 +511,17 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Window_initIDs /* * Class: com_sun_javafx_newt_x11_X11Window * Method: CreateWindow - * Signature: (JIJIIII)J + * Signature: (JJIJIIII)J */ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow - (JNIEnv *env, jobject obj, jlong display, jint screen_index, + (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, jlong visualID, jlong javaObjectAtom, jlong windowDeleteAtom, jint x, jint y, jint width, jint height) { Display * dpy = (Display *)(intptr_t)display; int scrn_idx = (int)screen_index; - Window windowParent = 0; + Window windowParent = (Window) parent; Window window = 0; XVisualInfo visualTemplate; @@ -578,7 +578,9 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow pVisualQuery=NULL; } - windowParent = XRootWindowOfScreen(scrn); + if(NULL==windowParent) { + windowParent = XRootWindowOfScreen(scrn); + } attrMask = (CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect) ; |