From 4e0eb391d6c64f956ea5c87c0385ab48a24b2175 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Tue, 1 May 2012 09:21:14 +0200
Subject: Fix Bug 560 and NEWT window closing behavior in general for all
 platforms.

- NEWT/WindowImpl:
  - 'void windowDestroyNotify()' -> 'boolean windowDestroyNotify(boolean force)', allowing to signal a forced close,
    as well as replying whether the window has been closed. (called by native code)

  - destroy(): set states before releasing the window lock

- NEWT/X11: Pass windowDeleteAtom for reconfigure window, in case of reparenting child to top-level

- NEWT/OSX:
  - Add 'BOOL windowShouldClose()' impl., ie. having a chance to reject the close attempt
  - Common impl. for 'windowShouldClose' and 'windowWillClose' -> 'windowClosingImpl'
    utilizing new 'windowDestroyNotify' code (see above).
    Fixes bug 560.

- NEWT/JOGLNewtApplet1Run: Refine out-of browser window behavior for window-close button
  - default: move NEWT window back to browser parent
  - closeable: close NEWT window

- jogl-test-applets: Add NApplet-Closeable test (Applet out-of browser window is closable)
---
 src/newt/native/KDWindow.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/newt/native/KDWindow.c')

diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c
index e6bc7952e..dc999138c 100644
--- a/src/newt/native/KDWindow.c
+++ b/src/newt/native/KDWindow.c
@@ -114,8 +114,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDDisplay_DispatchMessages
                 break;
             case KD_EVENT_WINDOW_CLOSE:
                 {
-                    DBG_PRINT( "event window close : src: %p\n", userData);
-                    (*env)->CallVoidMethod(env, javaWindow, windowDestroyNotifyID);
+                    jboolean closed;
+                    DBG_PRINT( "event window close : src: %p .. \n", userData);
+                    closed = (*env)->CallBooleanMethod(env, javaWindow, windowDestroyNotifyID, JNI_FALSE);
+                    DBG_PRINT( "event window close : src: %p, closed %d\n", userData, (int)closed);
                 }
                 break;
             case KD_EVENT_WINDOWPROPERTY_CHANGE:
@@ -189,7 +191,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_KDWindow_initIDs
     windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V");
     sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V");
     visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V");
-    windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify",    "()V");
+    windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z");
     sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V");
     sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V");
     if (windowCreatedID == NULL ||
-- 
cgit v1.2.3