summaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-06-10 09:35:06 +0200
committerSven Gothel <[email protected]>2010-06-10 09:35:06 +0200
commit1d333a771ce0bc7c8594e21d031703f698f06a46 (patch)
tree933d470582896320855fa1d98c1a917edc412c24 /src/newt/native
parent4512900ddcb9ce9a498411d257b1b6d6010ec006 (diff)
Fix: Locking/Threading; Common IntIntHashMap and Buffers; Fix: glMap*Buffer*; GLX/WGL/CgGL: All runtime dynamic; Misc ..
TODO: Compile and test on MacOSX .. Fix: ===== Multithreading/Locking: See jogl/doc/Implementation/MultiThreading.txt - Locking layer is not platform agnostic, ie GLContextImpl, GLDrawableImpl, .. and NEWT: Window/Display - No more use of JAWT global lock necessary, removed. - No need for X11 Display lock, on the contrary, this made the NV driver hang. - Use common window/surface lock - All NativeWindow surfaceLock's are recursive now glMapBuffer: If size is 0, don't do cont with the native call. glMapBufferRange: Fix capacity. glNamedBufferDataEXT: Track the size. glMapNamedBufferEXT: Manual impl. - use the tracked size glXGetVisualFromFBConfig, glXChooseFBConfig, glXChooseVisual: Instead of ignoring and implement a renamed version (*Copied), we just use ManualImplementation for the proper copy-result code. DesktopGLDynamicLookupHelper: Initialize _hasGLBinding* attributes in the determing loadGLJNILibrary() method, which is called by super(). Otherwise static init will overwrite them after the super() call. X11GLXDrawableFactory: Don't release anything at shutdown (removed sharedContext.destroy()), since this caused a freeze/SEGV sometimes. Fixed NEWT's reparentWindow() functionality incl NewtCanvasAWT usage. - Native: if not visible, don't focus, etc - NewtCanvasAWT: Use the container size to start with - Run the command on the EDT Using GlueGen's new DynamicLibraryBundle utility: - X11, Windows and MacOSX OpenGL adapted to DynamicLibraryBundleInfo. - X11GLXDynamicLookupHelper -> X11GLXDynamicLibraryBundleInfo - Remove all path from lib names. - GL order: libGL.so.1, libGL.so, GL - shallLinkGlobal: true -> to server some 'old' DRI systems -> http://dri.sourceforge.net/doc/DRIuserguide.html - shallLookupGlobal: false - Try both : glXGetProcAddressARB and glXGetProcAddress - Using bootstrap: GLX.glXGetProcAddress(long glxGetProcAddressHandle, String glFuncName) Found the issue with LIBGL_DRIVERS_PATH, ie if not set no valid GL instance can be found (ie ATI fglrx/DRI). This may happen if using a differen user than the desktop user for whom the env var is set within some /etc/X11/Xsession.d/ script. Enhancements: ============= GLBufferSizeTracker: Use IntIntHashMap and add DirectState size tracking. GLBufferStateTracker: Use IntIntHashMap. GLStateTracker: Use IntIntHashMap. GLDynamicLookupHelper: More generic (global loading/lookup and GetProcAddress function name list), remove redundant code. FIXME: MacOSXCGLDynamicLookupHelper: - Not tested - Not using NSImage lookup anymore as recommended by OSX API Doc, so dlsym is used always (to be tested) WindowsWGLDynamicLookupHelper: - Not tested GLX/WGL/CgGL is all runtime-dynamic as now, ie loaded and looked-up at runtime, no compile time dependencies to GL anymore, nor a need to specify CgGL. Split up WGL in GDI and WGL, to allow proper dynamic runtime linkage of OpenGL32 while using static binding to GDI32 NEWT events generated by native code are enqueued and not send directly. This should ease locking mechanisms .. if any are necessary. NEWT: More platform specific code moved to *Impl method, simplifying the generic code of the superclass and impl protocol. Cleanup: ========= Replace all InternalBufferUtil's with com.jogamp.common.nio.Buffers Removed all InternalBufferUtil's from repository Removed GLContextImpl notion of 'optimized' surface locking, where the surface gets unlocked during makeCurrent/release. This just makes no sense and would impact multithreading in a horrible way.
Diffstat (limited to 'src/newt/native')
-rwxr-xr-xsrc/newt/native/KDWindow.c16
-rwxr-xr-xsrc/newt/native/NewtMacWindow.m50
-rwxr-xr-xsrc/newt/native/WindowsWindow.c159
-rwxr-xr-xsrc/newt/native/X11Window.c218
4 files changed, 215 insertions, 228 deletions
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index b67b8dbd3..82f2ba7df 100755
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -96,8 +96,8 @@ static jmethodID windowCreatedID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowDestroyedID = NULL;
-static jmethodID sendMouseEventID = NULL;
-static jmethodID sendKeyEventID = NULL;
+static jmethodID enqueueMouseEventID = NULL;
+static jmethodID enqueueKeyEventID = NULL;
/**
* Display
@@ -180,13 +180,13 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDDisplay_DispatchMes
// time = ev->timestamp
if(KD_INPUT_POINTER_SELECT==ptr->index) {
DBG_PRINT( "event mouse click: src: %p, s:%d, (%d,%d)\n", userData, ptr->select, ptr->x, ptr->y);
- (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID,
+ (*env)->CallVoidMethod(env, javaWindow, enqueueMouseEventID,
(ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED,
(jint) 0,
(jint) ptr->x, (jint) ptr->y, 1, 0);
} else {
DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y);
- (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED,
+ (*env)->CallVoidMethod(env, javaWindow, enqueueMouseEventID, (jint) EVENT_MOUSE_MOVED,
0,
(jint) ptr->x, (jint) ptr->y, 0, 0);
}
@@ -213,14 +213,14 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDWindow_initIDs
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V");
+ enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V");
if (windowCreatedID == NULL ||
sizeChangedID == NULL ||
windowDestroyNotifyID == NULL ||
windowDestroyedID == NULL ||
- sendMouseEventID == NULL ||
- sendKeyEventID == NULL) {
+ enqueueMouseEventID == NULL ||
+ enqueueKeyEventID == NULL) {
DBG_PRINT( "initIDs failed\n" );
return JNI_FALSE;
}
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index d8d59a7af..ae658b908 100755
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -109,8 +109,8 @@ jint GetDeltaY(NSEvent *event, jint javaMods) {
@end
-static jmethodID sendMouseEventID = NULL;
-static jmethodID sendKeyEventID = NULL;
+static jmethodID enqueueMouseEventID = NULL;
+static jmethodID enqueueKeyEventID = NULL;
static jmethodID insetsChangedID = NULL;
static jmethodID sizeChangedID = NULL;
static jmethodID positionChangedID = NULL;
@@ -122,15 +122,15 @@ static jmethodID windowDestroyedID = NULL;
+ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz
{
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V");
+ enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(II)V");
insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V");
positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V");
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
- if (sendMouseEventID && sendKeyEventID && sizeChangedID && insetsChangedID &&
+ if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && insetsChangedID &&
positionChangedID && focusChangedID && windowDestroyedID && windowDestroyNotifyID)
{
return YES;
@@ -206,7 +206,7 @@ static jint mods2JavaMods(NSUInteger mods)
return javaMods;
}
-- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType
+- (void) enqueueKeyEvent: (NSEvent*) event eventType: (jint) evType
{
NSView* nsview = [self contentView];
if( ! [nsview isMemberOfClass:[NewtView class]] ) {
@@ -229,23 +229,23 @@ static jint mods2JavaMods(NSUInteger mods)
// Note: the key code in the NSEvent does not map to anything we can use
jchar keyChar = (jchar) [chars characterAtIndex: i];
- (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID,
+ (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID,
evType, javaMods, keyCode, keyChar);
}
}
- (void) keyDown: (NSEvent*) theEvent
{
- [self sendKeyEvent: theEvent eventType: EVENT_KEY_PRESSED];
+ [self enqueueKeyEvent: theEvent eventType: EVENT_KEY_PRESSED];
}
- (void) keyUp: (NSEvent*) theEvent
{
- [self sendKeyEvent: theEvent eventType: EVENT_KEY_RELEASED];
- [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED];
+ [self enqueueKeyEvent: theEvent eventType: EVENT_KEY_RELEASED];
+ [self enqueueKeyEvent: theEvent eventType: EVENT_KEY_TYPED];
}
-- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType
+- (void) enqueueMouseEvent: (NSEvent*) event eventType: (jint) evType
{
NSView* nsview = [self contentView];
if( ! [nsview isMemberOfClass:[NewtView class]] ) {
@@ -302,7 +302,7 @@ static jint mods2JavaMods(NSUInteger mods)
// ignore 0 increment wheel scroll events
return;
}
- (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID,
+ (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID,
evType, javaMods,
(jint) location.x,
(jint) (contentRect.size.height - location.y),
@@ -311,70 +311,70 @@ static jint mods2JavaMods(NSUInteger mods)
- (void) mouseEntered: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED];
}
- (void) mouseExited: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED];
}
- (void) mouseMoved: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
}
- (void) scrollWheel: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED];
}
- (void) mouseDown: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED];
}
- (void) mouseDragged: (NSEvent*) theEvent
{
// Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
}
- (void) mouseUp: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED];
}
- (void) rightMouseDown: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED];
}
- (void) rightMouseDragged: (NSEvent*) theEvent
{
// Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
}
- (void) rightMouseUp: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED];
}
- (void) otherMouseDown: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED];
}
- (void) otherMouseDragged: (NSEvent*) theEvent
{
// Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED];
}
- (void) otherMouseUp: (NSEvent*) theEvent
{
- [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED];
+ [self enqueueMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED];
}
- (void)windowDidResize: (NSNotification*) notification
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 37fd9c621..5e3311d3b 100755
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -115,8 +115,8 @@ static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowDestroyedID = NULL;
-static jmethodID sendMouseEventID = NULL;
-static jmethodID sendKeyEventID = NULL;
+static jmethodID enqueueMouseEventID = NULL;
+static jmethodID enqueueKeyEventID = NULL;
static jmethodID sendPaintEventID = NULL;
static RECT* UpdateInsets(JNIEnv *env, HWND hwnd, jobject window);
@@ -506,7 +506,7 @@ static int WmChar(JNIEnv *env, jobject window, UINT character, UINT repCnt,
if (character == VK_RETURN) {
character = J_VK_ENTER;
}
- (*env)->CallVoidMethod(env, window, sendKeyEventID,
+ (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
(jint) EVENT_KEY_TYPED,
GetModifiers(),
(jint) -1,
@@ -551,7 +551,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
*/
- (*env)->CallVoidMethod(env, window, sendKeyEventID,
+ (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
(jint) EVENT_KEY_PRESSED,
modifiers,
(jint) jkey,
@@ -562,7 +562,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
WM_KEYDOWN.
*/
if (jkey == J_VK_DELETE) {
- (*env)->CallVoidMethod(env, window, sendKeyEventID,
+ (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
(jint) EVENT_KEY_TYPED,
GetModifiers(),
(jint) -1,
@@ -586,7 +586,7 @@ static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
character = WindowsKeyToJavaChar(wkey, modifiers, SAVE);
*/
- (*env)->CallVoidMethod(env, window, sendKeyEventID,
+ (*env)->CallVoidMethod(env, window, enqueueKeyEventID,
(jint) EVENT_KEY_RELEASED,
modifiers,
(jint) jkey,
@@ -595,11 +595,23 @@ static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt,
return 0;
}
-static void NewtWindows_requestFocus (HWND hwnd) {
+static void NewtWindows_requestFocus (HWND hwnd, BOOL topLevel, BOOL reparented) {
+ DBG_PRINT("*** WindowsWindow: requestFocus.0 window %p\n", (void*)hwnd);
if (IsWindow(hwnd)) {
- SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
+ UINT flags = SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
+ if(reparented) {
+ flags |= SWP_FRAMECHANGED;
+ }
+ SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, flags);
+ DBG_PRINT("*** WindowsWindow: requestFocus.1\n");
SetForegroundWindow(hwnd); // Slightly Higher Priority
+ DBG_PRINT("*** WindowsWindow: requestFocus.2\n");
SetFocus(hwnd);// Sets Keyboard Focus To TheWindow
+ DBG_PRINT("*** WindowsWindow: requestFocus.3\n");
+ if(topLevel) {
+ SetActiveWindow(hwnd);
+ }
+ DBG_PRINT("*** WindowsWindow: requestFocus.X\n");
}
}
@@ -786,8 +798,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
case WM_LBUTTONDOWN:
- NewtWindows_requestFocus ( wnd ); // request focus on this window, if not already ..
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ NewtWindows_requestFocus ( wnd, FALSE, FALSE ); // request focus on this window, if not already ..
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -796,7 +808,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_LBUTTONUP:
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -805,8 +817,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_MBUTTONDOWN:
- NewtWindows_requestFocus ( wnd ); // request focus on this window, if not already ..
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ NewtWindows_requestFocus ( wnd, FALSE, FALSE ); // request focus on this window, if not already ..
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -815,7 +827,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_MBUTTONUP:
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -824,8 +836,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_RBUTTONDOWN:
- NewtWindows_requestFocus ( wnd ); // request focus on this window, if not already ..
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ NewtWindows_requestFocus ( wnd, FALSE, FALSE ); // request focus on this window, if not already ..
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_PRESSED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -834,7 +846,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_RBUTTONUP:
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_RELEASED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -843,7 +855,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
break;
case WM_MOUSEMOVE:
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_MOVED,
GetModifiers(),
(jint) LOWORD(lParam), (jint) HIWORD(lParam),
@@ -859,7 +871,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message,
eventPt.x = x;
eventPt.y = y;
ScreenToClient(wnd, &eventPt);
- (*env)->CallVoidMethod(env, window, sendMouseEventID,
+ (*env)->CallVoidMethod(env, window, enqueueMouseEventID,
(jint) EVENT_MOUSE_WHEEL_MOVED,
GetModifiers(),
(jint) eventPt.x, (jint) eventPt.y,
@@ -1046,8 +1058,8 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(JZ)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)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 ||
@@ -1055,9 +1067,9 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI
focusChangedID == NULL ||
windowDestroyNotifyID == NULL ||
windowDestroyedID == NULL ||
- sendMouseEventID == NULL ||
+ enqueueMouseEventID == NULL ||
sendPaintEventID == NULL ||
- sendKeyEventID == NULL)
+ enqueueKeyEventID == NULL)
{
return JNI_FALSE;
}
@@ -1130,7 +1142,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_CreateWi
ShowWindow(window, SW_SHOWNORMAL);
if(NULL!=parentWindow) {
- NewtWindows_requestFocus ( window ); // request focus on this window, if not already ..
+ NewtWindows_requestFocus ( window, FALSE, FALSE ); // request focus on this window, if not already ..
} /* else {
// top level already capable of receiving [keyboard] events
} */
@@ -1154,6 +1166,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);
DestroyWindow((HWND) (intptr_t) window);
}
@@ -1279,25 +1292,34 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setPositi
}
}
-/*
- * Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: setFullscreen
- * Signature: (JIIIIZ)V
- */
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullscreen0
- (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated)
+static void NewtWindows_reparentWindow(HWND hwndP, HWND hwnd, jint x, jint y, jint width, jint height, jboolean bIsUndecorated)
{
UINT flags;
- HWND hwndP = (HWND) (intptr_t) parent;
- HWND hwnd = (HWND) (intptr_t) window;
HWND hWndInsertAfter;
- DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
+ DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN ;
+ BOOL isVisible = IsWindowVisible(hwnd);
+
+ DBG_PRINT("*** WindowsWindow: reparentWindow.1 parent %p, window %p, %d/%d %dx%d undeco %d visible %d\n", (void*)hwndP, (void*)hwnd, x, y, width, height, bIsUndecorated, isVisible);
+ if (!IsWindow(hwnd)) {
+ DBG_PRINT("*** WindowsWindow: reparentWindow failure: Passed window %p is invalid\n", (void*)hwnd);
+ return;
+ }
+ if (NULL!=hwndP && !IsWindow(hwndP)) {
+ DBG_PRINT("*** WindowsWindow: reparentWindow failure: Passed parent window %p is invalid\n", (void*)hwndP);
+ return;
+ }
+
+ if (isVisible) {
+ windowStyle |= WS_VISIBLE;
+ }
// order of call sequence: (MS documentation)
- // SetParent(.., NULL), SetWindowLong ( WS_POPUP )
- // SetParent(.., PARENT), SetWindowLong ( WS_CHILD )
+ // TOP: SetParent(.., NULL); Clear WS_CHILD [, Set WS_POPUP]
+ // CHILD: Set WS_CHILD [, Clear WS_POPUP]; SetParent(.., PARENT)
+ //
if ( NULL == hwndP ) {
SetParent(hwnd, NULL);
+ DBG_PRINT("*** WindowsWindow: reparentWindow.2\n");
}
if(NULL!=hwndP) {
@@ -1308,32 +1330,26 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullsc
windowStyle |= WS_OVERLAPPEDWINDOW;
}
SetWindowLong(hwnd, GWL_STYLE, windowStyle);
+ DBG_PRINT("*** WindowsWindow: reparentWindow.3\n");
if ( NULL != hwndP ) {
SetParent(hwnd, hwndP );
+ DBG_PRINT("*** WindowsWindow: reparentWindow.4\n");
}
- if ( NULL == hwndP ) {
- flags = SWP_SHOWWINDOW;
- hWndInsertAfter = HWND_TOPMOST;
- } else {
- flags = SWP_NOACTIVATE | SWP_NOZORDER;
- hWndInsertAfter = 0;
+ if(isVisible) {
+ NewtWindows_requestFocus ( hwnd, ( NULL == hwndP ) ? TRUE : FALSE, TRUE );
}
- SetWindowPos(hwnd, hWndInsertAfter, x, y, width, height, flags);
-
- NewtWindows_requestFocus ( hwnd );
-
- (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
+ DBG_PRINT("*** WindowsWindow: reparentWindow.X\n");
}
/*
* Class: com_jogamp_newt_impl_windows_WindowsWindow
- * Method: reparentWindow0
+ * Method: setFullscreen
* Signature: (JIIIIZ)V
*/
-JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_reparentWindow0
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_setFullscreen0
(JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated)
{
UINT flags;
@@ -1341,28 +1357,13 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_reparentW
HWND hwnd = (HWND) (intptr_t) window;
HWND hWndInsertAfter;
DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
+ BOOL isVisible = IsWindowVisible(hwnd);
- // order of call sequence: (MS documentation)
- // SetParent(.., NULL), SetWindowLong ( WS_POPUP )
- // SetParent(.., PARENT), SetWindowLong ( WS_CHILD )
- if ( NULL == hwndP ) {
- SetParent(hwnd, NULL);
- }
+ DBG_PRINT("*** WindowsWindow: setFullscreen.1 parent %p, window %p, %d/%d %dx%d undeco %d visible\n",
+ parent, window, x, y, width, height, bIsUndecorated, isVisible);
- if(NULL!=hwndP) {
- windowStyle |= WS_CHILD ;
- } else if (bIsUndecorated) {
- windowStyle |= WS_POPUP | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
- } else {
- windowStyle |= WS_OVERLAPPEDWINDOW;
- }
- SetWindowLong(hwnd, GWL_STYLE, windowStyle);
+ NewtWindows_reparentWindow(hwndP, hwnd, x, y, width, height, bIsUndecorated);
- if ( NULL != hwndP ) {
- SetParent(hwnd, hwndP );
- }
-
- /**
if ( NULL == hwndP ) {
flags = SWP_SHOWWINDOW;
hWndInsertAfter = HWND_TOPMOST;
@@ -1372,11 +1373,23 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_reparentW
}
SetWindowPos(hwnd, hWndInsertAfter, x, y, width, height, flags);
- */
- NewtWindows_requestFocus ( hwnd );
+ DBG_PRINT("*** WindowsWindow: setFullscreen.X\n");
+ (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height); // resize necessary ..
+}
+
+/*
+ * Class: com_jogamp_newt_impl_windows_WindowsWindow
+ * Method: reparentWindow0
+ * Signature: (JIIIIZ)V
+ */
+JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_reparentWindow0
+ (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jboolean bIsUndecorated)
+{
+ HWND hwndP = (HWND) (intptr_t) parent;
+ HWND hwnd = (HWND) (intptr_t) window;
- // (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height);
+ NewtWindows_reparentWindow(hwndP, hwnd, x, y, width, height, bIsUndecorated);
}
/*
@@ -1403,8 +1416,8 @@ 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, jclass clazz, jlong window)
+ (JNIEnv *env, jclass clazz, jlong parent, jlong window)
{
- NewtWindows_requestFocus ( (HWND) (intptr_t) window ) ;
+ NewtWindows_requestFocus ( (HWND) (intptr_t) window, (0 == parent) ? TRUE : FALSE, FALSE ) ;
}
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index f77f54cd1..a521d2dbd 100755
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -58,18 +58,7 @@
// #define VERBOSE_ON 1
#ifdef VERBOSE_ON
- // Workaround for ancient compiler on Solaris/SPARC
- // #define DBG_PRINT(args...) fprintf(stderr, args);
- #define DBG_PRINT0(str) fprintf(stderr, str);
- #define DBG_PRINT1(str, arg1) fprintf(stderr, str, arg1);
- #define DBG_PRINT2(str, arg1, arg2) fprintf(stderr, str, arg1, arg2);
- #define DBG_PRINT3(str, arg1, arg2, arg3) fprintf(stderr, str, arg1, arg2, arg3);
- #define DBG_PRINT4(str, arg1, arg2, arg3, arg4) fprintf(stderr, str, arg1, arg2, arg3, arg4);
- #define DBG_PRINT5(str, arg1, arg2, arg3, arg4, arg5) fprintf(stderr, str, arg1, arg2, arg3, arg4, arg5);
- #define DBG_PRINT6(str, arg1, arg2, arg3, arg4, arg5, arg6) fprintf(stderr, str, arg1, arg2, arg3, arg4, arg5, arg6);
- #define DBG_PRINT7(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7) fprintf(stderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
- #define DBG_PRINT8(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) fprintf(stderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
- #define DBG_PRINT9(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) fprintf(stderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+ #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
#define DUMP_VISUAL_INFO(a,b) _dumpVisualInfo((a),(b))
@@ -95,18 +84,7 @@
#else
- // Workaround for ancient compiler on Solaris/SPARC
- // #define DBG_PRINT(args...)
- #define DBG_PRINT0(str)
- #define DBG_PRINT1(str, arg1)
- #define DBG_PRINT2(str, arg1, arg2)
- #define DBG_PRINT3(str, arg1, arg2, arg3)
- #define DBG_PRINT4(str, arg1, arg2, arg3, arg4)
- #define DBG_PRINT5(str, arg1, arg2, arg3, arg4, arg5)
- #define DBG_PRINT6(str, arg1, arg2, arg3, arg4, arg5, arg6)
- #define DBG_PRINT7(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
- #define DBG_PRINT8(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
- #define DBG_PRINT9(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
+ #define DBG_PRINT(...)
#define DUMP_VISUAL_INFO(a,b)
@@ -179,8 +157,8 @@ static jmethodID visibleChangedID = NULL;
static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowDestroyedID = NULL;
static jmethodID windowCreatedID = NULL;
-static jmethodID sendMouseEventID = NULL;
-static jmethodID sendKeyEventID = NULL;
+static jmethodID enqueueMouseEventID = NULL;
+static jmethodID enqueueKeyEventID = NULL;
static jmethodID displayCompletedID = NULL;
@@ -189,10 +167,6 @@ static void _throwNewRuntimeException(Display * unlockDisplay, JNIEnv *env, cons
char buffer[512];
va_list ap;
- if(NULL!=unlockDisplay) {
- XUnlockDisplay(unlockDisplay);
- }
-
va_start(ap, msg);
vsnprintf(buffer, sizeof(buffer), msg, ap);
va_end(ap);
@@ -293,7 +267,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay0
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
javaObjectAtom = (jlong) XInternAtom(dpy, "JOGL_JAVA_OBJECT", False);
if(None==javaObjectAtom) {
@@ -308,9 +281,8 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_CompleteDisplay0
}
// XSetCloseDownMode(dpy, RetainTemporary); // Just a try ..
- XUnlockDisplay(dpy) ;
- DBG_PRINT1("X11: X11Display_completeDisplay dpy %p\n", dpy);
+ DBG_PRINT("X11: X11Display_completeDisplay dpy %p\n", dpy);
(*env)->CallVoidMethod(env, obj, displayCompletedID, javaObjectAtom, windowDeleteAtom);
}
@@ -409,13 +381,9 @@ static void NewtWindows_requestFocus0 (Display *dpy, Window w, XWindowAttributes
static void NewtWindows_requestFocus1 (Display *dpy, Window w) {
XWindowAttributes xwa;
- XLockDisplay(dpy) ;
-
XGetWindowAttributes(dpy, w, &xwa);
NewtWindows_requestFocus0 (dpy, w, &xwa);
XSync(dpy, False);
-
- XUnlockDisplay(dpy) ;
}
/**
@@ -480,14 +448,11 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
char keyChar;
char text[255];
- XLockDisplay(dpy) ;
-
// num_events = XPending(dpy); // I/O Flush ..
// num_events = XEventsQueued(dpy, QueuedAfterFlush); // I/O Flush only of no already queued events are available
// num_events = XEventsQueued(dpy, QueuedAlready); // no I/O Flush at all, doesn't work on some cards (eg ATI)
if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) {
- XUnlockDisplay(dpy) ;
- // DBG_PRINT1( "X11: DispatchMessages 0x%X - Leave 1\n", dpy);
+ // DBG_PRINT( "X11: DispatchMessages 0x%X - Leave 1\n", dpy);
return;
}
@@ -504,7 +469,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
return ;
}
- DBG_PRINT3( "X11: DispatchMessages dpy %p, win %p, Event %d\n", (void*)dpy, (void*)evt.xany.window, evt.type);
+ DBG_PRINT( "X11: DispatchMessages dpy %p, win %p, Event %d\n", (void*)dpy, (void*)evt.xany.window, evt.type);
displayDispatchErrorHandlerEnable(1, env);
@@ -521,8 +486,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
if(NULL==jwindow) {
fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for X11 window %p\n",
(void*)dpy, evt.type, (void*)evt.xany.window);
-
- XUnlockDisplay(dpy) ;
continue;
}
@@ -539,49 +502,47 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
break;
}
- XUnlockDisplay(dpy) ;
-
switch(evt.type) {
case ButtonPress:
NewtWindows_requestFocus1 ( dpy, evt.xany.window );
- (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED,
+ (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, (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, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED,
+ (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, (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, sendMouseEventID, (jint) EVENT_MOUSE_MOVED,
+ (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, (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, sendKeyEventID, (jint) EVENT_KEY_PRESSED,
+ (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, (jint) EVENT_KEY_PRESSED,
(jint) evt.xkey.state,
X11KeySym2NewtVKey(keySym), (jchar) keyChar);
break;
case KeyRelease:
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED,
+ (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, (jint) EVENT_KEY_RELEASED,
(jint) evt.xkey.state,
X11KeySym2NewtVKey(keySym), (jchar) keyChar);
- (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED,
+ (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, (jint) EVENT_KEY_TYPED,
(jint) evt.xkey.state,
(jint) -1, (jchar) keyChar);
break;
case DestroyNotify:
- DBG_PRINT1( "X11: event . DestroyNotify call 0x%X\n", (unsigned int)evt.xdestroywindow.window);
+ DBG_PRINT( "X11: event . DestroyNotify call 0x%X\n", (unsigned int)evt.xdestroywindow.window);
(*env)->CallVoidMethod(env, jwindow, windowDestroyedID);
break;
case CreateNotify:
- DBG_PRINT1( "X11: event . CreateNotify call 0x%X\n", (unsigned int)evt.xcreatewindow.window);
+ DBG_PRINT( "X11: event . CreateNotify call 0x%X\n", (unsigned int)evt.xcreatewindow.window);
(*env)->CallVoidMethod(env, jwindow, windowCreatedID);
break;
case ConfigureNotify:
- DBG_PRINT8( "X11: event . ConfigureNotify call 0x%X (parent 0x%X, above 0x%X) %d/%d %dx%d %d\n",
+ DBG_PRINT( "X11: event . ConfigureNotify call 0x%X (parent 0x%X, above 0x%X) %d/%d %dx%d %d\n",
(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);
@@ -591,43 +552,43 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages
break;
case ClientMessage:
if (evt.xclient.send_event==True && evt.xclient.data.l[0]==(Atom)wmDeleteAtom) {
- DBG_PRINT2( "X11: event . ClientMessage call 0x%X type 0x%X !!!\n", (unsigned int)evt.xclient.window, (unsigned int)evt.xclient.message_type);
+ DBG_PRINT( "X11: event . ClientMessage call 0x%X type 0x%X !!!\n", (unsigned int)evt.xclient.window, (unsigned int)evt.xclient.message_type);
(*env)->CallVoidMethod(env, jwindow, windowDestroyNotifyID);
// Called by Window.java: CloseWindow();
}
break;
case FocusIn:
- DBG_PRINT1( "X11: event . FocusIn call 0x%X\n", (unsigned int)evt.xvisibility.window);
+ DBG_PRINT( "X11: event . FocusIn call 0x%X\n", (unsigned int)evt.xvisibility.window);
(*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_TRUE);
break;
case FocusOut:
- DBG_PRINT1( "X11: event . FocusOut call 0x%X\n", (unsigned int)evt.xvisibility.window);
+ DBG_PRINT( "X11: event . FocusOut call 0x%X\n", (unsigned int)evt.xvisibility.window);
(*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE);
break;
case MapNotify:
- DBG_PRINT1( "X11: event . MapNotify call 0x%X\n", (unsigned int)evt.xunmap.window);
+ DBG_PRINT( "X11: event . MapNotify call 0x%X\n", (unsigned int)evt.xunmap.window);
// FIXME (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_TRUE);
break;
case UnmapNotify:
- DBG_PRINT1( "X11: event . UnmapNotify call 0x%X\n", (unsigned int)evt.xunmap.window);
+ DBG_PRINT( "X11: event . UnmapNotify call 0x%X\n", (unsigned int)evt.xunmap.window);
// FIXME (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE);
break;
// unhandled events .. yet ..
case VisibilityNotify:
- DBG_PRINT1( "X11: event . VisibilityNotify call 0x%X\n", (unsigned int)evt.xvisibility.window);
+ DBG_PRINT( "X11: event . VisibilityNotify call 0x%X\n", (unsigned int)evt.xvisibility.window);
break;
case Expose:
- DBG_PRINT1( "X11: event . Expose call 0x%X\n", (unsigned int)evt.xexpose.window);
+ 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_PRINT3("X11: event . unhandled %d 0x%X call 0x%X\n", evt.type, evt.type, (unsigned int)evt.xunmap.window);
+ DBG_PRINT("X11: event . unhandled %d 0x%X call 0x%X\n", evt.type, evt.type, (unsigned int)evt.xunmap.window);
}
}
}
@@ -648,10 +609,11 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_GetScreen0
Display * dpy = (Display *)(intptr_t)display;
Screen * scrn= NULL;
+ DBG_PRINT("X11: X11Screen_GetScreen0 dpy %p START\n", dpy);
+
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy);
scrn = ScreenOfDisplay(dpy,screen_index);
if(scrn==NULL) {
@@ -660,7 +622,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Screen_GetScreen0
if(scrn==NULL) {
fprintf(stderr, "couldn't get screen ..\n");
}
- XUnlockDisplay(dpy) ;
+ DBG_PRINT("X11: X11Screen_GetScreen0 scrn %p DONE\n", scrn);
return (jlong) (intptr_t) scrn;
}
@@ -697,8 +659,8 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V");
windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V");
windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V");
- sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
- sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
+ enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(IIIIII)V");
+ enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(IIIC)V");
if (windowChangedID == NULL ||
focusChangedID == NULL ||
@@ -706,8 +668,8 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0
windowDestroyNotifyID == NULL ||
windowDestroyedID == NULL ||
windowCreatedID == NULL ||
- sendMouseEventID == NULL ||
- sendKeyEventID == NULL) {
+ enqueueMouseEventID == NULL ||
+ enqueueKeyEventID == NULL) {
return JNI_FALSE;
}
return JNI_TRUE;
@@ -751,15 +713,13 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
return 0;
}
- XLockDisplay(dpy) ;
-
XSync(dpy, False);
scrn = ScreenOfDisplay(dpy, scrn_idx);
if(0==windowParent) {
windowParent = XRootWindowOfScreen(scrn);
}
- DBG_PRINT7( "X11: CreateWindow dpy %p, parent %p, %x/%d %dx%d, undeco %d\n",
+ DBG_PRINT( "X11: CreateWindow dpy %p, parent %p, %x/%d %dx%d, undeco %d\n",
(void*)dpy, (void*)windowParent, x, y, width, height, undecorated);
// try given VisualID on screen
@@ -775,7 +735,7 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
XFree(pVisualQuery);
pVisualQuery=NULL;
}
- DBG_PRINT5( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent %p) found: %p\n",
+ DBG_PRINT( "X11: [CreateWindow] trying given (dpy %p, screen %d, visualID: %d, parent %p) found: %p\n",
dpy, scrn_idx, (int)visualID, (void*)windowParent, visual);
if (visual==NULL)
@@ -831,12 +791,10 @@ JNIEXPORT jlong JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CreateWindow0
XSelectInput(dpy, window, xevent_mask);
}
- NewtWindows_setDecorations (dpy, window, ( JNI_TRUE == undecorated ) ? False : True );
-
+ NewtWindows_setDecorations(dpy, window, ( JNI_TRUE == undecorated ) ? False : True );
XSync(dpy, False);
- XUnlockDisplay(dpy) ;
- DBG_PRINT2( "X11: [CreateWindow] created window 0x%X on display %p\n", (unsigned int)window, dpy);
+ DBG_PRINT( "X11: [CreateWindow] created window 0x%X on display %p\n", (unsigned int)window, dpy);
(*env)->CallVoidMethod(env, obj, windowCreatedID, (jlong) window);
return (jlong) window;
@@ -857,9 +815,8 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
- DBG_PRINT2( "X11: CloseWindow START dpy %p, win %p\n", (void*)dpy, (void*)w);
+ DBG_PRINT( "X11: CloseWindow START dpy %p, win %p\n", (void*)dpy, (void*)w);
jwindow = getJavaWindowProperty(env, dpy, w, javaObjectAtom, True);
if(NULL==jwindow) {
@@ -878,8 +835,7 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0
XDestroyWindow(dpy, w);
XSync(dpy, False);
- DBG_PRINT0( "X11: CloseWindow END\n");
- XUnlockDisplay(dpy) ;
+ DBG_PRINT( "X11: CloseWindow END\n");
(*env)->CallVoidMethod(env, obj, windowDestroyedID);
}
@@ -894,12 +850,11 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setVisible0
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
- DBG_PRINT1( "X11: setVisible0 vis %d\n", visible);
+ DBG_PRINT( "X11: setVisible0 vis %d\n", visible);
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
if(visible==JNI_TRUE) {
XMapRaised(dpy, w);
@@ -907,7 +862,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setVisible0
XUnmapWindow(dpy, w);
}
XSync(dpy, False);
- XUnlockDisplay(dpy) ;
}
/*
@@ -922,12 +876,11 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setSize0
Window w = (Window)window;
XWindowChanges xwc;
- DBG_PRINT2( "X11: setSize0 %dx%d\n", width, height);
+ DBG_PRINT( "X11: setSize0 %dx%d\n", width, height);
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
memset(&xwc, 0, sizeof(XWindowChanges));
xwc.width=width;
@@ -935,7 +888,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setSize0
XConfigureWindow(dpy, w, CWWidth|CWHeight, &xwc);
XSync(dpy, False);
- XUnlockDisplay(dpy) ;
}
/*
@@ -950,47 +902,60 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosition0
Window w = (Window)window;
XWindowChanges xwc;
- DBG_PRINT2( "X11: setPos0 . XConfigureWindow %d/%d\n", x, y);
+ DBG_PRINT( "X11: setPos0 . XConfigureWindow %d/%d\n", x, y);
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
memset(&xwc, 0, sizeof(XWindowChanges));
xwc.x=x;
xwc.y=y;
XConfigureWindow(dpy, w, CWX|CWY, &xwc);
XSync(dpy, False);
-
- XUnlockDisplay(dpy) ;
}
static void NewtWindows_reparentWindow
- (Display * dpy, Screen * scrn, Window w, XWindowAttributes *xwa, jlong jparent, jint x, jint y, jboolean undecorated)
+ (Display * dpy, Screen * scrn, Window w, XWindowAttributes *xwa, jlong jparent, jint x, jint y, jboolean undecorated, jboolean isVisible)
{
Window parent = (0!=jparent)?(Window)jparent:XRootWindowOfScreen(scrn);
- DBG_PRINT7( "X11: reparentWindow dpy %p, parent %p/%p, win %p, %d/%d undec %d\n",
+ 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);
- // let parent ignore reparent request
- NewtWindows_setOverrideRedirect0 (dpy, w, xwa, True);
- if(JNI_TRUE == undecorated) {
+ if(0 != jparent) {
+ // move into parent ..
NewtWindows_setDecorations (dpy, w, False);
+ XSync(dpy, False);
+ NewtWindows_setOverrideRedirect0 (dpy, w, xwa, True);
+ XSync(dpy, False);
+ }
+
+ if(JNI_TRUE == isVisible) {
+ XUnmapWindow(dpy, w);
+ XSync(dpy, False);
}
- XSync(dpy, False);
XReparentWindow( dpy, w, parent, x, y );
- XRaiseWindow(dpy, w);
XSync(dpy, False);
- NewtWindows_setOverrideRedirect0 (dpy, w, xwa, ( 0 != jparent ) ? True : False );
- if(JNI_FALSE == undecorated) {
- NewtWindows_setDecorations (dpy, w, True);
+ if(0 == jparent)
+ {
+ // move out of parent ..
+ NewtWindows_setOverrideRedirect0 (dpy, w, xwa, (0 == jparent) ? False : True);
+ XSync(dpy, False);
+ NewtWindows_setDecorations (dpy, w, (JNI_TRUE == undecorated) ? False : True);
+ XSync(dpy, False);
}
- XSync(dpy, False);
- DBG_PRINT0( "X11: reparentWindow X\n");
+ if(JNI_TRUE == isVisible) {
+ XRaiseWindow(dpy, w);
+ XSync(dpy, False);
+
+ XMapWindow(dpy, w);
+ XSync(dpy, False);
+ }
+
+ DBG_PRINT( "X11: reparentWindow X\n");
}
/*
@@ -1000,7 +965,7 @@ static void NewtWindows_reparentWindow
*/
JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0
(JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window,
- jint x, jint y, jint width, jint height, jboolean undecorated)
+ jint x, jint y, jint width, jint height, jboolean undecorated, jboolean isVisible)
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
@@ -1009,18 +974,18 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0
XWindowChanges xwc;
XWindowAttributes xwa;
- DBG_PRINT8( "X11: setPosSizeDecor0 dpy %p, parent %p, win %p, %d/%d %dx%d undec %d\n",
- (void*)dpy, (void*) jparent, (void*)w, x, y, width, height, undecorated);
+ DBG_PRINT( "X11: setPosSizeDecor0 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) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
XSync(dpy, False);
XGetWindowAttributes(dpy, w, &xwa);
- NewtWindows_reparentWindow(dpy, scrn, w, &xwa, jparent, x, y, undecorated);
+ NewtWindows_reparentWindow(dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
+ XSync(dpy, False);
memset(&xwc, 0, sizeof(XWindowChanges));
xwc.x=x;
@@ -1028,11 +993,12 @@ 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);
- XSync(dpy, False);
- NewtWindows_requestFocus0 ( dpy, w, &xwa );
- XSync(dpy, False);
- XUnlockDisplay(dpy) ;
+ if(JNI_TRUE == isVisible) {
+ XGetWindowAttributes(dpy, w, &xwa);
+ NewtWindows_requestFocus0 ( dpy, w, &xwa );
+ XSync(dpy, False);
+ }
}
/*
@@ -1041,28 +1007,28 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setPosSizeDecor0
* Signature: (JJIJIIZ)V
*/
JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reparentWindow0
- (JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window, jint x, jint y, jboolean undecorated)
+ (JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window, jint x, jint y,
+ jboolean undecorated, jboolean isVisible)
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
Screen * scrn = ScreenOfDisplay(dpy, (int)screen_index);
XWindowAttributes xwa;
- DBG_PRINT6( "X11: reparentWindow0 dpy %p, parent %p, win %p, %d/%d undec %d\n",
- (void*)dpy, (void*) jparent, (void*)w, x, y, undecorated);
+ DBG_PRINT( "X11: reparentWindow0 dpy %p, parent %p, win %p, %d/%d undec %d, visible %d\n",
+ (void*)dpy, (void*) jparent, (void*)w, x, y, undecorated, isVisible);
if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}
- XLockDisplay(dpy) ;
XSync(dpy, False);
XGetWindowAttributes(dpy, w, &xwa);
- NewtWindows_reparentWindow(dpy, scrn, w, &xwa, jparent, x, y, undecorated);
+ NewtWindows_reparentWindow(dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
+ XSync(dpy, False);
- XUnlockDisplay(dpy) ;
- DBG_PRINT0( "X11: reparentWindow0 X\n");
+ DBG_PRINT( "X11: reparentWindow0 X\n");
}
/*
@@ -1087,15 +1053,19 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setTitle0
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
- XLockDisplay(dpy) ;
#if 1
const char* title_str;
if (NULL != title) {
title_str = (*env)->GetStringUTFChars(env, title, NULL);
if(NULL != title_str) {
+ DBG_PRINT( "X11: setTitle: <%s> SET\n", title_str);
XStoreName(dpy, w, title_str);
(*env)->ReleaseStringUTFChars(env, title, title_str);
+ } else {
+ DBG_PRINT( "X11: setTitle: NULL - NOT SET (1)\n");
}
+ } else {
+ DBG_PRINT( "X11: setTitle: NULL TITLE\n");
}
#else
char *str_list[] = { NULL };
@@ -1105,18 +1075,22 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_setTitle0
if (str_list[0] != NULL) {
memset(&text_prop, 0, sizeof(XTextProperty));
if ( Success != XmbTextListToTextProperty(dpy, str_list, 1, XStringStyle, &text_prop) ) {
- DBG_PRINT0( "X11: setTitle.XmbTextListToTextProperty not completly successfull\n");
+ DBG_PRINT( "X11: setTitle.XmbTextListToTextProperty not completly successfull\n");
fprintf(stderr, "X11: setTitle.XmbTextListToTextProperty not completly successfull\n");
}
if(NULL!=text_prop.value) {
+ DBG_PRINT( "X11: setTitle: <%s> SET\n", str_list[0]);
XSetWMName(dpy, w, &text_prop);
XFree(text_prop.value);
+ } else {
+ DBG_PRINT( "X11: setTitle: <%s> NOT SET (1)\n", str_list[0]);
}
free(str_list[0]);
+ } else {
+ DBG_PRINT( "X11: setTitle: NULL\n");
}
}
#endif
- XUnlockDisplay(dpy) ;
}