From 472a9c60b5599bb01883c628339ab29628511ed5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 27 Sep 2011 12:20:38 +0200 Subject: NEWT: Adapt to GlueGen's Lock ChangeSet, all java callbacks for native have 'defer' 1st argument - Adapt to GlueGen's Lock ChangeSet: e4baba27507ce78e64a150ec6f69fb96f5721a34 - All java callbacks for native have 'defer' 1st argument. This allows enqueuing resulting events to the EDT if required, ie. the native thread may not be 'compatible' (MacOSX). - MacOSX-Native: enqueue key/mouse events and defer:=true for all java callbacks Since we are comming from a 3rd-party thread (AWT/NSApp-MainThread) we shall not abuse it. --- src/newt/classes/jogamp/newt/OffscreenWindow.java | 6 +- src/newt/classes/jogamp/newt/ScreenModeStatus.java | 5 +- src/newt/classes/jogamp/newt/WindowImpl.java | 90 +++++++++++++--------- .../jogamp/newt/driver/android/AndroidWindow.java | 6 +- .../classes/jogamp/newt/driver/awt/AWTWindow.java | 2 +- .../jogamp/newt/driver/broadcom/egl/Window.java | 2 +- .../jogamp/newt/driver/intel/gdl/Window.java | 2 +- .../classes/jogamp/newt/driver/kd/KDWindow.java | 8 +- .../jogamp/newt/driver/windows/WindowsWindow.java | 2 +- src/newt/native/KDWindow.c | 12 +-- src/newt/native/MacWindow.m | 76 ++++++++++++++---- src/newt/native/NewtMacWindow.h | 2 +- src/newt/native/NewtMacWindow.m | 48 ++++++------ src/newt/native/WindowsWindow.c | 32 ++++---- src/newt/native/X11Window.c | 32 ++++---- 15 files changed, 193 insertions(+), 132 deletions(-) (limited to 'src') diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 7afc54d71..fa7bafe5b 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -91,7 +91,7 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { @Override public void setSize(int width, int height) { if(!isVisible()) { - sizeChanged(width, height, false); + sizeChanged(false, width, height, false); } } @Override @@ -106,8 +106,8 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - sizeChanged(width, height, false); - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + sizeChanged(false, width, height, false); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } else { shouldNotCallThis(); } diff --git a/src/newt/classes/jogamp/newt/ScreenModeStatus.java b/src/newt/classes/jogamp/newt/ScreenModeStatus.java index dfd4e99a6..be87ce0dd 100644 --- a/src/newt/classes/jogamp/newt/ScreenModeStatus.java +++ b/src/newt/classes/jogamp/newt/ScreenModeStatus.java @@ -30,6 +30,7 @@ package jogamp.newt; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.IntIntHashMap; +import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.newt.Screen; import com.jogamp.newt.ScreenMode; @@ -41,7 +42,7 @@ import java.util.HashMap; public class ScreenModeStatus { private static boolean DEBUG = Screen.DEBUG; - private RecursiveLock lock = new RecursiveLock(); + private RecursiveLock lock = LockFactory.createRecursiveLock(); private ArrayHashSet screenModes; private IntIntHashMap screenModesIdx2NativeIdx; private ScreenMode currentScreenMode; @@ -49,7 +50,7 @@ public class ScreenModeStatus { private ArrayList listener = new ArrayList(); private static HashMap screenFQN2ScreenModeStatus = new HashMap(); - private static RecursiveLock screen2ScreenModeStatusLock = new RecursiveLock(); + private static RecursiveLock screen2ScreenModeStatusLock = LockFactory.createRecursiveLock(); protected static void mapScreenModeStatus(String screenFQN, ScreenModeStatus sms) { screen2ScreenModeStatusLock.lock(); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 77e69fef7..90b5a8226 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -42,6 +42,7 @@ import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Display; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; +import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.newt.ScreenMode; import com.jogamp.newt.event.KeyEvent; @@ -76,8 +77,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical - private RecursiveLock windowLock = new RecursiveLock(); // Window instance wide lock - private RecursiveLock surfaceLock = new RecursiveLock(); // Surface only lock + private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock + private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); // Surface only lock private ScreenImpl screen; // never null after create - may change reference though (reparent) private boolean screenReferenceAdded = false; @@ -395,10 +396,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * to notify this Java object of state changes.

* * @see #windowDestroyNotify() - * @see #focusChanged(boolean) - * @see #visibleChanged(boolean) + * @see #focusChanged(boolean, boolean) + * @see #visibleChanged(boolean, boolean) * @see #sizeChanged(int,int) - * @see #positionChanged(int,int) + * @see #positionChanged(boolean,int, int) * @see #windowDestroyNotify() */ protected abstract void createNativeImpl(); @@ -406,11 +407,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected abstract void closeNativeImpl(); /** - * The native implementation must invoke {@link #focusChanged(boolean)} + * The native implementation must invoke {@link #focusChanged(boolean, boolean)} * to change the focus state, if force == false. * This may happen asynchronous within {@link #TIMEOUT_NATIVEWINDOW}. * - * @param force if true, bypass {@link #focusChanged(boolean)} and force focus request + * @param force if true, bypass {@link #focusChanged(boolean, boolean)} and force focus request */ protected abstract void requestFocusImpl(boolean force); @@ -442,7 +443,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param flags bitfield of change and status flags * * @see #sizeChanged(int,int) - * @see #positionChanged(int,int) + * @see #positionChanged(boolean,int, int) */ protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags); @@ -508,10 +509,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Triggered by user via {@link #getInsets()}.
* Implementations may implement this hook to update the insets.
- * However, they may prefer the event driven path via {@link #insetsChanged(int, int, int, int)}. + * However, they may prefer the event driven path via {@link #insetsChanged(boolean, int, int, int, int)}. * * @see #getInsets() - * @see #insetsChanged(int, int, int, int) + * @see #insetsChanged(boolean, int, int, int, int) */ protected abstract void updateInsetsImpl(Insets insets); @@ -522,7 +523,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final int lockSurface() { windowLock.lock(); surfaceLock.lock(); - int res = surfaceLock.getRecursionCount() == 0 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; + int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? if ( LOCK_SURFACE_NOT_READY == res ) { try { @@ -551,7 +552,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer surfaceLock.validateLocked(); windowLock.validateLocked(); - if (surfaceLock.getRecursionCount() == 0) { + if (surfaceLock.getHoldCount() == 1) { final AbstractGraphicsDevice adevice = config.getScreen().getDevice(); try { unlockSurfaceImpl(); @@ -741,8 +742,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { - String msg = "Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow); - System.err.println(msg); + System.err.println("Window setVisible: START ("+getThreadName()+") "+x+"/"+y+" "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); Thread.dumpStack(); } runOnEDTIfAvail(true, new VisibleAction(visible)); @@ -1727,8 +1727,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer repaintQueued=true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window.consumeEvent: queued "+e); - // Exception ee = new Exception("Window.windowRepaint: "+e); - // ee.printStackTrace(); + // Thread.dumpStack(); } return false; } @@ -1742,9 +1741,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // queue event in case window is locked, ie in operation if( isWindowLocked() ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.consumeEvent: queued "+e); - // Exception ee = new Exception("Window.windowRepaint: "+e); - // ee.printStackTrace(); + // System.err.println("Window.consumeEvent: queued "+e); + // Thread.dumpStack(); // JAU } return false; } @@ -2137,23 +2135,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - /** Triggered by implementation's WM events to update the focus state. */ - protected void focusChanged(boolean focusGained) { + /** Triggered by implementation's WM events to update the focus state. */ + protected void focusChanged(boolean defer, boolean focusGained) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.focusChanged: ("+getThreadName()+"): "+this.hasFocus+" -> "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.focusChanged: ("+getThreadName()+"): (defer: "+defer+") "+this.hasFocus+" -> "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } hasFocus = focusGained; - if (focusGained) { - sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS); + final int evt = focusGained ? WindowEvent.EVENT_WINDOW_GAINED_FOCUS : WindowEvent.EVENT_WINDOW_LOST_FOCUS ; + if(!defer) { + sendWindowEvent(evt); } else { - sendWindowEvent(WindowEvent.EVENT_WINDOW_LOST_FOCUS); + enqueueWindowEvent(false, evt); } } - /** Triggered by implementation's WM events to update the visibility state. */ - protected void visibleChanged(boolean visible) { + /** Triggered by implementation's WM events to update the visibility state. */ + protected void visibleChanged(boolean defer, boolean visible) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.visibleChanged ("+getThreadName()+"): "+this.visible+" -> "+visible+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.visibleChanged ("+getThreadName()+"): (defer: "+defer+") "+this.visible+" -> "+visible+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } this.visible = visible ; } @@ -2180,10 +2179,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the client-area size w/o insets/decorations. */ - protected void sizeChanged(int newWidth, int newHeight, boolean force) { + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { if(force || width != newWidth || height != newHeight) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.sizeChanged: ("+getThreadName()+"): force "+force+", "+width+"x"+height+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.sizeChanged: ("+getThreadName()+"): (defer: "+defer+") force "+force+", "+width+"x"+height+" -> "+newWidth+"x"+newHeight+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } if(0>newWidth || 0>newHeight) { throw new NativeWindowException("Illegal width or height "+newWidth+"x"+newHeight+" (must be >= 0)"); @@ -2191,7 +2190,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer width = newWidth; height = newHeight; if(isNativeValid()) { - sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); + if(!defer) { + sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); + } else { + enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_RESIZED); + } } } } @@ -2221,14 +2224,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the position. */ - protected void positionChanged(int newX, int newY) { + protected void positionChanged(boolean defer, int newX, int newY) { if ( x != newX || y != newY ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.positionChanged: ("+getThreadName()+"): "+x+"/"+y+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+x+"/"+y+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } x = newX; y = newY; - sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED); + if(!defer) { + sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED); + } else { + enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_MOVED); + } } } @@ -2238,7 +2245,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #getInsets() * @see #updateInsetsImpl(Insets) */ - protected void insetsChanged(int left, int right, int top, int bottom) { + protected void insetsChanged(boolean defer, int left, int right, int top, int bottom) { if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 ) { if(isUndecorated()) { if(DEBUG_IMPLEMENTATION) { @@ -2252,7 +2259,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer insets.setTopHeight(top); insets.setBottomHeight(bottom); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.insetsChanged: "+insets); + System.err.println("Window.insetsChanged: (defer: "+defer+") "+insets); } } } @@ -2276,18 +2283,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void windowRepaint(int x, int y, int width, int height) { + windowRepaint(false, x, y, width, height); + } + + /** + * Triggered by implementation's WM events to update the content + */ + protected void windowRepaint(boolean defer, int x, int y, int width, int height) { x = ( 0 > x ) ? this.x : x; y = ( 0 > y ) ? this.y : y; width = ( 0 >= width ) ? this.width : width; height = ( 0 >= height ) ? this.height : height; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowRepaint "+getThreadName()+" - "+x+"/"+y+" "+width+"x"+height); + System.err.println("Window.windowRepaint "+getThreadName()+" (defer: "+defer+") "+x+"/"+y+" "+width+"x"+height); } if(isNativeValid()) { NEWTEvent e = new WindowUpdateEvent(WindowEvent.EVENT_WINDOW_REPAINT, this, System.currentTimeMillis(), new Rectangle(x, y, width, height)); - doEvent(false, false, e); + doEvent(defer, false, e); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index 83f306b46..5ce40a05e 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -172,7 +172,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { return false; } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; } @@ -219,7 +219,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "surfaceCreated - 0 - isValid: "+surface.isValid()+ ", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", "+nsv.getWidth()+"x"+nsv.getHeight()); - sizeChanged(width, height, false); + sizeChanged(false, width, height, false); windowRepaint(0, 0, nsv.getWidth(), nsv.getHeight()); } @@ -227,7 +227,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { int height) { Log.d(MD.TAG, "surfaceChanged: f "+Integer.toString(format)+", "+width+"x"+height); getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event - sizeChanged(width, height, false); + sizeChanged(false, width, height, false); } public void surfaceDestroyed(SurfaceHolder holder) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java index d71015d6c..9aaa82fec 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java @@ -209,7 +209,7 @@ public class AWTWindow extends WindowImpl { } } } - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java index 431ac934b..7df293c0d 100644 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java +++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java @@ -108,7 +108,7 @@ public class Window extends jogamp.newt.WindowImpl { } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java index 05833e93b..ab3e95e7e 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java @@ -109,7 +109,7 @@ public class Window extends jogamp.newt.WindowImpl { if(0 != ( FLAG_IS_VISIBLE & flags)) { ((Display)getScreen().getDisplay()).setFocus(this); } - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java index d94538545..10a75a017 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java +++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java @@ -88,7 +88,7 @@ public class KDWindow extends WindowImpl { protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } if(0!=eglWindowHandle) { @@ -112,7 +112,7 @@ public class KDWindow extends WindowImpl { } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; @@ -143,11 +143,11 @@ public class KDWindow extends WindowImpl { } @Override - protected void sizeChanged(int newWidth, int newHeight, boolean force) { + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { if(fullscreen) { ((KDScreen)getScreen()).setScreenSize(width, height); } - super.sizeChanged(newWidth, newHeight, force); + super.sizeChanged(defer, newWidth, newHeight, force); } private long eglWindowHandle; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index 9c80f0f85..ee057fb8f 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -174,7 +174,7 @@ public class WindowsWindow extends WindowImpl { reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; } diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 21ad312d0..5f1affed1 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -127,7 +127,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDDisplay_DispatchMessages KDint32 v[2]; if(!kdGetWindowPropertyiv(kdWindow, KD_WINDOWPROPERTY_SIZE, v)) { DBG_PRINT( "event window size change : src: %p %dx%d\n", userData, v[0], v[1]); - (*env)->CallVoidMethod(env, javaWindow, sizeChangedID, (jint) v[0], (jint) v[1], JNI_FALSE); + (*env)->CallVoidMethod(env, javaWindow, sizeChangedID, JNI_FALSE, (jint) v[0], (jint) v[1], JNI_FALSE); } else { DBG_PRINT( "event window size change error: src: %p %dx%d\n", userData, v[0], v[1]); } @@ -141,7 +141,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDDisplay_DispatchMessages KDboolean visible; kdGetWindowPropertybv(kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visible); DBG_PRINT( "event window visibility: src: %p, v:%d\n", userData, visible); - (*env)->CallVoidMethod(env, javaWindow, visibleChangedID, visible?JNI_TRUE:JNI_FALSE); + (*env)->CallVoidMethod(env, javaWindow, visibleChangedID, JNI_FALSE, visible?JNI_TRUE:JNI_FALSE); } break; default: @@ -187,8 +187,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_KDWindow_initIDs #endif #endif windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V"); - visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); @@ -287,7 +287,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDWindow_setVisible0 KDboolean v = (visible==JNI_TRUE)?KD_TRUE:KD_FALSE; kdSetWindowPropertybv(w, KD_WINDOWPROPERTY_VISIBILITY, &v); DBG_PRINT( "[setVisible] v=%d\n", visible); - (*env)->CallVoidMethod(env, obj, visibleChangedID, visible); // FIXME: or send via event ? + (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, visible); // FIXME: or defer=true ? } JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDWindow_setFullScreen0 @@ -317,6 +317,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_KDWindow_setSize0 DBG_PRINT( "[setSize] v=%dx%d, res=%d\n", width, height, res); (void)res; - (*env)->CallVoidMethod(env, obj, sizeChangedID, (jint) width, (jint) height, JNI_FALSE); + (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); } diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 946ac489c..a149c74af 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -249,7 +249,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "createWindow0 - %p (this), %p (parent), %d/%d %dx%d, opaque %d, fs %d, style %X, buffType %X, screenidx %d, view %p\n", + DBG_PRINT( "createWindow0 - %p (this), %p (parent), %d/%d %dx%d, opaque %d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, (int)x, (int)y, (int)w, (int)h, (int) opaque, (int)fullscreen, (int)styleMask, (int)bufferingType, (int)screen_idx, myView); @@ -302,18 +302,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 [myWindow setBackgroundColor: [NSColor clearColor]]; } - /** - if (fullscreen) { - [myWindow setOpaque: YES]; - } else { - // If the window is undecorated, assume we want the possibility of - // a shaped window, so make it non-opaque and the background color clear - if ((styleMask & NSTitledWindowMask) == 0) { - [myWindow setOpaque: NO]; - [myWindow setBackgroundColor: [NSColor clearColor]]; - } - } */ - // specify we want mouse-moved events [myWindow setAcceptsMouseMovedEvents:YES]; @@ -341,6 +329,9 @@ NS_ENDHANDLER // right mouse button down events [myView setNextResponder: myWindow]; + DBG_PRINT( "createWindow0 - %p (this), %p (parent): new window: %p (END)\n", + (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow); + [pool release]; return (jlong) ((intptr_t) myWindow); @@ -356,8 +347,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKeyAndOrderF { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (START)\n", win); + [win performSelectorOnMainThread:@selector(makeKeyAndOrderFront:) withObject:win waitUntilDone:NO]; // [win makeKeyAndOrderFront: win]; + + DBG_PRINT( "makeKeyAndOrderFront0 - window: %p (END)\n", win); + [pool release]; } @@ -371,8 +368,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_makeKey0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "makeKey0 - window: %p (START)\n", win); + [win performSelectorOnMainThread:@selector(makeKeyWindow:) withObject:nil waitUntilDone:NO]; // [win makeKeyWindow]; + + DBG_PRINT( "makeKey0 - window: %p (END)\n", win); + [pool release]; } @@ -386,8 +389,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "orderOut0 - window: %p (START)\n", win); + [win performSelectorOnMainThread:@selector(orderOut:) withObject:win waitUntilDone:NO]; // [win orderOut: win]; + + DBG_PRINT( "orderOut0 - window: %p (END)\n", win); + [pool release]; } @@ -431,10 +440,16 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "setTitle0 - window: %p (START)\n", win); + NSString* str = jstringToNSString(env, title); [str autorelease]; [win performSelectorOnMainThread:@selector(setTitle:) withObject:str waitUntilDone:NO]; // [win setTitle: str]; + + DBG_PRINT( "setTitle0 - window: %p (END)\n", win); + [pool release]; } @@ -448,7 +463,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_contentView0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "contentView0 - window: %p (START)\n", win); + jlong res = (jlong) ((intptr_t) [win contentView]); + + DBG_PRINT( "contentView0 - window: %p (END)\n", win); + [pool release]; return res; } @@ -463,6 +484,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentVi { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSWindow* win = (NewtMacWindow*) ((intptr_t) window); + NewtView* newView = (NewtView *) ((intptr_t) jview); + + DBG_PRINT( "changeContentView0 - window: %p (START)\n", win); + NSObject *nsParentObj = (NSObject*) ((intptr_t) parentWindowOrView); NSWindow* pWin = NULL; NSView* pView = NULL; @@ -476,11 +502,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentVi } } - NSWindow* win = (NewtMacWindow*) ((intptr_t) window); - NewtView* newView = (NewtView *) ((intptr_t) jview); - NewtView* oldView = changeContentView(env, jthis, pWin, pView, win, newView); + DBG_PRINT( "changeContentView0 - window: %p (END)\n", win); + [pool release]; return (jlong) ((intptr_t) oldView); @@ -496,8 +521,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setContentSize0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "setContentSize0 - window: %p (START)\n", win); + NSSize sz = NSMakeSize(w, h); [win setContentSize: sz]; + + DBG_PRINT( "setContentSize0 - window: %p (END)\n", win); + [pool release]; } @@ -512,7 +543,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftP NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* pwin = (NSWindow*) ((intptr_t) parent); NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "setFrameTopLeftPoint0 - window: %p (START)\n", win); + setFrameTopLeftPoint(pwin, win, x, y); + + DBG_PRINT( "setFrameTopLeftPoint0 - window: %p (END)\n", win); + [pool release]; } @@ -526,12 +563,17 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setAlwaysOnTop0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "setAlwaysOnTop0 - window: %p (START)\n", win); + if(atop) { [win setLevel:NSFloatingWindowLevel]; } else { [win setLevel:NSNormalWindowLevel]; } + + DBG_PRINT( "setAlwaysOnTop0 - window: %p (END)\n", win); + [pool release]; } - diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index a8931d6fc..5c465d4e9 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -36,7 +36,7 @@ #include "NewtCommon.h" -// #define VERBOSE_ON 1 +#define VERBOSE_ON 1 #ifdef VERBOSE_ON #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 6125761e3..eb1426dc2 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -72,8 +72,10 @@ jint GetDeltaY(NSEvent *event, jint javaMods) { return 0; } -static jmethodID sendMouseEventID = NULL; -static jmethodID sendKeyEventID = NULL; +static jmethodID enqueueMouseEventID = NULL; +static jmethodID enqueueKeyEventID = NULL; +static jmethodID enqueueRequestFocusID = NULL; + static jmethodID insetsChangedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID visibleChangedID = NULL; @@ -145,7 +147,7 @@ static jmethodID windowDestroyNotifyID = NULL; return; } - (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_FALSE); + (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_TRUE, JNI_FALSE); if (shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); @@ -163,7 +165,7 @@ static jmethodID windowDestroyNotifyID = NULL; return; } - (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_TRUE); + (*env)->CallVoidMethod(env, javaWindowObject, visibleChangedID, JNI_TRUE, JNI_TRUE); if (shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); @@ -178,16 +180,17 @@ static jmethodID windowDestroyNotifyID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V"); - visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)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"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); - if (sendMouseEventID && sendKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && - positionChangedID && focusChangedID && windowDestroyNotifyID) + enqueueRequestFocusID = (*env)->GetMethodID(env, clazz, "enqueueRequestFocus", "(Z)V"); + if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && + positionChangedID && focusChangedID && windowDestroyNotifyID && enqueueRequestFocusID) { return YES; } @@ -219,8 +222,7 @@ static jmethodID windowDestroyNotifyID = NULL; DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", (int)left, (int)right, (int)top, (int)bottom); - (*env)->CallVoidMethod(env, javaWindowObject, insetsChangedID, - left, right, top, bottom); + (*env)->CallVoidMethod(env, javaWindowObject, insetsChangedID, JNI_TRUE, left, right, top, bottom); } - (id) initWithContentRect: (NSRect) contentRect @@ -294,7 +296,7 @@ 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, JNI_FALSE, evType, javaMods, keyCode, keyChar); } @@ -378,7 +380,10 @@ static jint mods2JavaMods(NSUInteger mods) // ignore 0 increment wheel scroll events return; } - (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID, + if (evType == EVENT_MOUSE_PRESSED) { + (*env)->CallVoidMethod(env, javaWindowObject, enqueueRequestFocusID, JNI_FALSE); + } + (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, evType, javaMods, (jint) location.x, (jint) (contentRect.size.height - location.y), @@ -483,7 +488,7 @@ static jint mods2JavaMods(NSUInteger mods) NSRect frameRect = [self frame]; NSRect contentRect = [self contentRectForFrameRect: frameRect]; - (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, + (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_TRUE, (jint) contentRect.size.width, (jint) contentRect.size.height, JNI_FALSE); @@ -522,8 +527,7 @@ static jint mods2JavaMods(NSUInteger mods) screenRect = [screen frame]; pt = NSMakePoint(rect.origin.x, screenRect.origin.y + screenRect.size.height - rect.origin.y - rect.size.height); - (*env)->CallVoidMethod(env, javaWindowObject, positionChangedID, - (jint) pt.x, (jint) pt.y); + (*env)->CallVoidMethod(env, javaWindowObject, positionChangedID, JNI_TRUE, (jint) pt.x, (jint) pt.y); if (shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); @@ -593,7 +597,7 @@ static jint mods2JavaMods(NSUInteger mods) return; } - (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_TRUE); + (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_TRUE, JNI_TRUE); if (shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); @@ -620,7 +624,7 @@ static jint mods2JavaMods(NSUInteger mods) return; } - (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_FALSE); + (*env)->CallVoidMethod(env, javaWindowObject, focusChangedID, JNI_TRUE, JNI_FALSE); if (shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 8402373b3..307938ac1 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -666,7 +666,7 @@ static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd) (int)m_insets.left, (int)m_insets.top, (int)m_insets.right, (int)m_insets.bottom, (int)(m_insets.right-m_insets.left), (int)(m_insets.top-m_insets.bottom)); - (*env)->CallVoidMethod(env, window, insetsChangedID, + (*env)->CallVoidMethod(env, window, insetsChangedID, JNI_FALSE, m_insets.left, m_insets.right, m_insets.top, m_insets.bottom); return &m_insets; @@ -732,7 +732,7 @@ static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd) (void*)hwnd, (int)m_insets.left, (int)m_insets.right, (int)m_insets.top, (int)m_insets.bottom, (int) ( m_insets.left + m_insets.right ), (int) (m_insets.top + m_insets.bottom)); - (*env)->CallVoidMethod(env, window, insetsChangedID, + (*env)->CallVoidMethod(env, window, insetsChangedID, JNI_FALSE, (int)m_insets.left, (int)m_insets.right, (int)m_insets.top, (int)m_insets.bottom); return &m_insets; } @@ -761,7 +761,7 @@ static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) DBG_PRINT("*** WindowsWindow: WmSize window %p, %dx%d, visible %d\n", (void*)wnd, w, h, isVisible); - (*env)->CallVoidMethod(env, window, sizeChangedID, w, h, JNI_FALSE); + (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, w, h, JNI_FALSE); } static LRESULT CALLBACK wndProc(HWND wnd, UINT message, @@ -944,22 +944,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, } case WM_SETFOCUS: - (*env)->CallVoidMethod(env, window, focusChangedID, JNI_TRUE); + (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_TRUE); useDefWindowProc = 1; break; case WM_KILLFOCUS: - (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE); + (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_FALSE); useDefWindowProc = 1; break; case WM_SHOWWINDOW: - (*env)->CallVoidMethod(env, window, visibleChangedID, wParam==TRUE?JNI_TRUE:JNI_FALSE); + (*env)->CallVoidMethod(env, window, visibleChangedID, JNI_FALSE, wParam==TRUE?JNI_TRUE:JNI_FALSE); break; case WM_MOVE: DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d\n", wnd, (int)LOWORD(lParam), (int)HIWORD(lParam)); - (*env)->CallVoidMethod(env, window, positionChangedID, (jint)LOWORD(lParam), (jint)HIWORD(lParam)); + (*env)->CallVoidMethod(env, window, positionChangedID, JNI_FALSE, (jint)LOWORD(lParam), (jint)HIWORD(lParam)); useDefWindowProc = 1; break; @@ -971,7 +971,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, jint width = r.right-r.left; jint height = r.bottom-r.top; if (width > 0 && height > 0) { - (*env)->CallVoidMethod(env, window, windowRepaintID, r.left, r.top, width, height); + (*env)->CallVoidMethod(env, window, windowRepaintID, JNI_FALSE, r.left, r.top, width, height); } ValidateRect(wnd, &r); */ @@ -980,7 +980,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, } case WM_ERASEBKGND: // ignore erase background - (*env)->CallVoidMethod(env, window, windowRepaintID, 0, 0, -1, -1); + (*env)->CallVoidMethod(env, window, windowRepaintID, JNI_FALSE, 0, 0, -1, -1); useDefWindowProc = 0; res = 1; // OpenGL, etc .. erases the background, hence we claim to have just done this break; @@ -1240,13 +1240,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs { NewtCommon_init(env); - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V"); - focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V"); - visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); - windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V"); + windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); @@ -1396,7 +1396,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWind // 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); + (*env)->CallVoidMethod(env, wud->jinstance, visibleChangedID, JNI_FALSE, JNI_TRUE); if(!userPos) { GetWindowRect(window, &rc); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index e1a0071b5..f2af91970 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -504,13 +504,13 @@ static Status NewtWindows_updateInsets(JNIEnv *env, jobject jwindow, Display *dp if(0 != NewtWindows_getFrameExtends(dpy, window, left, right, top, bottom)) { DBG_PRINT( "NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l %d, r %d, t %d, b %d ]\n", *left, *right, *top, *bottom); - (*env)->CallVoidMethod(env, jwindow, insetsChangedID, *left, *right, *top, *bottom); + (*env)->CallVoidMethod(env, jwindow, insetsChangedID, JNI_FALSE, *left, *right, *top, *bottom); return 1; // OK } else if(0 != NewtWindows_getParentPosition (dpy, window, left, top)) { *right = *left; *bottom = *left; DBG_PRINT( "NewtWindows_updateInsets: insets by parent position [ l %d, r %d, t %d, b %d ]\n", *left, *right, *top, *bottom); - (*env)->CallVoidMethod(env, jwindow, insetsChangedID, *left, *right, *top, *bottom); + (*env)->CallVoidMethod(env, jwindow, insetsChangedID, JNI_FALSE, *left, *right, *top, *bottom); return 1; // OK } return 0; // Error @@ -886,9 +886,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 int left, right, top, bottom; NewtWindows_updateInsets(env, jwindow, dpy, evt.xany.window, &left, &right, &top, &bottom); } - (*env)->CallVoidMethod(env, jwindow, sizeChangedID, + (*env)->CallVoidMethod(env, jwindow, sizeChangedID, JNI_FALSE, (jint) evt.xconfigure.width, (jint) evt.xconfigure.height, JNI_FALSE); - (*env)->CallVoidMethod(env, jwindow, positionChangedID, + (*env)->CallVoidMethod(env, jwindow, positionChangedID, JNI_FALSE, (jint) evt.xconfigure.x, (jint) evt.xconfigure.y); } break; @@ -904,12 +904,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 case FocusIn: DBG_PRINT( "X11: event . FocusIn call %p\n", (void*)evt.xvisibility.window); - (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_TRUE); + (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE, JNI_TRUE); break; case FocusOut: DBG_PRINT( "X11: event . FocusOut call %p\n", (void*)evt.xvisibility.window); - (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE); + (*env)->CallVoidMethod(env, jwindow, focusChangedID, JNI_FALSE, JNI_FALSE); break; case Expose: @@ -917,7 +917,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 evt.xexpose.x, evt.xexpose.y, evt.xexpose.width, evt.xexpose.height, evt.xexpose.count); if (evt.xexpose.count == 0 && evt.xexpose.width > 0 && evt.xexpose.height > 0) { - (*env)->CallVoidMethod(env, jwindow, windowRepaintID, + (*env)->CallVoidMethod(env, jwindow, windowRepaintID, JNI_FALSE, evt.xexpose.x, evt.xexpose.y, evt.xexpose.width, evt.xexpose.height); } break; @@ -933,7 +933,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 int left, right, top, bottom; NewtWindows_updateInsets(env, jwindow, dpy, evt.xany.window, &left, &right, &top, &bottom); } - (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_TRUE); + (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE); } break; @@ -943,7 +943,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 evt.xunmap.event!=evt.xunmap.window); if( evt.xunmap.event == evt.xunmap.window ) { // ignore child window notification - (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE); + (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_FALSE); } break; @@ -1437,14 +1437,14 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_initIDs0 (JNIEnv *env, jclass clazz) { - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(IIII)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(IIZ)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V"); - focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(Z)V"); - visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(Z)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); reparentNotifyID = (*env)->GetMethodID(env, clazz, "reparentNotify", "(J)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "()V"); - windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(IIII)V"); + windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); @@ -1638,7 +1638,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 // 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); + (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE); if(!userPos) { // get position from WM -- cgit v1.2.3