aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-09-29 00:08:23 +0200
committerSven Gothel <[email protected]>2023-09-29 00:08:23 +0200
commita0e6d5883de009d4649d011633090d7660fa229a (patch)
tree36d090007ea5c44aba06ea7ebafc7a1dad277941 /src/newt/native
parentc5fde40428937c08486226e9d4488a0ca1a00377 (diff)
Bug 1431: Fix NewtCanvasAWT resize on X11, broken since commit ad38d1559854985b1131e5b6c7274a392b5bc265
Commit ad38d1559854985b1131e5b6c7274a392b5bc265 introduced XTranslateCoordinates(..) to savely validate the client-space window position against the parent (root). Totally missing in this change was the NEWT child window case since it always used the root-window as the destination. This change tracks the parent-window (valid parent Window or NULL) within the JavaWindow struct and either uses the parent-window if available or the root-window for XTranslateCoordinates(..). This results in the proper client-space position. Validated against - TestGearsES2NewtCanvasAWT - TestBug1431NewtCanvasAWT on Debian 12 w/ Java17.
Diffstat (limited to 'src/newt/native')
-rw-r--r--src/newt/native/X11Common.h3
-rw-r--r--src/newt/native/X11Display.c11
-rw-r--r--src/newt/native/X11Window.c17
3 files changed, 19 insertions, 12 deletions
diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h
index f570b7d39..c74599335 100644
--- a/src/newt/native/X11Common.h
+++ b/src/newt/native/X11Common.h
@@ -1,5 +1,5 @@
/**
- * Copyright 2011 JogAmp Community. All rights reserved.
+ * Copyright 2011-2023 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -83,6 +83,7 @@ typedef struct {
#define XI_TOUCHCOORD_COUNT 10
typedef struct {
+ Window parentWindow;
Window window;
jobject jwindow;
Atom * allAtoms;
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index 8457e4b63..a2fba9b7f 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -1,5 +1,5 @@
/**
- * Copyright 2011 JogAmp Community. All rights reserved.
+ * Copyright 2011-2023 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -764,11 +764,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
Window winRoot, winTopParent;
Bool translated = False;
if( 0 != NewtWindows_getRootAndParent(dpy, evt.xconfigure.window, &winRoot, &winTopParent) ) {
+ DBG_PRINT( "X11: event . ConfigureNotify call %p (root %p, top %p)\n",
+ (void*)evt.xconfigure.window, (void*)winRoot, (void*)winTopParent);
int x_return=-1, y_return=-1;
+ Window winDest = ( winTopParent == jw->parentWindow ) ? winTopParent : winRoot;
Window child;
- if( True == XTranslateCoordinates(dpy, evt.xconfigure.window, winRoot, 0, 0, &x_return, &y_return, &child) ) {
- DBG_PRINT( "X11: event . ConfigureNotify call %p POS (Xtrans) %d/%d -> %d/%d\n",
- (void*)evt.xconfigure.window, x_pos, y_pos, x_return, y_return);
+ if( True == XTranslateCoordinates(dpy, evt.xconfigure.window, winDest, 0, 0, &x_return, &y_return, &child) ) {
+ DBG_PRINT( "X11: event . ConfigureNotify call %p of dest %p POS (Xtrans) %d/%d -> %d/%d (child %p)\n",
+ (void*)evt.xconfigure.window, winDest, x_pos, y_pos, x_return, y_return, child);
x_pos = x_return;
y_pos = y_return;
translated = True;
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index b93bbe24f..b53b596cc 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -1,6 +1,6 @@
/*
+ * Copyright (c) 2010-2023 JogAmp Community. All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
- * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -198,7 +198,7 @@ uint32_t NewtWindows_getNET_WM_STATE(Display *dpy, JavaWindow *w) {
return res;
}
-static JavaWindow* createJavaWindowProperty(JNIEnv *env, Display *dpy, Window root, Window window,
+static JavaWindow* createJavaWindowProperty(JNIEnv *env, Display *dpy, Window root, Window parentWindow, Window window,
jlong javaObjectAtom, jlong windowDeleteAtom, jobject obj, Bool verbose) {
jobject jwindow = (*env)->NewGlobalRef(env, obj);
JavaWindow * res;
@@ -210,6 +210,7 @@ static JavaWindow* createJavaWindowProperty(JNIEnv *env, Display *dpy, Window ro
return NULL;
}
res = calloc(1, sizeof(JavaWindow));
+ res->parentWindow = parentWindow;
res->window = window;
res->jwindow = jwindow;
res->allAtoms = allAtoms;
@@ -920,7 +921,7 @@ JNIEXPORT jlongArray JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWind
// XClearWindow(dpy, window);
XSetWMProtocols(dpy, window, &wm_delete_atom, 1); // windowDeleteAtom
- javaWindow = createJavaWindowProperty(env, dpy, root, window, javaObjectAtom, windowDeleteAtom, obj, verbose);
+ javaWindow = createJavaWindowProperty(env, dpy, root, (Window)parent, window, javaObjectAtom, windowDeleteAtom, obj, verbose);
NewtWindows_setWindowTypeEWMH(dpy, javaWindow, _NET_WM_WINDOW_TYPE_NORMAL_IDX);
NewtWindows_setDecorations(dpy, javaWindow, TST_FLAG_IS_UNDECORATED(flags) ? False : True );
@@ -1215,8 +1216,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo
fsEWMHFlags |= _MASK_NET_WM_STATE_BELOW; // toggle below
}
- DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, isChild %d, undecorated[change %d, val %d], fullscreen[change %d, val %d (span %d)], alwaysOn[Top[change %d, val %d], Bottom[change %d, val %d]], visible[change %d, val %d, tempInvisible %d], resizable[change %d, val %d], sticky[change %d, val %d], fsEWMHFlags %d\n",
- (void*)dpy, screen_index, (void*) jparent, (void*)parent, (void*)jw->window,
+ DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p -> %p (%p), win %p, %d/%d %dx%d, parentChange %d, isChild %d, undecorated[change %d, val %d], fullscreen[change %d, val %d (span %d)], alwaysOn[Top[change %d, val %d], Bottom[change %d, val %d]], visible[change %d, val %d, tempInvisible %d], resizable[change %d, val %d], sticky[change %d, val %d], fsEWMHFlags %d\n",
+ (void*)dpy, screen_index, (void*)jw->parentWindow, (void*) jparent, (void*)parent, (void*)jw->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),
@@ -1267,7 +1268,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo
if( TST_FLAG_CHANGE_PARENTING(flags) && !TST_FLAG_IS_CHILD(flags) ) {
// TOP: in -> out
- DBG_PRINT( "X11: reconfigureWindow0 PARENTING in->out\n");
+ DBG_PRINT( "X11: reconfigureWindow0 PARENTING in->out %p -> %p\n", (void*)jw->parentWindow, (void*)jparent);
+ jw->parentWindow = (Window)jparent;
XReparentWindow( dpy, jw->window, parent, x, y ); // actual reparent call
#ifdef REPARENT_WAIT_FOR_REPARENT_NOTIFY
XIfEvent( dpy, &event, WaitForReparentNotify, (XPointer) jw->window );
@@ -1313,7 +1315,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo
if( TST_FLAG_CHANGE_PARENTING(flags) && TST_FLAG_IS_CHILD(flags) ) {
// CHILD: out -> in
- DBG_PRINT( "X11: reconfigureWindow0 PARENTING out->in\n");
+ DBG_PRINT( "X11: reconfigureWindow0 PARENTING out->in %p -> %p\n", (void*)jw->parentWindow, (void*)jparent);
+ jw->parentWindow = (Window)jparent;
XReparentWindow( dpy, jw->window, parent, x, y ); // actual reparent call
XFlush(dpy);
#ifdef REPARENT_WAIT_FOR_REPARENT_NOTIFY