aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11Window.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-01-18 03:34:30 +0100
committerSven Gothel <[email protected]>2012-01-18 03:34:30 +0100
commitd8bbddaea08bd6ae75bc5255ab33cbf15cf3a7be (patch)
tree33209b877be0a83c4b7f3e4a67003e5c0aef0ca9 /src/newt/native/X11Window.c
parentd25c25339d8878980c5f45cd1ee602767ffe0f33 (diff)
Newt: Add fullscreen for offscreen windows (currently OSX only); Focus handling; Misc.
- Add fullscreen for offscreen windows (currently OSX only), - Focus handling - requestFocus() @ creation - remove requestFocus() delay in setFullscreen() since focus loss in fullscreen mode is caused by a KDE 'misbehavior' in general. See X11Common.c FS_GRAB_KEYBOARD, an experimental focus loss prevention, disabled due to it's behavioral impact of removing the ability to use WM keyboard commands (task switcher). - Remove pending events waiting longer than TO (1200ms)
Diffstat (limited to 'src/newt/native/X11Window.c')
-rw-r--r--src/newt/native/X11Window.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 8cc9952d6..10ce8945b 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -253,6 +253,7 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy,
Window focus_return;
int revert_to_return;
+ XSync(dpy, False);
XGetInputFocus(dpy, &focus_return, &revert_to_return);
DBG_PRINT( "X11: requestFocus dpy %p,win %p, force %d, hasFocus %d\n", dpy, (void*)w, force, focus_return==w);
@@ -262,8 +263,8 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy,
NewtWindows_setCWAbove(dpy, w);
// Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable
XGetWindowAttributes(dpy, w, &xwa);
+ DBG_PRINT( "X11: XSetInputFocus dpy %p,win %p, isViewable %d\n", dpy, (void*)w, (xwa.map_state == IsViewable));
if(xwa.map_state == IsViewable) {
- DBG_PRINT( "X11: XSetInputFocus dpy %p,win %p\n", dpy, (void*)w);
XSetInputFocus(dpy, w, RevertToParent, CurrentTime);
}
}
@@ -683,6 +684,15 @@ static Bool WaitForReparentNotify( Display *dpy, XEvent *event, XPointer arg ) {
}
#endif
+/**
+ * KDE cause lost input focus in fullscreen mode.
+ * Using 'XGrabKeyboard(..)' would prevent the loss,
+ * but also would disable WM task switcher etc.
+ *
+ * #define FS_GRAB_KEYBOARD 1
+ *
+ */
+
/*
* Class: jogamp_newt_driver_x11_X11Window
* Method: reconfigureWindow0
@@ -730,6 +740,17 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0
Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ;
if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) {
NewtDisplay_displayDispatchErrorHandlerEnable(0, env);
+ #ifdef FS_GRAB_KEYBOARD
+ if(TST_FLAG_CHANGE_FULLSCREEN(flags)) {
+ if(TST_FLAG_IS_FULLSCREEN(flags)) {
+ XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
+ } else {
+ XUngrabKeyboard(dpy, CurrentTime);
+ }
+ } else if(TST_FLAG_CHANGE_ALWAYSONTOP(flags) && !TST_FLAG_IS_ALWAYSONTOP(flags)) {
+ XUngrabKeyboard(dpy, CurrentTime);
+ }
+ #endif
return;
}
}
@@ -744,6 +765,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0
if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) ||
( TST_FLAG_CHANGE_ALWAYSONTOP(flags) && !TST_FLAG_IS_ALWAYSONTOP(flags) ) ) ) { // FS off
NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, False);
+ #ifdef FS_GRAB_KEYBOARD
+ XUngrabKeyboard(dpy, CurrentTime);
+ #endif
}
if( TST_FLAG_CHANGE_PARENTING(flags) && !TST_FLAG_HAS_PARENT(flags) ) {
@@ -791,6 +815,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0
if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) ||
( TST_FLAG_CHANGE_ALWAYSONTOP(flags) && TST_FLAG_IS_ALWAYSONTOP(flags) ) ) ) { // FS on
NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, True);
+ #ifdef FS_GRAB_KEYBOARD
+ if(TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags)) {
+ XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
+ }
+ #endif
}
NewtDisplay_displayDispatchErrorHandlerEnable(0, env);