aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java28
-rw-r--r--src/newt/native/WindowsWindow.c4
-rw-r--r--src/newt/native/X11Window.c4
3 files changed, 26 insertions, 10 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 75c3510b7..6c71e6082 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -274,18 +274,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
throw new InternalError("XXX");
}
if(canCreateNativeImpl()) {
- final int _x = x, _y = y; // orig req pos
+ int _x = x, _y = y; // orig req pos
screen.addReference();
screenReferenceAdded = true;
createNativeImpl();
screen.addScreenModeListener(screenModeListenerImpl);
setTitleImpl(title);
- waitForVisible(true, false);
- if(userPos) {
- // wait for user req position
- waitForPosSize(_x, _y, -1, -1, false, TIMEOUT_NATIVEWINDOW);
- } else {
- waitForAnyPos(false, TIMEOUT_NATIVEWINDOW);
+ if(waitForVisible(true, false)) {
+ if(userPos) {
+ // fix req position about window decoration
+ _x = Math.max(_x, insets.getLeftWidth());
+ _y = Math.max(_y, insets.getTopHeight());
+ // wait for user req position
+ waitForPosSize(_x, _y, -1, -1, false, TIMEOUT_NATIVEWINDOW);
+ } else {
+ waitForAnyPos(false, TIMEOUT_NATIVEWINDOW);
+ }
}
}
// always flag visible,
@@ -387,8 +391,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
/**
* The native implementation must set the native windowHandle.<br>
*
+ * <p>
* The implementation should invoke the referenced java state callbacks
- * to notify this Java object of state changes.
+ * to notify this Java object of state changes.</p>
+ *
+ * <p>
+ * In case the implementation supports a deterministic size/pos mechanism,
+ * i.e. is able to determine the correct size/pos,
+ * it shall invalidate such values via the callbacks allowing the caller
+ * to wait until the values are reached - notified by the WM.<br>
+ * This is currently implemented for X11 and Windows.</p>
*
* @see #windowDestroyNotify()
* @see #focusChanged(boolean)
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index 1cb0f2036..6990bcb83 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -1388,9 +1388,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWind
BOOL userPos = 0<=x && 0<=y ;
ShowWindow(window, SW_SHOW);
- (*env)->CallVoidMethod(env, wud->jinstance, visibleChangedID, JNI_TRUE);
+ // send insets before visibility, allowing java code a proper sync point!
insets = UpdateInsets(env, wud->jinstance, window);
+ (*env)->CallVoidMethod(env, wud->jinstance, visibleChangedID, JNI_TRUE);
+
if(!userPos) {
GetWindowRect(window, &rc);
x = rc.left + insets->left; // client coords
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 39e8f9476..90b16a5c3 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -1618,9 +1618,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0
XMapWindow(dpy, window);
XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) window ); // wait to get proper insets values
- (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_TRUE);
+ // send insets before visibility, allowing java code a proper sync point!
NewtWindows_updateInsets(env, jwindow, dpy, window, &left, &right, &top, &bottom);
+ (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_TRUE);
+
if(!userPos) {
// get position from WM
int dest_x, dest_y;