diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 12 | ||||
-rw-r--r-- | src/newt/native/X11Window.c | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 6e7735509..10fa36a83 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1584,7 +1584,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void requestFocus(boolean wait) { - if(isNativeValid() && !focusAction()) { + if(!hasFocus() && isNativeValid() && !focusAction()) { runOnEDTIfAvail(wait, requestFocusAction); } } @@ -1743,8 +1743,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer display.dispatchMessagesNative(); // status up2date WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); display.dispatchMessagesNative(); // status up2date - requestFocusInt(true); - display.dispatchMessagesNative(); // status up2date if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs done: " + WindowImpl.this); @@ -1761,6 +1759,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public boolean setFullscreen(boolean fullscreen) { runOnEDTIfAvail(true, new FullScreenActionImpl(fullscreen)); + if(isVisible()) { + // Request focus 'later' allowing native WM to complete event handling, + // this is required especially on X11 to guarantee a focused fullscreen window. + try { + Thread.sleep(100); + } catch (InterruptedException e) { } + requestFocus(true); + } return this.fullscreen; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 0a7e1cf77..8cc9952d6 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -263,7 +263,7 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable XGetWindowAttributes(dpy, w, &xwa); if(xwa.map_state == IsViewable) { - DBG_PRINT( "X11: XSetInputFocus dpy %p,win %pd\n", dpy, (void*)w); + DBG_PRINT( "X11: XSetInputFocus dpy %p,win %p\n", dpy, (void*)w); XSetInputFocus(dpy, w, RevertToParent, CurrentTime); } } |