diff options
Diffstat (limited to 'src/newt/native')
-rw-r--r-- | src/newt/native/WindowsWindow.c | 43 | ||||
-rw-r--r-- | src/newt/native/X11Window.c | 32 |
2 files changed, 31 insertions, 44 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 6b8f2b73f..4bf2545ab 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -600,10 +600,11 @@ static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, } static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, BOOL reparented) { - HWND pHwnd = GetParent(hwnd); - HWND current = GetFocus(); - DBG_PRINT("*** WindowsWindow: requestFocus.0 parent %p, window %p, isCurrent %d\n", - (void*) pHwnd, (void*)hwnd, current==hwnd); + HWND pHwnd, current; + pHwnd = GetParent(hwnd); + current = GetFocus(); + DBG_PRINT("*** WindowsWindow: requestFocus.S parent %p, window %p, isCurrent %d, reparented %d\n", + (void*) pHwnd, (void*)hwnd, current==hwnd, (int) reparented); if(reparented || current!=hwnd) { if( JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) { UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE; @@ -621,6 +622,7 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, BO DBG_PRINT("*** WindowsWindow: requestFocus.X0\n"); } } + DBG_PRINT("*** WindowsWindow: requestFocus.XX\n"); } static RECT * UpdateInsets(JNIEnv *env, HWND hwnd, jobject window) @@ -738,12 +740,12 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, env = wud->jenv; window = wud->jinstance; + // DBG_PRINT("*** WindowsWindow: thread 0x%X - window %p -> %p, 0x%X %d/%d\n", (int)GetCurrentThreadId(), wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); + if (NULL==window || NULL==env) { return DefWindowProc(wnd, message, wParam, lParam); } - // DBG_PRINT("*** WindowsWindow: window %p -> %p, 0x%X %d/%d\n", wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); - switch (message) { // @@ -961,6 +963,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsDisplay_Dispatch // Periodically take a break do { gotOne = PeekMessage(&msg, (HWND) NULL, 0, 0, PM_REMOVE); + // DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne); if (gotOne) { ++i; #ifdef DEBUG_KEYS @@ -1149,7 +1152,8 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi (HINSTANCE) (intptr_t) hInstance, NULL); - DBG_PRINT("*** WindowsWindow: CreateWindow parent %p, window %p, %d/%d %dx%d\n", parentWindow, window, x, y, width, height); + DBG_PRINT("*** WindowsWindow: CreateWindow thread 0xX, parent %p, window %p, %d/%d %dx%d\n", + (int)GetCurrentThreadId(), parentWindow, window, x, y, width, height); if (NULL == window) { int lastError = (int) GetLastError(); @@ -1186,7 +1190,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_DestroyWindow0 (JNIEnv *env, jobject obj, jlong window) { - DBG_PRINT("*** WindowsWindow: DestroyWindow window %p\n", window); + DBG_PRINT("*** WindowsWindow: DestroyWindow thread 0x%X, window %p\n", (int)GetCurrentThreadId(), window); DestroyWindow((HWND) (intptr_t) window); } @@ -1362,10 +1366,10 @@ static void NewtWindows_reparentWindow(JNIEnv *env, jobject obj, HWND hwndP, HWN /* * Class: com_jogamp_newt_impl_windows_WindowsWindow - * Method: setFullscreen + * Method: reconfigureWindow0 * Signature: (JIIIIZ)V */ -JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullscreen0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_reconfigureWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated) { UINT flags; @@ -1374,7 +1378,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullsc HWND hWndInsertAfter; BOOL isVisible = IsWindowVisible(hwnd); - DBG_PRINT("*** WindowsWindow: setFullscreen.1 parent %p, window %p, %d/%d %dx%d undeco %d visible\n", + DBG_PRINT("*** WindowsWindow: reconfigureWindow0.1 parent %p, window %p, %d/%d %dx%d undeco %d visible\n", parent, window, x, y, width, height, bIsUndecorated, isVisible); NewtWindows_reparentWindow(env, obj, hwndP, hwnd, FALSE, x, y, width, height, bIsUndecorated); @@ -1388,11 +1392,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullsc } SetWindowPos(hwnd, hWndInsertAfter, x, y, width, height, flags); - if(isVisible) { - NewtWindows_requestFocus ( env, obj, hwnd, TRUE ); // request focus on this window, if not already .. - } - - DBG_PRINT("*** WindowsWindow: setFullscreen.X\n"); + DBG_PRINT("*** WindowsWindow: reconfigureWindow0.X\n"); (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height); // resize necessary .. } @@ -1409,11 +1409,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_reparentW BOOL isVisible = IsWindowVisible(hwnd); NewtWindows_reparentWindow(env, obj, hwndP, hwnd, FALSE, x, y, width, height, bIsUndecorated); - - if(isVisible) { - NewtWindows_requestFocus ( env, obj, hwnd, TRUE ); // request focus on this window, if not already .. - } - } /* @@ -1440,9 +1435,9 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setTitle0 * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_requestFocus0 - (JNIEnv *env, jobject obj, jlong window) + (JNIEnv *env, jobject obj, jlong window, jboolean bReparented) { - DBG_PRINT("*** WindowsWindow: RequestFocus0\n"); - NewtWindows_requestFocus ( env, obj, (HWND) (intptr_t) window, FALSE ) ; + DBG_PRINT("*** WindowsWindow: RequestFocus0: reparented %d\n", (int)bReparented); + NewtWindows_requestFocus ( env, obj, (HWND) (intptr_t) window, bReparented ) ; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 61575c947..350a0a704 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -393,27 +393,22 @@ static Window NewtWindows_getParent (Display *dpy, Window w) { return 0; } */ -static void NewtWindows_requestFocus0 (JNIEnv *env, jobject window, Display *dpy, Window w, XWindowAttributes *xwa, - Bool reparented){ +static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, Window w, + Bool reparented) { + XWindowAttributes xwa; Window focus_return; int revert_to_return; + + XGetWindowAttributes(dpy, w, &xwa); XGetInputFocus(dpy, &focus_return, &revert_to_return); if(reparented || focus_return!=w) { // Avoid 'BadMatch' errors from XSetInputFocus, ie if window is not viewable if( JNI_FALSE == (*env)->CallBooleanMethod(env, window, focusActionID) ) { - if(xwa->map_state == IsViewable) { + if(xwa.map_state == IsViewable) { XSetInputFocus(dpy, w, RevertToParent, CurrentTime); } } } -} - -static void NewtWindows_requestFocus1 (JNIEnv *env, jobject window, Display *dpy, Window w, - Bool reparented) { - XWindowAttributes xwa; - - XGetWindowAttributes(dpy, w, &xwa); - NewtWindows_requestFocus0 (env, window, dpy, w, &xwa, reparented); XSync(dpy, False); } @@ -904,7 +899,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0 XUnmapWindow(dpy, w); // Drain all events related to this window .. - JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages0(env, obj, display, javaObjectAtom, wmDeleteAtom); + Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages0(env, obj, display, javaObjectAtom, wmDeleteAtom); XDestroyWindow(dpy, w); XSync(dpy, False); @@ -1028,9 +1023,6 @@ static void NewtWindows_reparentWindow if(JNI_TRUE == isVisible) { XMapRaised(dpy, w); XSync(dpy, False); - - NewtWindows_requestFocus0 ( env, obj, dpy, w, xwa, True ); - XSync(dpy, False); } DBG_PRINT( "X11: reparentWindow X\n"); @@ -1038,10 +1030,10 @@ static void NewtWindows_reparentWindow /* * Class: com_jogamp_newt_impl_x11_X11Window - * Method: setPosSizeDecor0 + * Method: reconfigureWindow0 * Signature: (JJIJIIIIZ)V */ -JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0 +JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reconfigureWindow0 (JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window, jint x, jint y, jint width, jint height, jboolean undecorated, jboolean isVisible) { @@ -1052,7 +1044,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0 XWindowChanges xwc; XWindowAttributes xwa; - DBG_PRINT( "X11: setPosSizeDecor0 dpy %p, parent %p, win %p, %d/%d %dx%d undec %d, visible %d\n", + DBG_PRINT( "X11: reconfigureWindow0 dpy %p, parent %p, win %p, %d/%d %dx%d undec %d, visible %d\n", (void*)dpy, (void*) jparent, (void*)w, x, y, width, height, undecorated, isVisible); if(dpy==NULL) { @@ -1110,9 +1102,9 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reparentWindow0 * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_requestFocus0 - (JNIEnv *env, jobject obj, jlong display, jlong window) + (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean bReparented) { - NewtWindows_requestFocus1 ( env, obj, (Display *) (intptr_t) display, (Window)window, False ) ; + NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Window)window, bReparented ) ; } /* |