aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-08-12 03:01:26 +0200
committerSven Gothel <[email protected]>2015-08-12 03:01:26 +0200
commit2c23b1cb343a008621e3fe642c5b8abacca48b1a (patch)
treedf62efc34cd8344888cbfa2bff8ad9210e4f48f2 /src/newt/native
parent8df37534138e15061e66e6460391dcdc413b521f (diff)
Bug 1188: Refine Maximized on X11 / Impl. Maximized and Iconify on Windows
WindowImpl - remove updateMinMaxSize(..) - unused info - fix appendStateToString: show all maximized state changes if reconfig - add sizePosMaxInsetsChanged(..) and sendMouseEventRequestFocus(..) accumulating multiple callbacks from impl. - add: maximizedChanged(..) notification from native impl. - refine manual maximized mode used for OSX and Windows (single extent) - reconfigMaximizedManual(..) - resetMaximizedManual(..) X11 WindowDriver: - Update maximized at xreconfig, read from _NET_WM_STATE - Use less Java callbacks from JNI Windows WindowDriver: - Use native maximized, if HORZ && VERT, otherwise use manual maximized for single extent. - Invisible of top-window -> MINIMIZED/ICONIFY showing the app in task-bar.
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/WindowsWindow.c122
-rw-r--r--src/newt/native/X11Common.h8
-rw-r--r--src/newt/native/X11Display.c41
-rw-r--r--src/newt/native/X11Window.c112
4 files changed, 181 insertions, 102 deletions
diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c
index ad4111ec7..a1ba4d3b8 100644
--- a/src/newt/native/WindowsWindow.c
+++ b/src/newt/native/WindowsWindow.c
@@ -177,6 +177,7 @@
static jmethodID insetsChangedID = NULL;
static jmethodID sizeChangedID = NULL;
+static jmethodID maximizedChangedID = NULL;
static jmethodID positionChangedID = NULL;
static jmethodID focusChangedID = NULL;
static jmethodID visibleChangedID = NULL;
@@ -218,9 +219,13 @@ typedef struct {
HCURSOR setPointerHandle;
HCURSOR defPointerHandle;
/** Bool: 0 NOP, 1 FULLSCREEN */
- int isFullscreen;
+ BOOL isFullscreen;
/** Bool: 0 TOP, 1 CHILD */
- int isChildWindow;
+ BOOL isChildWindow;
+ /** Bool: 0 NOP, 1 minimized/iconic */
+ BOOL isMinimized;
+ /** Bool: 0 NOP, 1 maximized */
+ BOOL isMaximized;
int pointerCaptured;
int pointerInside;
int touchDownCount;
@@ -787,11 +792,27 @@ static void WmSize(JNIEnv *env, WindowUserData * wud, HWND wnd, UINT type)
RECT rc;
BOOL isVisible = IsWindowVisible(wnd);
jobject window = wud->jinstance;
+ BOOL maxChanged = FALSE;
+
+ DBG_PRINT("*** WindowsWindow: WmSize.0 window %p, %dx%d, isMinimized %d, isMaximized %d, visible %d\n",
+ (void*)wnd, wud->width, wud->height, wud->isMinimized, wud->isMaximized, isVisible);
if (type == SIZE_MINIMIZED) {
- // TODO: deal with minimized window sizing
+ wud->isMinimized = TRUE;
return;
}
+ if (type == SIZE_MAXIMIZED) {
+ if( !wud->isMaximized ) {
+ wud->isMaximized = 1;
+ maxChanged = TRUE;
+ }
+ } else if (type == SIZE_RESTORED) {
+ wud->isMinimized = FALSE;
+ if( wud->isMaximized ) {
+ wud->isMaximized = FALSE;
+ maxChanged = TRUE;
+ }
+ }
// make sure insets are up to date
(void)UpdateInsets(env, window, wnd);
@@ -802,8 +823,13 @@ static void WmSize(JNIEnv *env, WindowUserData * wud, HWND wnd, UINT type)
wud->width = (int) ( rc.right - rc.left );
wud->height = (int) ( rc.bottom - rc.top );
- DBG_PRINT("*** WindowsWindow: WmSize window %p, %dx%d, visible %d\n", (void*)wnd, wud->width, wud->height, isVisible);
+ DBG_PRINT("*** WindowsWindow: WmSize.X window %p, %dx%d, isMinimized %d, isMaximized %d (changed %d), visible %d\n",
+ (void*)wnd, wud->width, wud->height, wud->isMinimized, wud->isMaximized, maxChanged, isVisible);
+ if( maxChanged ) {
+ jboolean v = wud->isMaximized ? JNI_TRUE : JNI_FALSE;
+ (*env)->CallVoidMethod(env, window, maximizedChangedID, v, v);
+ }
(*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, wud->width, wud->height, JNI_FALSE);
}
@@ -1020,6 +1046,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP
break;
case WM_SHOWWINDOW:
+ DBG_PRINT("*** WindowsWindow: WM_SHOWWINDOW window %p: %d\n", wnd, wParam==TRUE);
(*env)->CallVoidMethod(env, window, visibleChangedID, JNI_FALSE, wParam==TRUE?JNI_TRUE:JNI_FALSE);
break;
@@ -2032,6 +2059,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0
insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V");
sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V");
+ maximizedChangedID = (*env)->GetMethodID(env, clazz, "maximizedChanged", "(ZZ)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");
@@ -2044,6 +2072,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0
if (insetsChangedID == NULL ||
sizeChangedID == NULL ||
+ maximizedChangedID == NULL ||
positionChangedID == NULL ||
focusChangedID == NULL ||
visibleChangedID == NULL ||
@@ -2088,32 +2117,51 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_getNewtWndP
return (jlong) (intptr_t) wndProc;
}
-static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible,
+static void NewtWindow_setVisiblePosSize(WindowUserData *wud, HWND hwnd, int jflags, BOOL visible,
int x, int y, int width, int height)
{
- UINT flags;
- BOOL bRes;
-
- DBG_PRINT("*** WindowsWindow: NewtWindow_setVisiblePosSize %d/%d %dx%d, atop %d, visible %d\n",
- x, y, width, height, atop, visible);
+ BOOL atop = TST_FLAG_IS_ALWAYSONTOP(jflags);
+ BOOL abottom = TST_FLAG_IS_ALWAYSONBOTTOM(jflags);
+ UINT wflags;
+
+ DBG_PRINT("*** WindowsWindow: NewtWindow_setVisiblePosSize %d/%d %dx%d, atop %d, abottom %d, max[change[%d %d], is[%d %d]], visible %d\n",
+ x, y, width, height, atop, abottom,
+ TST_FLAG_CHANGE_MAXIMIZED_VERT(jflags), TST_FLAG_CHANGE_MAXIMIZED_HORZ(jflags),
+ TST_FLAG_IS_MAXIMIZED_VERT(jflags), TST_FLAG_IS_MAXIMIZED_HORZ(jflags),
+ visible);
if(visible) {
- flags = SWP_SHOWWINDOW;
+ wflags = SWP_SHOWWINDOW;
} else {
- flags = SWP_NOACTIVATE | SWP_NOZORDER;
+ wflags = SWP_NOACTIVATE | SWP_NOZORDER;
}
if(0>=width || 0>=height ) {
- flags |= SWP_NOSIZE;
+ wflags |= SWP_NOSIZE;
}
if(atop) {
- SetWindowPos(hwnd, HWND_TOP, x, y, width, height, flags);
- SetWindowPos(hwnd, HWND_TOPMOST, x, y, width, height, flags);
+ SetWindowPos(hwnd, HWND_TOP, x, y, width, height, wflags);
+ SetWindowPos(hwnd, HWND_TOPMOST, x, y, width, height, wflags);
+ } else if(abottom) {
+ SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, width, height, wflags);
+ SetWindowPos(hwnd, HWND_BOTTOM, x, y, width, height, wflags);
} else {
- SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, width, height, flags);
- SetWindowPos(hwnd, HWND_TOP, x, y, width, height, flags);
+ SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, width, height, wflags);
+ SetWindowPos(hwnd, HWND_TOP, x, y, width, height, wflags);
+ }
+ // SetWindowPos(hwnd, atop ? HWND_TOPMOST : HWND_TOP, x, y, width, height, wflags);
+
+ if( TST_FLAG_CHANGE_MAXIMIZED_ANY(jflags) ) {
+ if( TST_FLAG_IS_MAXIMIZED_VERT(jflags) && TST_FLAG_IS_MAXIMIZED_HORZ(jflags) ) {
+ wud->isMaximized = 1;
+ ShowWindow(hwnd, SW_MAXIMIZE);
+ } else if( !TST_FLAG_IS_MAXIMIZED_VERT(jflags) && !TST_FLAG_IS_MAXIMIZED_HORZ(jflags) ) {
+ if( wud->isMaximized ) {
+ ShowWindow(hwnd, SW_RESTORE);
+ wud->isMaximized = 0;
+ }
+ }
}
- // SetWindowPos(hwnd, atop ? HWND_TOPMOST : HWND_TOP, x, y, width, height, flags);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
@@ -2128,7 +2176,7 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible,
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0
(JNIEnv *env, jobject obj,
jlong hInstance, jstring jWndClassName, jstring jWndName, jint winMajor, jint winMinor,
- jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags)
+ jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jint flags)
{
HWND parentWindow = (HWND) (intptr_t) parent;
const TCHAR* wndClassName = NULL;
@@ -2157,7 +2205,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo
windowStyle |= WS_POPUP | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
} else {
windowStyle |= WS_OVERLAPPEDWINDOW;
- if(JNI_TRUE == autoPosition) {
+ if( TST_FLAG_IS_AUTOPOSITION(flags) ) {
// user didn't requested specific position, use WM default
_x = CW_USEDEFAULT;
_y = 0;
@@ -2172,7 +2220,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo
DBG_PRINT("*** WindowsWindow: CreateWindow thread 0x%X, win %d.%d parent %p, window %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n",
(int)GetCurrentThreadId(), winMajor, winMinor, parentWindow, window, x, y, width, height,
- TST_FLAG_IS_UNDECORATED(flags), TST_FLAG_IS_ALWAYSONTOP(flags), autoPosition);
+ TST_FLAG_IS_UNDECORATED(flags), TST_FLAG_IS_ALWAYSONTOP(flags), TST_FLAG_IS_AUTOPOSITION(flags));
if (NULL == window) {
int lastError = (int) GetLastError();
@@ -2188,8 +2236,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo
wud->setPointerAction = 0;
wud->defPointerHandle = LoadCursor( NULL, IDC_ARROW);
wud->setPointerHandle = wud->defPointerHandle;
- wud->isFullscreen = 0;
+ wud->isFullscreen = FALSE;
wud->isChildWindow = NULL!=parentWindow;
+ wud->isMinimized = FALSE;
+ wud->isMaximized = FALSE;
wud->pointerCaptured = 0;
wud->pointerInside = 0;
wud->touchDownCount = 0;
@@ -2224,12 +2274,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo
insets = UpdateInsets(env, wud->jinstance, window);
(*env)->CallVoidMethod(env, wud->jinstance, visibleChangedID, JNI_FALSE, JNI_TRUE);
- if(JNI_TRUE == autoPosition) {
+ if( TST_FLAG_IS_AUTOPOSITION(flags) ) {
GetWindowRect(window, &rc);
x = rc.left + insets->left; // client coords
y = rc.top + insets->top; // client coords
}
- DBG_PRINT("*** WindowsWindow: CreateWindow client: %d/%d %dx%d (autoPosition %d)\n", x, y, width, height, autoPosition);
+ DBG_PRINT("*** WindowsWindow: CreateWindow client: %d/%d %dx%d (autoPosition %d)\n", x, y, width, height, TST_FLAG_IS_AUTOPOSITION(flags));
x -= insets->left; // top-level
y -= insets->top; // top-level
@@ -2237,7 +2287,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo
height += insets->top + insets->bottom; // top-level
DBG_PRINT("*** WindowsWindow: CreateWindow top-level %d/%d %dx%d\n", x, y, width, height);
- NewtWindow_setVisiblePosSize(window, TST_FLAG_IS_ALWAYSONTOP(flags), TRUE, x, y, width, height);
+ NewtWindow_setVisiblePosSize(wud, window, flags, TRUE, x, y, width, height);
}
if( wud->supportsMTouch ) {
WinTouch_RegisterTouchWindow(window, 0);
@@ -2288,7 +2338,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW
HWND hwndP = (HWND) (intptr_t) parent;
HWND hwnd = (HWND) (intptr_t) window;
DWORD windowStyle = WS_DEFAULT_STYLES;
- BOOL styleChange = TST_FLAG_CHANGE_DECORATION(flags) || TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ;
+ BOOL styleChange = TST_FLAG_CHANGE_DECORATION(flags) || TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags);
WindowUserData * wud;
#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 )
wud = (WindowUserData *) GetWindowLong(hwnd, GWL_USERDATA);
@@ -2297,13 +2347,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW
#endif
- DBG_PRINT( "*** WindowsWindow: reconfigureWindow0 parent %p, window %p, %d/%d %dx%d, parentChange %d, isChild %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d -> styleChange %d, isChild %d, isFullscreen %d\n",
+ DBG_PRINT( "*** WindowsWindow: reconfigureWindow0 parent %p, window %p, %d/%d %dx%d, parentChange %d, isChild %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d -> styleChange %d, isChild %d, isMinimized %d, isMaximized %d, isFullscreen %d\n",
parent, window, x, y, width, height,
TST_FLAG_CHANGE_PARENTING(flags), TST_FLAG_IS_CHILD(flags),
TST_FLAG_CHANGE_DECORATION(flags), TST_FLAG_IS_UNDECORATED(flags),
TST_FLAG_CHANGE_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN(flags),
TST_FLAG_CHANGE_ALWAYSONTOP(flags), TST_FLAG_IS_ALWAYSONTOP(flags),
- TST_FLAG_CHANGE_VISIBILITY(flags), TST_FLAG_IS_VISIBLE(flags), styleChange, wud->isChildWindow, wud->isFullscreen);
+ TST_FLAG_CHANGE_VISIBILITY(flags), TST_FLAG_IS_VISIBLE(flags), styleChange,
+ wud->isChildWindow, wud->isMinimized, wud->isMaximized, wud->isFullscreen);
if (!IsWindow(hwnd)) {
DBG_PRINT("*** WindowsWindow: reconfigureWindow0 failure: Passed window %p is invalid\n", (void*)hwnd);
@@ -2336,7 +2387,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW
if( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) { // FS on
// TOP: in -> out
- wud->isFullscreen = 1;
+ wud->isFullscreen = TRUE;
NewtWindows_setFullScreen(JNI_TRUE);
}
@@ -2354,7 +2405,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW
if( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off
// CHILD: out -> in
- wud->isFullscreen = 0;
+ wud->isFullscreen = FALSE;
NewtWindows_setFullScreen(JNI_FALSE);
}
@@ -2363,17 +2414,22 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW
SetParent(hwnd, hwndP );
}
- NewtWindow_setVisiblePosSize(hwnd, TST_FLAG_IS_ALWAYSONTOP(flags), TST_FLAG_IS_VISIBLE(flags), x, y, width, height);
+ NewtWindow_setVisiblePosSize(wud, hwnd, flags, TST_FLAG_IS_VISIBLE(flags), x, y, width, height);
if( TST_FLAG_CHANGE_VISIBILITY(flags) ) {
if( TST_FLAG_IS_VISIBLE(flags) ) {
- ShowWindow(hwnd, SW_SHOW);
+ int cmd = wud->isMinimized ? SW_RESTORE : SW_SHOW;
+ wud->isMinimized = FALSE;
+ ShowWindow(hwnd, cmd);
+ } else if( !TST_FLAG_CHANGE_VISIBILITY_FAST(flags) && !TST_FLAG_IS_CHILD(flags) ) {
+ wud->isMinimized = TRUE;
+ ShowWindow(hwnd, SW_MINIMIZE);
} else {
ShowWindow(hwnd, SW_HIDE);
}
}
- DBG_PRINT("*** WindowsWindow: reconfigureWindow0.X isChild %d, isFullscreen %d\n", wud->isChildWindow, wud->isFullscreen);
+ DBG_PRINT("*** WindowsWindow: reconfigureWindow0.X isChild %d, isMinimized %d, isFullscreen %d\n", wud->isChildWindow, wud->isMinimized, wud->isFullscreen);
}
/*
diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h
index 309e62683..cdfb65d50 100644
--- a/src/newt/native/X11Common.h
+++ b/src/newt/native/X11Common.h
@@ -71,7 +71,7 @@
extern jclass X11NewtWindowClazz;
extern jmethodID insetsChangedID;
extern jmethodID visibleChangedID;
-extern jmethodID minMaxSizeChangedID;
+extern jmethodID sizePosMaxInsetsChanged;
typedef struct {
Window window;
@@ -81,13 +81,15 @@ typedef struct {
Atom windowDeleteAtom;
uint32_t supportedAtoms;
uint32_t lastDesktop;
+ Bool maxHorz;
+ Bool maxVert;
} JavaWindow;
JavaWindow * getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, jlong javaObjectAtom, Bool showWarning);
Status NewtWindows_getRootAndParent (Display *dpy, Window w, Window * root_return, Window * parent_return);
-Status NewtWindows_updateInsets(JNIEnv *env, Display *dpy, JavaWindow * w, int *left, int *right, int *top, int *bottom);
-void NewtWindows_updateMinMaxSize(JNIEnv *env, Display *dpy, JavaWindow * w);
+Bool NewtWindows_updateInsets(Display *dpy, JavaWindow * w, int *left, int *right, int *top, int *bottom);
+Bool NewtWindows_updateMaximized(Display *dpy, JavaWindow * w);
#endif /* _X11COMMON_H_ */
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 0ba454a00..68aa43887 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -35,7 +35,7 @@
jclass X11NewtWindowClazz = NULL;
jmethodID insetsChangedID = NULL;
jmethodID visibleChangedID = NULL;
-jmethodID minMaxSizeChangedID = NULL;
+jmethodID sizePosMaxInsetsChangedID = NULL;
static const char * const ClazzNameX11NewtWindow = "jogamp/newt/driver/x11/WindowDriver";
@@ -52,7 +52,7 @@ static jmethodID windowDestroyNotifyID = NULL;
static jmethodID windowRepaintID = NULL;
static jmethodID sendMouseEventID = NULL;
static jmethodID sendKeyEventID = NULL;
-static jmethodID requestFocusID = NULL;
+static jmethodID sendMouseEventRequestFocusID = NULL;
/**
* Keycode
@@ -254,13 +254,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0
positionChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "positionChanged", "(ZII)V");
focusChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "focusChanged", "(ZZ)V");
visibleChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "visibleChanged", "(ZZ)V");
- minMaxSizeChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "minMaxSizeChanged", "(IIII)V");
+ sizePosMaxInsetsChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sizePosMaxInsetsChanged", "(ZIIIIZZIIIIZ)V");
reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V");
windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z");
windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V");
sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V");
+ sendMouseEventRequestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEventRequestFocus", "(SIIISF)V");
sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSCLjava/lang/String;)V");
- requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V");
if (displayCompletedID == NULL ||
sendRRScreenChangeNotifyID == NULL ||
@@ -271,13 +271,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0
positionChangedID == NULL ||
focusChangedID == NULL ||
visibleChangedID == NULL ||
- minMaxSizeChangedID == NULL ||
+ sizePosMaxInsetsChangedID == NULL ||
reparentNotifyID == NULL ||
windowDestroyNotifyID == NULL ||
windowRepaintID == NULL ||
sendMouseEventID == NULL ||
- sendKeyEventID == NULL ||
- requestFocusID == NULL) {
+ sendMouseEventRequestFocusID == NULL ||
+ sendKeyEventID == NULL) {
return JNI_FALSE;
}
@@ -522,8 +522,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
switch(evt.type) {
case ButtonPress:
- (*env)->CallVoidMethod(env, jw->jwindow, requestFocusID, JNI_FALSE);
- (*env)->CallVoidMethod(env, jw->jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED,
+ (*env)->CallVoidMethod(env, jw->jwindow, sendMouseEventRequestFocusID, (jshort) EVENT_MOUSE_PRESSED,
modifiers,
(jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/);
break;
@@ -579,16 +578,16 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
evt.xconfigure.override_redirect, evt.xconfigure.window != evt.xconfigure.event);
if ( evt.xconfigure.window == evt.xconfigure.event ) {
// ignore child window change notification
- {
- // update insets
- int left, right, top, bottom;
- NewtWindows_updateInsets(env, dpy, jw, &left, &right, &top, &bottom);
- }
- NewtWindows_updateMinMaxSize(env, dpy, jw);
- (*env)->CallVoidMethod(env, jw->jwindow, sizeChangedID, JNI_FALSE,
- (jint) evt.xconfigure.width, (jint) evt.xconfigure.height, JNI_FALSE);
- (*env)->CallVoidMethod(env, jw->jwindow, positionChangedID, JNI_FALSE,
- (jint) evt.xconfigure.x, (jint) evt.xconfigure.y);
+ // update insets
+ int left=-1, right=-1, top=-1, bottom=-1;
+ NewtWindows_updateInsets(dpy, jw, &left, &right, &top, &bottom);
+ NewtWindows_updateMaximized(dpy, jw);
+ (*env)->CallVoidMethod(env, jw->jwindow, sizePosMaxInsetsChangedID, JNI_FALSE,
+ (jint) evt.xconfigure.x, (jint) evt.xconfigure.y,
+ (jint) evt.xconfigure.width, (jint) evt.xconfigure.height,
+ (jboolean)jw->maxHorz, (jboolean)jw->maxVert,
+ (jint)left, (jint)right, (jint)top, (jint)bottom,
+ JNI_FALSE);
}
break;
case ClientMessage:
@@ -633,7 +632,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
{
// update insets
int left, right, top, bottom;
- NewtWindows_updateInsets(env, dpy, jw, &left, &right, &top, &bottom);
+ if( NewtWindows_updateInsets(dpy, jw, &left, &right, &top, &bottom) ) {
+ (*env)->CallVoidMethod(env, jw->jwindow, insetsChangedID, JNI_FALSE, left, right, top, bottom);
+ }
}
(*env)->CallVoidMethod(env, jw->jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE);
}
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 778b71cc5..6fa3cc195 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -178,21 +178,21 @@ static uint32_t NewtWindows_getSupportedFeatureEWMH(Display *dpy, const Atom * a
return 0;
}
static uint32_t NewtWindows_getSupportedFeaturesEWMH(Display *dpy, Window root, Atom * allAtoms, Bool verbose) {
- Atom * actions = NULL;
+ Atom * properties = NULL;
Atom type = 0;
- unsigned long action_len = 0, remain = 0;
+ unsigned long props_count = 0, remain = 0;
int form = 0, i = 0;
uint32_t res = 0;
Status s;
XSync(dpy, False);
if ( Success == (s = XGetWindowProperty(dpy, root, allAtoms[_NET_SUPPORTED_IDX], 0, 1024, False, AnyPropertyType,
- &type, &form, &action_len, &remain, (unsigned char**)&actions)) ) {
- if( NULL != actions ) {
- for(i=0; i<action_len; i++) {
- res |= NewtWindows_getSupportedFeatureEWMH(dpy, allAtoms, actions[i], i, verbose);
+ &type, &form, &props_count, &remain, (unsigned char**)&properties)) ) {
+ if( NULL != properties ) {
+ for(i=0; i<props_count; i++) {
+ res |= NewtWindows_getSupportedFeatureEWMH(dpy, allAtoms, properties[i], i, verbose);
}
- XFree(actions);
+ XFree(properties);
}
if(verbose) {
fprintf(stderr, "**************** X11: Feature EWMH CHECK: 0x%X\n", res);
@@ -202,6 +202,31 @@ static uint32_t NewtWindows_getSupportedFeaturesEWMH(Display *dpy, Window root,
}
return res;
}
+static uint32_t NewtWindows_getNET_WM_STATE(Display *dpy, Window window, Atom * allAtoms, Bool verbose) {
+ Atom * properties = NULL;
+ Atom type = 0;
+ unsigned long props_count = 0, remain = 0;
+ int form = 0, i = 0;
+ uint32_t res = 0;
+ Status s;
+
+ XSync(dpy, False);
+ if ( Success == (s = XGetWindowProperty(dpy, window, allAtoms[_NET_WM_STATE_IDX], 0, 1024, False, AnyPropertyType,
+ &type, &form, &props_count, &remain, (unsigned char**)&properties)) ) {
+ if( NULL != properties ) {
+ for(i=0; i<props_count; i++) {
+ res |= NewtWindows_getSupportedFeatureEWMH(dpy, allAtoms, properties[i], i, verbose);
+ }
+ XFree(properties);
+ }
+ if(verbose) {
+ fprintf(stderr, "**************** X11: WM_STATE of %p: 0x%X\n", (void*)window, res);
+ }
+ } else if(verbose) {
+ fprintf(stderr, "**************** X11: WM_STATE of %p: XGetWindowProperty failed: %d\n", (void*)window, s);
+ }
+ return res;
+}
static JavaWindow* createJavaWindowProperty(JNIEnv *env, Display *dpy, Window root, Window window,
jlong javaObjectAtom, jlong windowDeleteAtom, jobject obj, Bool verbose) {
@@ -222,6 +247,8 @@ static JavaWindow* createJavaWindowProperty(JNIEnv *env, Display *dpy, Window ro
res->windowDeleteAtom = (Atom)windowDeleteAtom;
res->supportedAtoms = NewtWindows_getSupportedFeaturesEWMH(dpy, root, allAtoms, verbose);
res->lastDesktop = 0; //undef
+ res->maxHorz = False;
+ res->maxVert = False;
}
unsigned long jogl_java_object_data[2]; // X11 is based on 'unsigned long'
int nitems_32 = putPtrIn32Long( jogl_java_object_data, (uintptr_t) res);
@@ -465,12 +492,10 @@ static void NewtWindows_requestFocus (Display *dpy, JavaWindow * jw, Bool force)
XSync(dpy, False);
}
-Status NewtWindows_updateInsets(JNIEnv *env, Display *dpy, JavaWindow * w, int *left, int *right, int *top, int *bottom) {
+Bool NewtWindows_updateInsets(Display *dpy, JavaWindow * w, int *left, int *right, int *top, int *bottom) {
if(0 != NewtWindows_getFrameExtends(dpy, w, 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, w->jwindow, insetsChangedID, JNI_FALSE, *left, *right, *top, *bottom);
- return 1; // OK
+ DBG_PRINT( "NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l %d, r %d, t %d, b %d ]\n", *left, *right, *top, *bottom);
+ return True; // OK
}
Bool hasDecor = NewtWindows_hasDecorations (dpy, w);
@@ -480,43 +505,30 @@ Status NewtWindows_updateInsets(JNIEnv *env, Display *dpy, JavaWindow * w, int *
Window parent = NewtWindows_getParent(dpy, w->window);
if(0 != NewtWindows_getWindowPositionRelative2Parent (dpy, parent, left, top)) {
*right = *left; *bottom = *top;
- DBG_PRINT( "NewtWindows_updateInsets: insets by parent position [ l %d, r %d, t %d, b %d ]\n",
- *left, *right, *top, *bottom);
- (*env)->CallVoidMethod(env, w->jwindow, insetsChangedID, JNI_FALSE, *left, *right, *top, *bottom);
- return 1; // OK
+ DBG_PRINT( "NewtWindows_updateInsets: insets by parent position [ l %d, r %d, t %d, b %d ]\n", *left, *right, *top, *bottom);
+ return True; // OK
}
}
DBG_PRINT( "NewtWindows_updateInsets: cannot determine insets - hasDecor %d\n", hasDecor);
- return 0; // Error
+ return False; // Error
}
-void NewtWindows_updateMinMaxSize(JNIEnv *env, Display *dpy, JavaWindow * w) {
- XSizeHints * xsh = XAllocSizeHints();
- long xsh_bits = 0;
- int min_width=-1, min_height=-1;
- int max_width=-1, max_height=-1;
- if( NULL != xsh ) {
- xsh->flags = 0;
- xsh->min_width=0;
- xsh->min_height=0;
- xsh->max_width=0;
- xsh->max_height=0;
- if( 0 != XGetWMNormalHints(dpy, w->window, xsh, &xsh_bits) ) {
- // OK
- if( 0 != ( xsh_bits & PMinSize ) ) {
- min_width = xsh->min_width;
- min_height = xsh->min_height;
- }
- if( 0 != ( xsh_bits & PMaxSize ) ) {
- max_width = xsh->max_width;
- max_height = xsh->max_height;
- }
- DBG_PRINT( "NewtWindows_updateMinMaxSize: XGetWMNormalHints 0x%X / 0x%X for window %p on display %p\n", xsh_bits, xsh->flags, (void*)w->window, dpy);
- (*env)->CallVoidMethod(env, w->jwindow, minMaxSizeChangedID, min_width, min_height, max_width, max_height);
- } else {
- DBG_PRINT( "NewtWindows_updateMinMaxSize: XGetWMNormalHints failed (0x%X / 0x%X) for window %p on display %p\n", xsh_bits, xsh->flags, (void*)w->window, dpy);
- }
- XFree(xsh);
+Bool NewtWindows_updateMaximized(Display *dpy, JavaWindow * w) {
+ uint32_t state = NewtWindows_getNET_WM_STATE(dpy, w->window, w->allAtoms,
+#ifdef VERBOSE_ON
+ True
+#else
+ False
+#endif
+ );
+ Bool maxHorz = 0 != ( _MASK_NET_WM_STATE_MAXIMIZED_HORZ & state ) ;
+ Bool maxVert = 0 != ( _MASK_NET_WM_STATE_MAXIMIZED_VERT & state ) ;
+ if( w->maxHorz != maxHorz || w->maxVert != maxVert ) {
+ w->maxHorz = maxHorz;
+ w->maxVert = maxVert;
+ return True;
+ } else {
+ return False;
}
}
@@ -671,9 +683,15 @@ static void NewtWindows_setStackingEWMHFlags (Display *dpy, Window root, JavaWin
XChangeProperty( dpy, w->window, w->allAtoms[_NET_WM_BYPASS_COMPOSITOR_IDX], XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&value, 1);
}
} else if( changeMaxVert || changeMaxHorz ) {
+ if( changeMaxHorz ) {
+ w->maxHorz = enable;
+ }
+ if( changeMaxVert ) {
+ w->maxVert = enable;
+ }
NewtWindows_sendNET_WM_STATE(dpy, root, w,
- changeMaxVert ? _NET_WM_STATE_MAXIMIZED_VERT_IDX : 0,
changeMaxHorz ? _NET_WM_STATE_MAXIMIZED_HORZ_IDX : 0,
+ changeMaxVert ? _NET_WM_STATE_MAXIMIZED_VERT_IDX : 0,
enable);
}
XSync(dpy, False);
@@ -916,7 +934,9 @@ JNIEXPORT jlongArray JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWind
}
// send insets before visibility, allowing java code a proper sync point!
- NewtWindows_updateInsets(env, dpy, javaWindow, &left, &right, &top, &bottom);
+ if( NewtWindows_updateInsets(dpy, javaWindow, &left, &right, &top, &bottom) ) {
+ (*env)->CallVoidMethod(env, javaWindow->jwindow, insetsChangedID, JNI_FALSE, left, right, top, bottom);
+ }
(*env)->CallVoidMethod(env, javaWindow->jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE);
if( TST_FLAG_IS_AUTOPOSITION(flags) ) {