diff options
author | Sven Gothel <[email protected]> | 2010-12-23 06:26:47 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-12-23 06:26:47 +0100 |
commit | e7778124162aef7004e040dded5de1eaf5e1ece4 (patch) | |
tree | b750b24a7d3e5c3e008701760af7e9b74b43f4b4 /src/newt/native | |
parent | 1c2a11a54949188d6704558f7fa38ecf8e811118 (diff) |
NEWT: Add WindowListener.windowDestroyed() ; Remove WindowImpl.windowDestroyed()
Add WindowListener.windowDestroyed()
To expose a proper window lifecycle, ie destroy-notify and destroyed,
this notification is added.
This will be used at least in unit tests, where we verify destruction.
Remove WindowImpl.windowDestroyed():
This native hook (planned to be called by native destroy notification)
is unreliable or not supported for all platforms.
NEWT relies on the pre destroy native hooks and handles the final
destroy notification itself.
Diffstat (limited to 'src/newt/native')
-rw-r--r-- | src/newt/native/KDWindow.c | 5 | ||||
-rw-r--r-- | src/newt/native/NewtMacWindow.m | 5 | ||||
-rw-r--r-- | src/newt/native/WindowEvent.h | 13 | ||||
-rw-r--r-- | src/newt/native/WindowsWindow.c | 7 | ||||
-rw-r--r-- | src/newt/native/X11Window.c | 6 |
5 files changed, 9 insertions, 27 deletions
diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 33af4d963..50ad22b5a 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -94,7 +94,6 @@ static jmethodID windowCreatedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; -static jmethodID windowDestroyedID = NULL; static jmethodID sendMouseEventID = NULL; static jmethodID sendKeyEventID = NULL; @@ -137,8 +136,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDDisplay_DispatchMes { DBG_PRINT( "event window close : src: %p\n", userData); (*env)->CallVoidMethod(env, javaWindow, windowDestroyNotifyID); - // Called by Window.java: DestroyWindow(wnd); - // (*env)->CallVoidMethod(env, javaWindow, windowDestroyedID); } break; case KD_EVENT_WINDOWPROPERTY_CHANGE: @@ -213,14 +210,12 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_opengl_kd_KDWindow_initIDs sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)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"); if (windowCreatedID == NULL || sizeChangedID == NULL || visibleChangedID == NULL || windowDestroyNotifyID == NULL || - windowDestroyedID == NULL || sendMouseEventID == NULL || sendKeyEventID == NULL) { DBG_PRINT( "initIDs failed\n" ); diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 2d8a84b4b..cba69498a 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -80,7 +80,6 @@ static jmethodID visibleChangedID = NULL; static jmethodID positionChangedID = NULL; static jmethodID focusChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; -static jmethodID windowDestroyedID = NULL; @implementation NewtView - (void) setJNIEnv: (JNIEnv*) theEnv @@ -142,9 +141,8 @@ static jmethodID windowDestroyedID = NULL; 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 && visibleChangedID && insetsChangedID && - positionChangedID && focusChangedID && windowDestroyedID && windowDestroyNotifyID) + positionChangedID && focusChangedID && windowDestroyNotifyID) { return YES; } @@ -456,7 +454,6 @@ static jint mods2JavaMods(NSUInteger mods) (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyNotifyID); // Can't issue call here - locked window state, done from Java method - // (*env)->CallVoidMethod(env, javaWindowObject, windowDestroyedID); // No OSX hook for DidClose, so do it here // EOL .. (*env)->DeleteGlobalRef(env, javaWindowObject); diff --git a/src/newt/native/WindowEvent.h b/src/newt/native/WindowEvent.h index 6274f9443..05491b43c 100644 --- a/src/newt/native/WindowEvent.h +++ b/src/newt/native/WindowEvent.h @@ -2,11 +2,12 @@ #ifndef _WINDOW_EVENT_H_ #define _WINDOW_EVENT_H_ -#define EVENT_WINDOW_RESIZED = 100; -#define EVENT_WINDOW_MOVED = 101; -#define EVENT_WINDOW_DESTROY_NOTIFY = 102; -#define EVENT_WINDOW_GAINED_FOCUS = 103; -#define EVENT_WINDOW_LOST_FOCUS = 104; -#define EVENT_WINDOW_REPAINT = 105; // TODO +#define EVENT_WINDOW_RESIZED 100 +#define EVENT_WINDOW_MOVED 101 +#define EVENT_WINDOW_DESTROY_NOTIFY 102 +#define EVENT_WINDOW_GAINED_FOCUS 103 +#define EVENT_WINDOW_LOST_FOCUS 104 +#define EVENT_WINDOW_REPAINT 105 +#define EVENT_WINDOW_DESTROYED 106 #endif diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index cafdaeef8..998743e75 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -124,7 +124,6 @@ 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 enqueueMouseEventID = NULL; static jmethodID sendMouseEventID = NULL; @@ -820,8 +819,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, // // The signal pipeline for destruction is: // Java::DestroyWindow(wnd) _or_ window-close-button -> - // WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY -> Java::windowDestroyed -> - // Java::CleanupWindowResources() + // WM_CLOSE -> Java::windowDestroyNotify -> W_DESTROY case WM_CLOSE: (*env)->CallVoidMethod(env, window, windowDestroyNotifyID); break; @@ -834,7 +832,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, SetWindowLongPtr(wnd, GWLP_USERDATA, (intptr_t) NULL); #endif free(wud); wud=NULL; - (*env)->CallVoidMethod(env, window, windowDestroyedID); (*env)->DeleteGlobalRef(env, window); } break; @@ -1267,7 +1264,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI 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"); enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); @@ -1282,7 +1278,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_windows_WindowsWindow_initI focusChangedID == NULL || visibleChangedID == NULL || windowDestroyNotifyID == NULL || - windowDestroyedID == NULL || windowRepaintID == NULL || enqueueMouseEventID == NULL || sendMouseEventID == NULL || diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 15418269e..d30e5de59 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -147,7 +147,6 @@ 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 windowReparentedID = NULL; static jmethodID enqueueMouseEventID = NULL; @@ -624,7 +623,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Display_DispatchMessages (void*)evt.xdestroywindow.window, (void*)evt.xdestroywindow.event, evt.xdestroywindow.window != evt.xdestroywindow.event); if ( evt.xdestroywindow.window == evt.xdestroywindow.event ) { // ignore child destroy notification - (*env)->CallVoidMethod(env, jwindow, windowDestroyedID); } break; case CreateNotify: @@ -1191,7 +1189,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0 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"); windowReparentedID = (*env)->GetMethodID(env, clazz, "windowReparented", "(J)V"); enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); @@ -1206,7 +1203,6 @@ JNIEXPORT jboolean JNICALL Java_com_jogamp_newt_impl_x11_X11Window_initIDs0 focusChangedID == NULL || visibleChangedID == NULL || windowDestroyNotifyID == NULL || - windowDestroyedID == NULL || windowRepaintID == NULL || windowReparentedID == NULL || enqueueMouseEventID == NULL || @@ -1394,8 +1390,6 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_CloseWindow0 (*env)->DeleteGlobalRef(env, jwindow); DBG_PRINT( "X11: CloseWindow END\n"); - - (*env)->CallVoidMethod(env, obj, windowDestroyedID); } static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint width, jint height) |