aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-08-11 01:59:15 +0200
committerSven Gothel <[email protected]>2015-08-11 01:59:15 +0200
commit4a9f65b176d618a8816eff6d24e683c56a4d8086 (patch)
tree079a2e1d82acc9d9f924fcb3429d8309ece23b58
parentfe90427a84bbea6f23f59a533db300b3832a6a21 (diff)
Bug 1188: Fix regression on X11 setVisible: in-visibility never reached on child windows
It has been experienced that UnmapNotify is not sent for child windows when using IconicState! Hence the visible:=false event never reaches the Window, causing an error. This patch only uses IconicState for top-level windows and if requested.
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java3
-rw-r--r--src/newt/native/X11Window.c13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java2
3 files changed, 11 insertions, 7 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 491f984f2..2721e90e6 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -1131,7 +1131,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
stateMask.set(STATE_BIT_VISIBLE);
} else if(stateMask.get(STATE_BIT_VISIBLE) != visible) {
if(isNativeValid()) {
- setVisibleImpl(visible /* visible */, false /* fast */, getX(), getY(), getWidth(), getHeight());
+ // Skip WM if child-window!
+ setVisibleImpl(visible /* visible */, isChildWindow() /* fast */, getX(), getY(), getWidth(), getHeight());
WindowImpl.this.waitForVisible(visible, false);
madeVisible = visible;
} else {
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index ca768240f..778b71cc5 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -689,9 +689,11 @@ static Bool WaitForUnmapNotify( Display *dpy, XEvent *event, XPointer arg ) {
return (event->type == UnmapNotify) && (event->xmap.window == (Window) arg);
}
-static void NewtWindows_setVisible(Display *dpy, Window root, JavaWindow* jw, Bool visible, Bool useWM, Bool waitForMapNotify) {
+static void NewtWindows_setVisible(Display *dpy, Window root, JavaWindow* jw, Bool visible, Bool useWM, Bool waitForNotify) {
XEvent event;
if( !visible && useWM && 0 != ( _MASK_NET_WM_STATE_HIDDEN & jw->supportedAtoms ) ) {
+ DBG_PRINT( "X11: setVisible -> %d, method: IconicState, wait %d, window %p\n", (int)visible, (int)waitForNotify, (void*)jw->window);
+ // It has been experienced that UnmapNotify is not sent for child windows when using IconicState!
XEvent xev;
memset ( &xev, 0, sizeof(xev) );
xev.type = ClientMessage;
@@ -701,18 +703,19 @@ static void NewtWindows_setVisible(Display *dpy, Window root, JavaWindow* jw, Bo
xev.xclient.data.l[0] = IconicState;
XSendEvent ( dpy, root, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev );
// NewtWindows_sendNET_WM_STATE(dpy, root, jw, _NET_WM_STATE_HIDDEN_IDX, 0, !visible);
- if(waitForMapNotify) {
+ if(waitForNotify) {
XIfEvent( dpy, &event, WaitForUnmapNotify, (XPointer) jw->window );
}
} else {
+ DBG_PRINT( "X11: setVisible -> %d, method: Map/Unmap, wait %d, window %p\n", (int)visible, (int)waitForNotify, (void*)jw->window);
if( visible ) {
XMapRaised(dpy, jw->window);
- if(waitForMapNotify) {
+ if(waitForNotify) {
XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) jw->window );
}
} else {
XUnmapWindow(dpy, jw->window);
- if(waitForMapNotify) {
+ if(waitForNotify) {
XIfEvent( dpy, &event, WaitForUnmapNotify, (XPointer) jw->window );
}
}
@@ -1193,7 +1196,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo
NewtWindows_setVisible(dpy, root, jw, True /* visible */, False /* useWM */, True /* wait */);
// no need to notify the java side .. just temp change
} else if( TST_FLAG_CHANGE_VISIBILITY(flags) ) {
- Bool useWM = TST_FLAG_CHANGE_VISIBILITY_FAST(flags) ? False : True;
+ Bool useWM = ( TST_FLAG_CHANGE_VISIBILITY_FAST(flags) || TST_FLAG_IS_CHILD(flags) ) ? False : True;
if( TST_FLAG_IS_VISIBLE(flags) ) {
DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n");
NewtWindows_setVisible(dpy, root, jw, True /* visible */, useWM, False /* wait */);
diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
index 33479569e..b70beae69 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTDemoListener.java
@@ -300,7 +300,7 @@ public class NEWTDemoListener extends MouseAdapter implements KeyListener {
printlnState("[set visible post]");
glWindow.setExclusiveContextThread(t);
}
- if( wasVisible ) {
+ if( wasVisible && !e.isControlDown() ) {
try {
Thread.sleep(5000);
} catch (final InterruptedException e) {