aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Window.java5
-rw-r--r--src/newt/native/X11Window.c20
-rw-r--r--src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java1
3 files changed, 17 insertions, 9 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
index cbb43934b..57abd0b2d 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java
@@ -107,7 +107,8 @@ public class X11Window extends WindowImpl {
}
protected void requestFocusImpl(boolean force) {
- requestFocus0(getDisplayHandle(), getWindowHandle(), force);
+ final X11Display display = (X11Display) getScreen().getDisplay();
+ requestFocus0(display.getHandle(), display.getEDTHandle(), getWindowHandle(), force);
}
@Override
@@ -133,7 +134,7 @@ public class X11Window extends WindowImpl {
int x, int y, int width, int height, boolean isVisible,
boolean parentChange, int fullScreenChange, int decorationChange);
private native void setTitle0(long display, long windowHandle, String title);
- private native void requestFocus0(long display, long windowHandle, boolean force);
+ private native void requestFocus0(long display, long displayEDT, long windowHandle, boolean force);
private native Object getRelativeLocation0(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y);
private void windowReparented(long gotParentHandle) {
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 ) ;
}
/*
diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
index 4c5628860..01356e9d0 100644
--- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java
@@ -37,7 +37,6 @@ import javax.media.opengl.*;
import com.jogamp.opengl.util.Animator;
import com.jogamp.newt.*;
-import com.jogamp.newt.event.*;
import com.jogamp.newt.opengl.*;
import java.io.IOException;