aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11Window.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-08-30 16:46:36 +0200
committerSven Gothel <[email protected]>2011-08-30 16:46:36 +0200
commitbcea6b67bafaaabf2b1c43989fb13c0e4bf82c98 (patch)
tree0afdfb888c5f976a3982213e82b353ca548d7d64 /src/newt/native/X11Window.c
parentbe7995cb57c4ffa1ea71f8fc292fc0b3df5de212 (diff)
Fix NEWT regression due to fix of bug 502, commit 9ed513e9a9616f6028084df4c650c8caf31ea49d
In case of exessive destroy/create (the NEWT reparenting test cases), some dpyEDT events are slipping through the event dispatcher. This fix uses issues more XSync on both Display connection in case of 'requestFocus' and 'closeWindow'. 'requestFocus' also uses the dpyEDT to issue the XSetInputFocus(..), since it's EDT related.
Diffstat (limited to 'src/newt/native/X11Window.c')
-rw-r--r--src/newt/native/X11Window.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index fc949b318..82b1a5bf7 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -430,7 +430,7 @@ static Window NewtWindows_getParent (Display *dpy, Window w) {
}
-static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, Window w, jboolean force) {
+static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, Display *dpyEDT, Window w, jboolean force) {
XWindowAttributes xwa;
Window focus_return;
int revert_to_return;
@@ -439,14 +439,16 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy,
if( JNI_TRUE==force || focus_return!=w) {
if( JNI_TRUE==force || JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) {
XRaiseWindow(dpy, w);
+ XSync(dpy, False);
+
// Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable
- XGetWindowAttributes(dpy, w, &xwa);
+ XGetWindowAttributes(dpyEDT, w, &xwa);
if(xwa.map_state == IsViewable) {
- XSetInputFocus(dpy, w, RevertToParent, CurrentTime);
+ XSetInputFocus(dpyEDT, w, RevertToParent, CurrentTime);
}
+ XSync(dpyEDT, False);
}
}
- XSync(dpy, False);
}
#define MWM_HINTS_DECORATIONS (1L << 1)
@@ -1426,13 +1428,18 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0
XSync(dpy, False);
XSelectInput(dpyEDT, w, 0);
+ XSync(dpyEDT, False);
XUnmapWindow(dpy, w);
+ XSync(dpy, False);
// Drain all events related to this window ..
Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0(env, obj, displayEDT, javaObjectAtom, wmDeleteAtom);
+ XSync(dpyEDT, False);
XDestroyWindow(dpy, w);
XSync(dpy, False);
+ XSync(dpyEDT, False);
+ Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0(env, obj, displayEDT, javaObjectAtom, wmDeleteAtom);
(*env)->DeleteGlobalRef(env, jwindow);
@@ -1557,9 +1564,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_requestFocus0
- (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean force)
+ (JNIEnv *env, jobject obj, jlong display, jlong displayEDT, jlong window, jboolean force)
{
- NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Window)window, force ) ;
+ NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Display *) (intptr_t) displayEDT,
+ (Window)window, force ) ;
}
/*