aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-06-26 06:59:48 +0300
committerSven Gothel <[email protected]>2010-06-26 06:59:48 +0300
commit969e427642d3b9be376cefaada9febd489b7b3d7 (patch)
treed2b4af8b500c0f561fc9d77807f318959ef41b4b /src/newt/native
parentce8c373576fe58fa5c71811fa376321e5379f71d (diff)
GLAutoDrawable: setAnimator/getAnimator/invoke/display changes; NEWT: Adding native repaint; NewtCanvasAWT focus fix
Support for native repaint, which shall call display() in case no animator is running. GLAutoDrawable invoke(GLRunnable) impl. handles case if invoked on animator thread, or no animator thread is running (issueing a display() call). The impl resides in GLDrawableHelper. GLEventListener's init() and glViewport()/reshape() method must be called before the 1st display() and after a dispose() call. It could miss the 1st display() call if added after the setVisible(true) call - due to the native repainting. The impl resides in GLDrawableHelper. The Animator un-/registers itself at the GLAutoDrawable via setAnimator. NEWT Window reparent always issues a resize() and display() call. NEWT native Window uses direct send.*Event for input events (again), instead of enqueueing it for performance. NEWT Window implements all status change and Java native event callbacks, instead of having duplicated code in all implementations. NewtCanvasAWT if the Newt window is focused, the AWT/Swing component[s] will loose the focus.
Diffstat (limited to 'src/newt/native')
-rwxr-xr-xsrc/newt/native/WindowsWindow.c85
-rwxr-xr-xsrc/newt/native/X11Window.c109
2 files changed, 118 insertions, 76 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 5e3311d3b..a1dab2678 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -109,15 +109,16 @@
#define STD_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
-static jmethodID sizeChangedID = NULL;
static jmethodID insetsChangedID = NULL;
+static jmethodID sizeChangedID = NULL;
static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
+static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowDestroyedID = NULL;
-static jmethodID enqueueMouseEventID = NULL;
-static jmethodID enqueueKeyEventID = NULL;
-static jmethodID sendPaintEventID = NULL;
+static jmethodID windowRepaintID = NULL;
+static jmethodID sendMouseEventID = NULL;
+static jmethodID sendKeyEventID = NULL;
static RECT* UpdateInsets(JNIEnv *env, HWND hwnd, jobject window);
@@ -506,7 +507,7 @@ static int WmChar(JNIEnv *env, jobject window, UINT character, UINT repCnt,
if (character == VK_RETURN) {
character = J_VK_ENTER;
}
- (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
+ (*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_TYPED,
GetModifiers(),
(jint) -1,
@@ -551,7 +552,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
*/
- (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
+ (*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_PRESSED,
modifiers,
(jint) jkey,
@@ -562,7 +563,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
WM_KEYDOWN.
*/
if (jkey == J_VK_DELETE) {
- (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
+ (*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_TYPED,
GetModifiers(),
(jint) -1,
@@ -586,7 +587,7 @@ static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
*/
- (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
+ (*env)->CallVoidMethod(env, window, sendKeyEventID,
(jint) EVENT_KEY_RELEASED,
modifiers,
(jint) jkey,
@@ -706,6 +707,7 @@ static void WmSize(JNIEnv *env, HWND wnd, jobject window, UINT type)
static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
+ LRESULT res = 0;
int useDefWindowProc = 0;
JNIEnv *env = NULL;
jobject window = NULL;
@@ -799,7 +801,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
case WM_LBUTTONDOWN:
NewtWindows_requestFocus ( wnd, FALSE, FALSE ); // request focus on this window, if not already ..
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -808,7 +810,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_LBUTTONUP:
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -818,7 +820,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
case WM_MBUTTONDOWN:
NewtWindows_requestFocus ( wnd, FALSE, FALSE ); // request focus on this window, if not already ..
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -827,7 +829,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_MBUTTONUP:
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -837,7 +839,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
case WM_RBUTTONDOWN:
NewtWindows_requestFocus ( wnd, FALSE, FALSE ); // request focus on this window, if not already ..
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -846,7 +848,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_RBUTTONUP:
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -855,7 +857,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_MOUSEMOVE:
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_MOVED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -871,7 +873,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
eventPt.x = x;
eventPt.y = y;
ScreenToClient(wnd, &eventPt);
- (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
+ (*env)->CallVoidMethod(env, window, sendMouseEventID,
(jint) EVENT_MOUSE_WHEEL_MOVED,
GetModifiers(),
(jint) eventPt.x, (jint) eventPt.y,
@@ -881,17 +883,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
}
case WM_SETFOCUS:
- (*env)->CallVoidMethod(env, window, focusChangedID,
- (jlong)wParam, JNI_TRUE);
+ (*env)->CallVoidMethod(env, window, focusChangedID, JNI_TRUE);
useDefWindowProc = 1;
break;
case WM_KILLFOCUS:
- (*env)->CallVoidMethod(env, window, focusChangedID,
- (jlong)wParam, JNI_FALSE);
+ (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE);
useDefWindowProc = 1;
break;
+ case WM_SHOWWINDOW:
+ (*env)->CallVoidMethod(env, window, visibleChangedID, wParam==TRUE?JNI_TRUE:JNI_FALSE);
+ break;
+
case WM_MOVE:
DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d\n", wnd, (int)LOWORD(lParam), (int)HIWORD(lParam));
(*env)->CallVoidMethod(env, window, positionChangedID,
@@ -901,21 +905,24 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
case WM_PAINT: {
RECT r;
- if (GetUpdateRect(wnd, &r, FALSE)) {
- if ((r.right-r.left) > 0 && (r.bottom-r.top) > 0) {
- (*env)->CallVoidMethod(env, window, sendPaintEventID,
- 0, r.left, r.top, r.right-r.left, r.bottom-r.top);
+ useDefWindowProc = 0;
+ if (GetUpdateRect(wnd, &r, TRUE /* erase background */)) {
+ /*
+ jint width = r.right-r.left;
+ jint height = r.bottom-r.top;
+ if (width > 0 && height > 0) {
+ (*env)->CallVoidMethod(env, window, windowRepaintID, r.left, r.top, width, height);
}
ValidateRect(wnd, &r);
- useDefWindowProc = 0;
- } else {
- useDefWindowProc = 1;
+ */
}
break;
}
case WM_ERASEBKGND:
// ignore erase background
+ (*env)->CallVoidMethod(env, window, windowRepaintID, 0, 0, -1, -1);
useDefWindowProc = 0;
+ res = 1;
break;
@@ -926,7 +933,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
if (useDefWindowProc)
return DefWindowProc(wnd, message, wParam, lParam);
- return 0;
+ return res;
}
/*
@@ -1052,24 +1059,26 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_windows_WindowsScreen_getHeight
JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initIDs0
(JNIEnv *env, jclass clazz)
{
- sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V");
+ sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
- focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(JZ)V");
+ focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
+ visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
- enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V");
- enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V");
- sendPaintEventID = (*env)->GetMethodID(env, clazz, "sendPaintEvent", "(IIIII)V");
- if (sizeChangedID == NULL ||
- insetsChangedID == NULL ||
+ windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
+ sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ if (insetsChangedID == NULL ||
+ sizeChangedID == NULL ||
positionChangedID == NULL ||
focusChangedID == NULL ||
+ visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
windowDestroyedID == NULL ||
- enqueueMouseEventID == NULL ||
- sendPaintEventID == NULL ||
- enqueueKeyEventID == NULL)
+ windowRepaintID == NULL ||
+ sendMouseEventID == NULL ||
+ sendKeyEventID == NULL)
{
return JNI_FALSE;
}
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index a521d2dbd..dbf833633 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -151,14 +151,16 @@ static const char * const ClazzNameNewtWindow =
"com/jogamp/newt/Window";
static jclass newtWindowClz=NULL;
-static jmethodID windowChangedID = NULL;
+static jmethodID sizeChangedID = NULL;
+static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowDestroyedID = NULL;
+static jmethodID windowRepaintID = NULL;
static jmethodID windowCreatedID = NULL;
-static jmethodID enqueueMouseEventID = NULL;
-static jmethodID enqueueKeyEventID = NULL;
+static jmethodID sendMouseEventID = NULL;
+static jmethodID sendKeyEventID = NULL;
static jmethodID displayCompletedID = NULL;
@@ -291,8 +293,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay0
* Window
*/
-// #define WINDOW_EVENT_MASK ( FocusChangeMask | StructureNotifyMask | ExposureMask | VisibilityNotify )
-#define WINDOW_EVENT_MASK ( FocusChangeMask | StructureNotifyMask | VisibilityNotify )
+#define WINDOW_EVENT_MASK ( FocusChangeMask | StructureNotifyMask | ExposureMask )
static int putPtrIn32Long(unsigned long * dst, uintptr_t src) {
int i=0;
@@ -505,31 +506,37 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
switch(evt.type) {
case ButtonPress:
NewtWindows_requestFocus1 ( dpy, evt.xany.window );
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, (jint) EVENT_MOUSE_PRESSED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID,
+ (jint) EVENT_MOUSE_PRESSED,
(jint) evt.xbutton.state,
(jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/);
break;
case ButtonRelease:
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, (jint) EVENT_MOUSE_RELEASED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID,
+ (jint) EVENT_MOUSE_RELEASED,
(jint) evt.xbutton.state,
(jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/);
break;
case MotionNotify:
- (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, (jint) EVENT_MOUSE_MOVED,
+ (*env)->CallVoidMethod(env, jwindow, sendMouseEventID,
+ (jint) EVENT_MOUSE_MOVED,
(jint) evt.xmotion.state,
(jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/);
break;
case KeyPress:
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, (jint) EVENT_KEY_PRESSED,
+ (*env)->CallVoidMethod(env, jwindow, sendKeyEventID,
+ (jint) EVENT_KEY_PRESSED,
(jint) evt.xkey.state,
X11KeySym2NewtVKey(keySym), (jchar) keyChar);
break;
case KeyRelease:
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, (jint) EVENT_KEY_RELEASED,
+ (*env)->CallVoidMethod(env, jwindow, sendKeyEventID,
+ (jint) EVENT_KEY_RELEASED,
(jint) evt.xkey.state,
X11KeySym2NewtVKey(keySym), (jchar) keyChar);
- (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, (jint) EVENT_KEY_TYPED,
+ (*env)->CallVoidMethod(env, jwindow, sendKeyEventID,
+ (jint) EVENT_KEY_TYPED,
(jint) evt.xkey.state,
(jint) -1, (jchar) keyChar);
break;
@@ -546,9 +553,10 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
(unsigned int)evt.xconfigure.window, (unsigned int)evt.xconfigure.event, (unsigned int)evt.xconfigure.above,
evt.xconfigure.x, evt.xconfigure.y, evt.xconfigure.width, evt.xconfigure.height,
evt.xconfigure.override_redirect);
- (*env)->CallVoidMethod(env, jwindow, windowChangedID,
- (jint) evt.xconfigure.x, (jint) evt.xconfigure.y,
+ (*env)->CallVoidMethod(env, jwindow, sizeChangedID,
(jint) evt.xconfigure.width, (jint) evt.xconfigure.height);
+ (*env)->CallVoidMethod(env, jwindow, positionChangedID,
+ (jint) evt.xconfigure.x, (jint) evt.xconfigure.y);
break;
case ClientMessage:
if (evt.xclient.send_event==True && evt.xclient.data.l[0]==(Atom)wmDeleteAtom) {
@@ -568,25 +576,28 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
(*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE);
break;
+ case Expose:
+ DBG_PRINT( "X11: event . Expose call 0x%X %d/%d %dx%d\n", (unsigned int)evt.xexpose.window,
+ evt.xexpose.x, evt.xexpose.y, evt.xexpose.width, evt.xexpose.height);
+
+ if (evt.xexpose.width > 0 && evt.xexpose.height > 0) {
+ (*env)->CallVoidMethod(env, jwindow, windowRepaintID,
+ evt.xexpose.x, evt.xexpose.y, evt.xexpose.width, evt.xexpose.height);
+ }
+ break;
+
case MapNotify:
DBG_PRINT( "X11: event . MapNotify call 0x%X\n", (unsigned int)evt.xunmap.window);
- // FIXME (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_TRUE);
+ (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_TRUE);
break;
case UnmapNotify:
DBG_PRINT( "X11: event . UnmapNotify call 0x%X\n", (unsigned int)evt.xunmap.window);
- // FIXME (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE);
+ (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE);
break;
// unhandled events .. yet ..
- case VisibilityNotify:
- DBG_PRINT( "X11: event . VisibilityNotify call 0x%X\n", (unsigned int)evt.xvisibility.window);
- break;
- case Expose:
- DBG_PRINT( "X11: event . Expose call 0x%X\n", (unsigned int)evt.xexpose.window);
- /* FIXME: Might want to send a repaint event .. */
- break;
default:
DBG_PRINT("X11: event . unhandled %d 0x%X call 0x%X\n", evt.type, evt.type, (unsigned int)evt.xunmap.window);
}
@@ -653,23 +664,27 @@ JNIEXPORT jint JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_getHeight0
JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
(JNIEnv *env, jclass clazz)
{
- windowChangedID = (*env)->GetMethodID(env, clazz, "windowChanged", "(IIII)V");
+ sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
+ positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
+ windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V");
windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V");
- enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V");
- enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V");
+ sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
+ sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
- if (windowChangedID == NULL ||
+ if (sizeChangedID == NULL ||
+ positionChangedID == NULL ||
focusChangedID == NULL ||
visibleChangedID == NULL ||
windowDestroyNotifyID == NULL ||
windowDestroyedID == NULL ||
+ windowRepaintID == NULL ||
windowCreatedID == NULL ||
- enqueueMouseEventID == NULL ||
- enqueueKeyEventID == NULL) {
+ sendMouseEventID == NULL ||
+ sendKeyEventID == NULL) {
return JNI_FALSE;
}
return JNI_TRUE;
@@ -749,12 +764,17 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
pVisualQuery=NULL;
}
- attrMask = ( CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect ) ;
+ attrMask = ( CWBackingStore | CWBackingPlanes | CWBackingPixel | CWBackPixel |
+ CWBorderPixel | CWColormap | CWOverrideRedirect ) ;
memset(&xswa, 0, sizeof(xswa));
xswa.override_redirect = ( 0 != parent ) ? True : False ;
xswa.border_pixel = 0;
xswa.background_pixel = 0;
+ xswa.backing_store=NotUseful; /* NotUseful, WhenMapped, Always */
+ xswa.backing_planes=0; /* planes to be preserved if possible */
+ xswa.backing_pixel=0; /* value to use in restoring planes */
+
xswa.colormap = XCreateColormap(dpy,
windowParent, // XRootWindow(dpy, scrn_idx),
visual,
@@ -781,6 +801,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
setJavaWindowProperty(env, dpy, window, javaObjectAtom, (*env)->NewGlobalRef(env, obj));
+ // XClearWindow(dpy, window);
XSync(dpy, False);
{
@@ -806,7 +827,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
- (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom)
+ (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom, jlong wmDeleteAtom)
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
@@ -827,14 +848,19 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
_throwNewRuntimeException(dpy, env, "Internal Error .. Window global ref not the same!");
return;
}
- (*env)->DeleteGlobalRef(env, jwindow);
XSync(dpy, False);
XSelectInput(dpy, w, 0);
XUnmapWindow(dpy, w);
+
+ // Drain all events related to this window ..
+ JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages0(env, obj, display, javaObjectAtom, wmDeleteAtom);
+
XDestroyWindow(dpy, w);
XSync(dpy, False);
+ (*env)->DeleteGlobalRef(env, jwindow);
+
DBG_PRINT( "X11: CloseWindow END\n");
(*env)->CallVoidMethod(env, obj, windowDestroyedID);
@@ -922,6 +948,11 @@ static void NewtWindows_reparentWindow
DBG_PRINT( "X11: reparentWindow dpy %p, parent %p/%p, win %p, %d/%d undec %d\n",
(void*)dpy, (void*) jparent, (void*)parent, (void*)w, x, y, undecorated);
+ // don't propagate events during reparenting
+ // long orig_xevent_mask = xwa->your_event_mask ;
+ /* XSelectInput(dpy, w, orig_xevent_mask & ~ ( StructureNotifyMask ) );
+ XSync(dpy, False); */
+
if(0 != jparent) {
// move into parent ..
NewtWindows_setDecorations (dpy, w, False);
@@ -955,6 +986,14 @@ static void NewtWindows_reparentWindow
XSync(dpy, False);
}
+ /* XSelectInput(dpy, w, orig_xevent_mask);
+ XSync(dpy, False); */
+
+ if(JNI_TRUE == isVisible) {
+ NewtWindows_requestFocus0 ( dpy, w, xwa );
+ XSync(dpy, False);
+ }
+
DBG_PRINT( "X11: reparentWindow X\n");
}
@@ -993,12 +1032,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0
xwc.width=width;
xwc.height=height;
XConfigureWindow(dpy, w, CWX|CWY|CWWidth|CWHeight, &xwc);
-
- if(JNI_TRUE == isVisible) {
- XGetWindowAttributes(dpy, w, &xwa);
- NewtWindows_requestFocus0 ( dpy, w, &xwa );
- XSync(dpy, False);
- }
}
/*
@@ -1039,7 +1072,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reparentWindow0
JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_requestFocus0
(JNIEnv *env, jobject obj, jlong display, jlong window)
{
- NewtWindows_requestFocus ( (Display *) (intptr_t) display, (Window)window ) ;
+ NewtWindows_requestFocus1 ( (Display *) (intptr_t) display, (Window)window ) ;
}
/*