diff options
author | Sven Gothel <[email protected]> | 2010-05-06 00:59:46 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-05-06 00:59:46 +0200 |
commit | f3cd476a00e86da9963d4a5c705022e82d5d2059 (patch) | |
tree | f9dc721a8aa6b649a6aa5581893bb76dba15a069 | |
parent | b8b7a30dcfbee99c60f9f0abeb95a973cc1dcdd5 (diff) |
A little cleanup ..
8 files changed, 100 insertions, 107 deletions
diff --git a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java index fb25ae399..51977d6d3 100755 --- a/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java +++ b/src/junit/com/jogamp/test/junit/jogl/demos/gl2/gears/TestGearsNewtAWTWrapper.java @@ -67,7 +67,7 @@ public class TestGearsNewtAWTWrapper { protected void runTestGL(GLCapabilities caps) throws InterruptedException { Display nDisplay = NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display Screen nScreen = NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0 - Window nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps); + Window nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps, false); GLWindow glWindow = GLWindow.create(nWindow); Assert.assertNotNull(glWindow); diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java index c46ec3941..9d0001733 100755 --- a/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestParenting01AWT.java @@ -131,7 +131,7 @@ public class TestParenting01AWT { NEWTEventFiFo eventFifo = new NEWTEventFiFo(); - Window window2 = NewtFactory.createWindow(overlayedAWTComponent, screen, caps); + Window window2 = NewtFactory.createWindow(overlayedAWTComponent, screen, caps, false); Assert.assertNotNull(window2); GLWindow glWindow2 = GLWindow.create(window2); @@ -145,14 +145,12 @@ public class TestParenting01AWT { glWindow2.setTitle("NEWT - CHILD"); glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); + glWindow2.setVisible(true); GLEventListener demo2 = new Gears(); setDemoFields(demo2, window2, glWindow2, false); glWindow2.addGLEventListener(demo2); - glWindow2.setVisible(true); - glWindow2.display(); - long duration = durationPerTest; long step = 20; NEWTEvent event; diff --git a/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java b/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java index cd85d1c9a..1940534dd 100755 --- a/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java +++ b/src/junit/com/jogamp/test/junit/newt/TestParenting01NEWT.java @@ -70,21 +70,14 @@ public class TestParenting01NEWT { static Window createWindow(NativeWindow parent, Screen screen, Capabilities caps, int width, int height) { Assert.assertNotNull(caps); - // - // Create native windowing resources .. X11/Win/OSX - // Window window; - window = ( null == parent ) ? NewtFactory.createWindow(screen, caps) : NewtFactory.createWindow(parent, screen, caps) ; + window = ( null == parent ) ? NewtFactory.createWindow(screen, caps, false) : NewtFactory.createWindow(parent, screen, caps, false) ; Assert.assertNotNull(window); window.setSize(width, height); Assert.assertTrue(false==window.isVisible()); Assert.assertTrue(width==window.getWidth()); Assert.assertTrue(height==window.getHeight()); - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // caps = window.getGraphicsConfiguration().getNativeGraphicsConfiguration().getChosenCapabilities(); Assert.assertNotNull(caps); Assert.assertTrue(caps.getGreenBits()>5); @@ -134,6 +127,7 @@ public class TestParenting01NEWT { glWindow1.setPosition(x,y); glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); glWindow1.addWindowListener(new TraceWindowAdapter()); + glWindow1.setVisible(true); Window window2 = createWindow(window1, screen, caps, width/2, height/2); Assert.assertNotNull(window2); @@ -146,6 +140,7 @@ public class TestParenting01NEWT { glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); // glWindow2.addMouseListener(new TraceMouseAdapter()); + glWindow2.setVisible(true); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, window1, glWindow1, false); @@ -155,15 +150,6 @@ public class TestParenting01NEWT { setDemoFields(demo2, window2, glWindow2, false); glWindow2.addGLEventListener(demo2); - glWindow2.setVisible(true); - glWindow1.setVisible(true); - - glWindow2.setVisible(true); - glWindow1.setVisible(true); - - glWindow2.display(); - glWindow1.display(); - boolean shouldQuit = false; long duration = durationPerTest; long step = 20; diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 531d686b2..60ad003af 100755 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -121,7 +121,7 @@ public abstract class NewtFactory { * <p> * In case <code>parentWindowObject</code> is a {@link javax.media.nativewindow.NativeWindow},<br> * we create a child {@link com.jogamp.newt.Window}, - * utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities)}, + * utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean)}, * passing the parent's native window handle retrieved via {@link javax.media.nativewindow.NativeWindow#getWindowHandle()}.<br></p> * <p> * In case <code>parentWindowObject</code> is even a {@link com.jogamp.newt.Window}, the following applies:<br> @@ -132,17 +132,18 @@ public abstract class NewtFactory { * you have to handle all events appropriatly.<br></p> * <p> * In case <code>parentWindowObject</code> is a {@link java.awt.Component},<br> - * we utilize the {@link com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities)} + * we utilize the {@link com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean)} * factory method.<br> * The factory adds a {@link com.jogamp.newt.event.WindowListener} to propagate {@link com.jogamp.newt.event.WindowEvent}'s so * your NEWT Window integrates into the AWT layout.<br></p> * * @param parentWindowObject either a NativeWindow or java.awt.Component + * @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always * - * @see com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities) - * @see com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities) + * @see com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean) + * @see com.jogamp.newt.impl.awt.AWTNewtFactory#createNativeChildWindow(Object, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean) */ - public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps) { + public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps, boolean undecorated) { if(null==parentWindowObject) { throw new RuntimeException("Null parentWindowObject"); } @@ -151,7 +152,7 @@ public abstract class NewtFactory { nativeParentWindow.lockSurface(); long parentWindowHandle = nativeParentWindow.getWindowHandle(); nativeParentWindow.unlockSurface(); - final Window win = createWindow(parentWindowHandle, screen, caps); + final Window win = createWindow(parentWindowHandle, screen, caps, undecorated); if ( nativeParentWindow instanceof Window) { final Window f_nativeParentWindow = (Window) nativeParentWindow ; f_nativeParentWindow.addWindowListener(new WindowAdapter() { @@ -166,30 +167,41 @@ public abstract class NewtFactory { if(ReflectionUtil.isClassAvailable("com.jogamp.newt.impl.awt.AWTNewtFactory")) { return (Window) ReflectionUtil.callStaticMethod("com.jogamp.newt.impl.awt.AWTNewtFactory", "createNativeChildWindow", - new Class[] { Object.class, Screen.class, Capabilities.class }, - new Object[] { parentWindowObject, screen, caps } ); + new Class[] { Object.class, Screen.class, Capabilities.class, java.lang.Boolean.TYPE}, + new Object[] { parentWindowObject, screen, caps, new Boolean(undecorated) } ); } } } throw new RuntimeException("No NEWT child Window factory method for parent object: "+parentWindowObject); } + public static Window createWindow(Object parentWindowObject, Screen screen, Capabilities caps) { + return createWindow(parentWindowObject, screen, caps, false); + } + /** * Create a child Window entity attached to the given parent, incl native creation<br> * * @param parentWindowObject the native parent window handle + * @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always */ - public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps) { + public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) { if(0==parentWindowHandle) { throw new RuntimeException("Null parentWindowHandle"); } - return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, true); + return Window.create(NativeWindowFactory.getNativeWindowType(true), parentWindowHandle, screen, caps, undecorated); + } + + public static Window createWindow(long parentWindowHandle, Screen screen, Capabilities caps) { + return createWindow(parentWindowHandle, screen, caps, false); } /** * Ability to try a Window type with a construnctor argument, if supported ..<p> * Currently only valid is <code> AWTWindow(Frame frame) </code>, * to support an external created AWT Frame, ie the browsers embedded frame. + * + * @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always */ public static Window createWindow(Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) { return Window.create(NativeWindowFactory.getNativeWindowType(true), cstrArguments, screen, caps, undecorated); @@ -197,19 +209,13 @@ public abstract class NewtFactory { /** * Create a Window entity using the given implementation type, incl native creation + * + * @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always */ - public static Window createWindow(String type, Screen screen, Capabilities caps) { - return Window.create(type, 0, screen, caps, false); - } - public static Window createWindow(String type, Screen screen, Capabilities caps, boolean undecorated) { return Window.create(type, 0, screen, caps, undecorated); } - public static Window createWindow(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated) { - return Window.create(type, parentWindowHandle, screen, caps, undecorated); - } - public static Window createWindow(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated) { return Window.create(type, cstrArguments, screen, caps, undecorated); } diff --git a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java b/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java index f3296d9d5..eb2e27115 100644 --- a/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/impl/awt/AWTNewtFactory.java @@ -83,14 +83,15 @@ public class AWTNewtFactory { * utilizing {@link #getNativeWindow(java.awt.Component)}.<br> * The actual wrapping implementation is {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow}.<br></p> * <p> - * Second we create a child {@link com.jogamp.newt.Window}, utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities)}, passing the AWT parent's native window handle retrieved via {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow#getWindowHandle()}.<br></p> + * Second we create a child {@link com.jogamp.newt.Window}, utilizing {@link com.jogamp.newt.NewtFactory#createWindow(long, com.jogamp.newt.Screen, com.jogamp.newt.Capabilities, boolean)}, passing the AWT parent's native window handle retrieved via {@link com.jogamp.nativewindow.impl.jawt.JAWTWindow#getWindowHandle()}.<br></p> * <p> * Third we attach a {@link com.jogamp.newt.event.awt.AWTParentWindowAdapter} to the given AWT component.<br> * The adapter passes window related events to our new child window, look at the implementation<br></p> * * @param awtParentObject must be of type java.awt.Component + * @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always */ - public static Window createNativeChildWindow(Object awtParentObject, Screen newtScreen, Capabilities newtCaps) { + public static Window createNativeChildWindow(Object awtParentObject, Screen newtScreen, Capabilities newtCaps, boolean undecorated) { NativeWindow parent = getNativeWindow(awtParentObject); // also checks java.awt.Component type java.awt.Component awtParent = (java.awt.Component) awtParentObject; if(null==parent) { @@ -102,7 +103,7 @@ public class AWTNewtFactory { if(0==windowHandle) { throw new NativeWindowException("Null window handle: "+parent); } - Window window = NewtFactory.createWindow(windowHandle, newtScreen, newtCaps); + Window window = NewtFactory.createWindow(windowHandle, newtScreen, newtCaps, undecorated); new AWTParentWindowAdapter(window).addTo(awtParent); return window; } diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java index e81d89a8c..4fe9f77ad 100755 --- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java +++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java @@ -40,8 +40,6 @@ import javax.media.nativewindow.x11.*; public class X11Window extends Window { private static final String WINDOW_CLASS_NAME = "NewtWindow"; - // non fullscreen dimensions .. - private int nfs_width, nfs_height, nfs_x, nfs_y; static { X11Display.initSingleton(); @@ -57,12 +55,13 @@ public class X11Window extends Window { if (config == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } + attachedToParent = 0 != parentWindowHandle ; X11GraphicsConfiguration x11config = (X11GraphicsConfiguration) config; long visualID = x11config.getVisualID(); long w = CreateWindow(parentWindowHandle, display.getHandle(), screen.getIndex(), visualID, display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - x, y, width, height, undecorated||0!=parentWindowHandle); + x, y, width, height, undecorated()); if (w == 0 || w!=windowHandle) { throw new NativeWindowException("Error creating window: "+w); } @@ -87,6 +86,9 @@ public class X11Window extends Window { } public void setVisible(boolean visible) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window setVisible: "+this.x+"/"+this.y+" "+this.width+"x"+this.height+", fs "+fullscreen+", windowHandle "+windowHandle); + } if(0!=windowHandle && this.visible!=visible) { this.visible=visible; setVisible0(getDisplayHandle(), windowHandle, visible); @@ -95,6 +97,9 @@ public class X11Window extends Window { } public void setSize(int width, int height) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window setSize: "+this.width+"x"+this.height+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+windowHandle); + } if (width != this.width || this.height != height) { if(!fullscreen) { this.width = width; @@ -109,6 +114,9 @@ public class X11Window extends Window { } public void setPosition(int x, int y) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window setPosition: "+this.x+"/"+this.y+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+windowHandle); + } if ( this.x != x || this.y != y ) { if(!fullscreen) { this.x = x; @@ -137,16 +145,15 @@ public class X11Window extends Window { h = nfs_height; } if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) { - System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h); - } - setPosSizeDecor0(fullscreen?0:parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, (undecorated||fullscreen)?-1:1); - if(fullscreen) { - requestFocus0(getDisplayHandle(), windowHandle); + System.err.println("X11Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+undecorated()); } + setPosSizeDecor0(fullscreen?0:parentWindowHandle, getDisplayHandle(), getScreenIndex(), windowHandle, x, y, w, h, undecorated()); } return fullscreen; } + final boolean undecorated() { return attachedToParent || undecorated || fullscreen ; } + // @Override public void requestFocus() { super.requestFocus(); @@ -179,7 +186,7 @@ public class X11Window extends Window { private native void setVisible0(long display, long windowHandle, boolean visible); private native void setSize0(long display, long windowHandle, int width, int height); private native void setPosSizeDecor0(long parentWindowHandle, long display, int screen_index, long windowHandle, - int x, int y, int width, int height, int decorationToggle); + int x, int y, int width, int height, boolean undecorated); private native void setTitle0(long display, long windowHandle, String title); private native void requestFocus0(long display, long windowHandle); private native void setPosition0(long parentWindowHandle, long display, long windowHandle, int x, int y); @@ -229,4 +236,8 @@ public class X11Window extends Window { private long windowHandleClose; private long displayHandleClose; private long parentWindowHandle; + private boolean attachedToParent; + + // non fullscreen dimensions .. + private int nfs_width, nfs_height, nfs_x, nfs_y; } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index e7d4e534b..a3ff7d6c7 100755 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -1312,6 +1312,8 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullsc SetWindowPos(hwnd, hWndInsertAfter, x, y, width, height, flags); + NewtWindows_requestFocus ( wnd ); + (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height); } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 3af20aa07..eb52e45bc 100755 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -201,7 +201,6 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons * Display */ - static JNIEnv * x11ErrorHandlerJNIEnv = NULL; static XErrorHandler origErrorHandler = NULL ; @@ -405,6 +404,28 @@ static void NewtWindows_requestFocus (Display *dpy, Window w) { XUnlockDisplay(dpy) ; } +/** changing this attribute while a window is established, + * didn't impact the decoration - only at window creation time. +static void NewtWindows_setOverrideRedirect (Display *dpy, Window w, Bool val) { + XSetWindowAttributes xswa; + memset(&xswa, 0, sizeof(XSetWindowAttributes)); + xswa.override_redirect = val; + XChangeWindowAttributes(dpy, w, CWOverrideRedirect, &xswa); +} */ + +#define MWM_HINTS_DECORATIONS (1L << 1) +#define PROP_MWM_HINTS_ELEMENTS 5 + +static void NewtWindows_setDecorations (Display *dpy, Window w, Bool val) { + unsigned long mwmhints[PROP_MWM_HINTS_ELEMENTS] = { 0, 0, 0, 0, 0 }; // flags, functions, decorations, input_mode, status + Atom prop; + + mwmhints[0] = MWM_HINTS_DECORATIONS; + mwmhints[2] = val ; + prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", False ); + XChangeProperty( dpy, w, prop, prop, 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); +} + /* * Class: com_jogamp_newt_impl_x11_X11Display * Method: DispatchMessages @@ -514,16 +535,16 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages (jint) -1, (jchar) keyChar); break; case DestroyNotify: - DBG_PRINT1( "X11: event . DestroyNotify call 0x%X\n", evt.xdestroywindow.window); + DBG_PRINT1( "X11: event . DestroyNotify call 0x%X\n", (unsigned int)evt.xdestroywindow.window); (*env)->CallVoidMethod(env, jwindow, windowDestroyedID); break; case CreateNotify: - DBG_PRINT1( "X11: event . CreateNotify call 0x%X\n", evt.xcreatewindow.window); + DBG_PRINT1( "X11: event . CreateNotify call 0x%X\n", (unsigned int)evt.xcreatewindow.window); (*env)->CallVoidMethod(env, jwindow, windowCreatedID); break; case ConfigureNotify: DBG_PRINT8( "X11: event . ConfigureNotify call 0x%X (parent 0x%X, above 0x%X) %d/%d %dx%d %d\n", - evt.xconfigure.window, evt.xconfigure.event, evt.xconfigure.above, + (unsigned int)evt.xconfigure.window, (unsigned int)evt.xconfigure.event, (unsigned int)evt.xconfigure.above, evt.xconfigure.x, evt.xconfigure.y, evt.xconfigure.width, evt.xconfigure.height, evt.xconfigure.override_redirect); (*env)->CallVoidMethod(env, jwindow, windowChangedID, @@ -532,36 +553,36 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages break; case ClientMessage: if (evt.xclient.send_event==True && evt.xclient.data.l[0]==(Atom)wmDeleteAtom) { - DBG_PRINT2( "X11: event . ClientMessage call 0x%X type 0x%X !!!\n", evt.xclient.window, evt.xclient.message_type); + DBG_PRINT2( "X11: event . ClientMessage call 0x%X type 0x%X !!!\n", (unsigned int)evt.xclient.window, (unsigned int)evt.xclient.message_type); (*env)->CallVoidMethod(env, jwindow, windowDestroyNotifyID); // Called by Window.java: CloseWindow(); } break; case FocusIn: - DBG_PRINT1( "X11: event . FocusIn call 0x%X\n", evt.xvisibility.window); + DBG_PRINT1( "X11: event . FocusIn call 0x%X\n", (unsigned int)evt.xvisibility.window); (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_TRUE); break; case FocusOut: - DBG_PRINT1( "X11: event . FocusOut call 0x%X\n", evt.xvisibility.window); + DBG_PRINT1( "X11: event . FocusOut call 0x%X\n", (unsigned int)evt.xvisibility.window); (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE); break; // unhandled events .. yet .. case VisibilityNotify: - DBG_PRINT1( "X11: event . VisibilityNotify call 0x%X\n", evt.xvisibility.window); + DBG_PRINT1( "X11: event . VisibilityNotify call 0x%X\n", (unsigned int)evt.xvisibility.window); break; case Expose: - DBG_PRINT1( "X11: event . Expose call 0x%X\n", evt.xexpose.window); + DBG_PRINT1( "X11: event . Expose call 0x%X\n", (unsigned int)evt.xexpose.window); /* FIXME: Might want to send a repaint event .. */ break; case UnmapNotify: - DBG_PRINT1( "X11: event . UnmapNotify call 0x%X\n", evt.xunmap.window); + DBG_PRINT1( "X11: event . UnmapNotify call 0x%X\n", (unsigned int)evt.xunmap.window); break; default: - DBG_PRINT3("X11: event . unhandled %d 0x%X call 0x%X\n", evt.type, evt.type, evt.xunmap.window); + DBG_PRINT3("X11: event . unhandled %d 0x%X call 0x%X\n", evt.type, evt.type, (unsigned int)evt.xunmap.window); } } } @@ -674,7 +695,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow Screen* scrn; Atom wm_delete_atom; - DBG_PRINT4( "X11: CreateWindow %x/%d %dx%d\n", x, y, width, height); + DBG_PRINT5( "X11: CreateWindow %x/%d %dx%d, undeco %d\n", x, y, width, height, undecorated); if(dpy==NULL) { _FatalError(env, "invalid display connection.."); @@ -704,7 +725,8 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow XFree(pVisualQuery); pVisualQuery=NULL; } - DBG_PRINT5( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent %p) found: %p\n", dpy, scrn_idx, (int)visualID, windowParent, visual); + DBG_PRINT5( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent 0x%X) found: %p\n", + dpy, scrn_idx, (int)visualID, (unsigned int)windowParent, visual); if (visual==NULL) { @@ -725,7 +747,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow memset(&xswa, 0, sizeof(xswa)); xswa.override_redirect = ( JNI_TRUE == undecorated || 0 != parent ) ? True : False ; - xswa.border_pixel = 255; + xswa.border_pixel = 0; xswa.background_pixel = 0; xswa.event_mask = FocusChangeMask | ExposureMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask; xswa.colormap = XCreateColormap(dpy, @@ -744,7 +766,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow attrMask, &xswa); - if(NULL==window) { + if(0==window) { _throwNewRuntimeException(dpy, env, "could not create Window, bail out!"); return 0; } @@ -764,9 +786,10 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow XSelectInput(dpy, window, xevent_mask); } + XSync(dpy, False); XUnlockDisplay(dpy) ; - DBG_PRINT2( "X11: [CreateWindow] created window %p on display %p\n", window, dpy); + DBG_PRINT2( "X11: [CreateWindow] created window 0x%X on display %p\n", (unsigned int)window, dpy); (*env)->CallVoidMethod(env, obj, windowCreatedID, (jlong) window); return (jlong) window; @@ -803,7 +826,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow XSync(dpy, False); XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); - XSync(dpy, False); XDestroyWindow(dpy, w); XSync(dpy, False); @@ -829,7 +851,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setVisible0 } XLockDisplay(dpy) ; - XSync(dpy, False); if(visible==JNI_TRUE) { XMapRaised(dpy, w); } else { @@ -851,14 +872,13 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setSize0 Window w = (Window)window; XWindowChanges xwc; - DBG_PRINT5( "X11: setSize0 %d/%d %dx%d, dec %d\n", x, y, width, height, decorationToggle); + DBG_PRINT2( "X11: setSize0 %dx%d\n", width, height); if(dpy==NULL) { _FatalError(env, "invalid display connection.."); } XLockDisplay(dpy) ; - XSync(dpy, False); memset(&xwc, 0, sizeof(XWindowChanges)); xwc.width=width; xwc.height=height; @@ -868,13 +888,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setSize0 XUnlockDisplay(dpy) ; } -#define MWM_FULLSCREEN 1 - -#ifdef MWM_FULLSCREEN - #define MWM_HINTS_DECORATIONS (1L << 1) - #define PROP_MWM_HINTS_ELEMENTS 5 -#endif - /* * Class: com_jogamp_newt_impl_x11_X11Window * Method: setPosSizeDecor0 @@ -882,7 +895,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setSize0 */ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0 (JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window, - jint x, jint y, jint width, jint height, jint decorationToggle) + jint x, jint y, jint width, jint height, jboolean undecorated) { Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; @@ -891,7 +904,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0 XWindowChanges xwc; - DBG_PRINT5( "X11: setSize0 %d/%d %dx%d, dec %d\n", x, y, width, height, decorationToggle); + DBG_PRINT5( "X11: setPosSizeDecor0 %d/%d %dx%d, undec %d\n", x, y, width, height, undecorated); if(dpy==NULL) { _FatalError(env, "invalid display connection.."); @@ -903,32 +916,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0 XReparentWindow( dpy, w, parent, x, y ); XRaiseWindow(dpy, w); - if(0!=decorationToggle) { -#ifdef MWM_FULLSCREEN - unsigned long mwmhints[PROP_MWM_HINTS_ELEMENTS] = { 0, 0, 0, 0, 0 }; // flags, functions, decorations, input_mode, status - Atom prop; - - mwmhints[0] = MWM_HINTS_DECORATIONS; - mwmhints[2] = (decorationToggle<0)?False:True; - prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", False ); - XChangeProperty( dpy, w, prop, prop, 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); -#else - XSetWindowAttributes xswa; - unsigned long attrMask=CWOverrideRedirect; - - memset(&xswa, 0, sizeof(XSetWindowAttributes)); - if(decorationToggle<0) { - /* undecorated */ - xswa.override_redirect = True; - } else { - /* decorated */ - xswa.override_redirect = False; - } - XChangeWindowAttributes(dpy, w, attrMask, &xswa); - XReparentWindow( dpy, w, parent, x, y ); -#endif - } - XSync(dpy, False); + NewtWindows_setDecorations (dpy, w, ( JNI_TRUE == undecorated ) ? False : True ); memset(&xwc, 0, sizeof(XWindowChanges)); xwc.x=x; @@ -938,6 +926,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0 XConfigureWindow(dpy, w, CWX|CWY|CWWidth|CWHeight, &xwc); XSync(dpy, False); + NewtWindows_requestFocus ( dpy, w ); XUnlockDisplay(dpy) ; } |