From ecdaa59aa48c16a558ec7a0b50df9419a9ccedc1 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Fri, 9 Oct 2015 02:24:05 +0200
Subject: Bug 1249 - NEWT X11: setVisible(false)
 IconicState/_NET_WM_STATE_HIDDEN: Handle case where KDE unmaps the window

Update our internal JavaWindow.isMapped according to MapNotify and UnmapNotify.
This takes care of a situation (KDE) where a window is unmapped
during IconicState.

For unmapped windows we cannot interprete _NET_WM_STATE_HIDDEN
and we have to issue XMapWindow for restoring the window.
---
 src/newt/classes/jogamp/newt/WindowImpl.java |  3 ++-
 src/newt/native/X11Display.c                 | 10 ++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 8fe3dceca..107851d0b 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -4426,7 +4426,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                 System.err.println("XXXX: FREEZE");
                 try {
                     while(true) {
-                        Thread.sleep(1000);
+                        Thread.sleep(100);
+                        display.dispatchMessagesNative(); // status up2date
                     }
                 } catch (final InterruptedException e) {
                     ExceptionUtils.dumpThrowable("", e);
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index a98f707ca..ab5afd1d6 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -662,11 +662,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
                 break;
 
             case MapNotify:
-                DBG_PRINT( "X11: event . MapNotify call Event %p, Window %p, override_redirect %d, child-event: %d\n", 
-                    (void*)evt.xmap.event, (void*)evt.xmap.window, (int)evt.xmap.override_redirect,
+                DBG_PRINT( "X11: event . MapNotify call Event %p, Window %p, isMapped %d -> 1, override_redirect %d, child-event: %d\n", 
+                    (void*)evt.xmap.event, (void*)evt.xmap.window, jw->isMapped, (int)evt.xmap.override_redirect,
                     evt.xmap.event!=evt.xmap.window);
                 if( evt.xmap.event == evt.xmap.window ) {
                     // ignore child window notification
+                    jw->isMapped = True;
                     // insets: negative values are ignored
                     int left=-1, right=-1, top=-1, bottom=-1;
                     if( NewtWindows_updateInsets(dpy, jw, &left, &right, &top, &bottom) ) {
@@ -678,11 +679,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
                 break;
 
             case UnmapNotify:
-                DBG_PRINT( "X11: event . UnmapNotify call Event %p, Window %p, from_configure %d, child-event: %d\n", 
-                    (void*)evt.xunmap.event, (void*)evt.xunmap.window, (int)evt.xunmap.from_configure,
+                DBG_PRINT( "X11: event . UnmapNotify call Event %p, Window %p, isMapped %d -> 0, from_configure %d, child-event: %d\n", 
+                    (void*)evt.xunmap.event, (void*)evt.xunmap.window, jw->isMapped, (int)evt.xunmap.from_configure,
                     evt.xunmap.event!=evt.xunmap.window);
                 if( evt.xunmap.event == evt.xunmap.window ) {
                     // ignore child window notification
+                    jw->isMapped = False;
                     (*env)->CallVoidMethod(env, jw->jwindow, visibleChangedID, JNI_FALSE, JNI_FALSE);
                 }
                 break;
-- 
cgit v1.2.3