diff options
author | Sven Gothel <[email protected]> | 2015-10-09 01:54:32 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-10-09 01:54:32 +0200 |
commit | e418a665756af52fe2ca691ca220644e9b27c22c (patch) | |
tree | 5aad1e3803b5cbf177b591912985d992afec6894 /src/newt/native/X11Window.c | |
parent | dca5d36370ec5eb44998bae593880e3b10cc9a4e (diff) |
Bug 1249 - NEWT X11: setVisible(*) _NET_WM_STATE_HIDDEN update not received at ConfigureNotify event (2)
On gnome shell WM, sometimes KDE WM,
it has been observed that the _NET_WM_STATE_HIDDEN update (visible or invisible)
is not received at ConfigureNotify event.
Turns out the state is finally updated at FocusOut!
This change tests _NET_WM_STATE_HIDDEN visibility hint
for mapped window also for FocusIn and FocusOut events,
besides the ConfigureNotify event.
Further more, NormalState to restore a hidden but mapped
window did not work, so it is no more being sent.
We limit us here to _NET_ACTIVE_WINDOW.
2 unit tests are prepared to test this issue:
- TestGLWindows00NEWT
- TestParenting01NEWT
Diffstat (limited to 'src/newt/native/X11Window.c')
-rw-r--r-- | src/newt/native/X11Window.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 26029801b..f10db317a 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -211,7 +211,7 @@ static JavaWindow* createJavaWindowProperty(JNIEnv *env, Display *dpy, Window ro res->lastDesktop = 0; //undef res->maxHorz = False; res->maxVert = False; - res->isMapped=False; + res->isMapped = False; } unsigned long jogl_java_object_data[2]; // X11 is based on 'unsigned long' int nitems_32 = putPtrIn32Long( jogl_java_object_data, (uintptr_t) res); @@ -515,7 +515,16 @@ static void NewtWindows_setWindowTypeEWMH (Display *dpy, JavaWindow * w, int typ } } -static void NewtWindows_sendNET_WM_STATE(Display *dpy, Window root, JavaWindow *w, int prop1Idx, int prop2Idx, Bool enable) { +void NewtWindows_setUrgency(Display *dpy, Window window, Bool enable) { + XWMHints wmh; + memset ( &wmh, 0, sizeof(wmh) ); + if( enable ) { + wmh.flags = XUrgencyHint; + } + XSetWMHints(dpy, window, &wmh); +} + +void NewtWindows_sendNET_WM_STATE(Display *dpy, Window root, JavaWindow *w, int prop1Idx, int prop2Idx, Bool enable) { XEvent xev; int i=0; @@ -666,21 +675,12 @@ static void NewtWindows_setVisible(Display *dpy, Window root, JavaWindow* jw, Bo if( useWM && jw->isMapped && 0 != ( _MASK_NET_WM_STATE_HIDDEN & jw->supportedAtoms ) ) { // It has been experienced that MapNotify/UnmapNotify is not sent for windows when using NormalState/IconicState! // See X11Display.c::Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0 case ConfigureNotify + // NewtWindows_sendNET_WM_STATE(dpy, root, jw, _NET_WM_STATE_DEMANDS_ATTENTION_IDX, 0, True); + // NewtWindows_setUrgency(dpy, jw->window, True); XEvent xev; memset ( &xev, 0, sizeof(xev) ); - xev.type = ClientMessage; - xev.xclient.window = jw->window; - xev.xclient.message_type = jw->allAtoms[_WM_CHANGE_STATE_IDX]; - xev.xclient.format = 32; - if( visible ) { - xev.xclient.data.l[0] = NormalState; - } else { - xev.xclient.data.l[0] = IconicState; - } - XSendEvent ( dpy, root, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev ); if( visible ) { - // NormalState may not work on some WMs (Gnome, KDE) ? - memset ( &xev, 0, sizeof(xev) ); + // NormalState does not work on some WMs (Gnome, KDE) xev.type = ClientMessage; xev.xclient.window = jw->window; xev.xclient.message_type = jw->allAtoms[_NET_ACTIVE_WINDOW_IDX]; @@ -688,6 +688,13 @@ static void NewtWindows_setVisible(Display *dpy, Window root, JavaWindow* jw, Bo xev.xclient.data.l[0] = 1; //source indication for normal applications xev.xclient.data.l[1] = CurrentTime; XSendEvent ( dpy, root, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev ); + } else { + xev.type = ClientMessage; + xev.xclient.window = jw->window; + xev.xclient.message_type = jw->allAtoms[_WM_CHANGE_STATE_IDX]; + xev.xclient.format = 32; + xev.xclient.data.l[0] = IconicState; + XSendEvent ( dpy, root, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev ); } } else { if( visible ) { @@ -840,7 +847,7 @@ JNIEXPORT jlongArray JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWind xswa.override_redirect = False; // use the window manager, always (default) xswa.event_mask = X11_MOUSE_EVENT_MASK; xswa.event_mask |= KeyPressMask | KeyReleaseMask ; - xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask ; + xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask; { int _x = x, _y = y; // pos for CreateWindow, might be tweaked |