Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmajano2021-09-10 15:27:01 +0000
committerAlexander Kurtakov2021-09-13 14:56:13 +0000
commite511efab8374e7b625df2ccaa8bf93ca133b75cb (patch)
tree70fc0c4be6f403733e5c3a989a44af24c542274b
parentee2a08f9745da984fdc700b76a52d4aed02a3465 (diff)
downloadeclipse.platform.swt-e511efab8374e7b625df2ccaa8bf93ca133b75cb.tar.gz
eclipse.platform.swt-e511efab8374e7b625df2ccaa8bf93ca133b75cb.tar.xz
eclipse.platform.swt-e511efab8374e7b625df2ccaa8bf93ca133b75cb.zip
Bug 575814 - [GTK4] Restore window sizing using GdkToplevelSize
Restored sizing of window functionality by adding: - SWTGeometry, a parallel to GdkGeometry, useful to prevent major logic changes - GeometryInterface, which provides set and get functions for GdkGeometry and SWTGeometry - connected a new signal (compute-size) - added new GDKToplevelSize functions Complete correctness in terms of exact pixels still needs to be double checked but setBounds no longer crashes. Change-Id: If7eaff0da30694d3fba758d4d150d4e2c1ce5ce2 Signed-off-by: jmajano <jmajano@redhat.com> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/185309 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GeometryInterface.java35
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GdkGeometry.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SWTGeometry.java92
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java73
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java3
11 files changed, 320 insertions, 32 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
index d149153492..0f740fcce0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
@@ -106,6 +106,43 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gdk_1toplevel_1set_1icon_1list)
}
#endif
+#ifndef NO_gdk_1toplevel_1size_1get_1bounds
+JNIEXPORT void JNICALL GTK4_NATIVE(gdk_1toplevel_1size_1get_1bounds)
+ (JNIEnv *env, jclass that, jlong arg0, jintArray arg1, jintArray arg2)
+{
+ jint *lparg1=NULL;
+ jint *lparg2=NULL;
+ GTK4_NATIVE_ENTER(env, that, gdk_1toplevel_1size_1get_1bounds_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ gdk_toplevel_size_get_bounds((GdkToplevelSize*)arg0, (int *)lparg1, (int *)lparg2);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ GTK4_NATIVE_EXIT(env, that, gdk_1toplevel_1size_1get_1bounds_FUNC);
+}
+#endif
+
+#ifndef NO_gdk_1toplevel_1size_1set_1min_1size
+JNIEXPORT void JNICALL GTK4_NATIVE(gdk_1toplevel_1size_1set_1min_1size)
+ (JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2)
+{
+ GTK4_NATIVE_ENTER(env, that, gdk_1toplevel_1size_1set_1min_1size_FUNC);
+ gdk_toplevel_size_set_min_size((GdkToplevelSize*)arg0, (int)arg1, (int)arg2);
+ GTK4_NATIVE_EXIT(env, that, gdk_1toplevel_1size_1set_1min_1size_FUNC);
+}
+#endif
+
+#ifndef NO_gdk_1toplevel_1size_1set_1size
+JNIEXPORT void JNICALL GTK4_NATIVE(gdk_1toplevel_1size_1set_1size)
+ (JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2)
+{
+ GTK4_NATIVE_ENTER(env, that, gdk_1toplevel_1size_1set_1size_FUNC);
+ gdk_toplevel_size_set_size((GdkToplevelSize*)arg0, (int)arg1, (int)arg2);
+ GTK4_NATIVE_EXIT(env, that, gdk_1toplevel_1size_1set_1size_FUNC);
+}
+#endif
+
#ifndef NO_gtk_1box_1append
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1box_1append)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.c
index 6e037d610d..8e562e3f16 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.c
@@ -28,6 +28,9 @@ char * GTK4_nativeFunctionNames[] = {
"gdk_1toplevel_1get_1state",
"gdk_1toplevel_1lower",
"gdk_1toplevel_1set_1icon_1list",
+ "gdk_1toplevel_1size_1get_1bounds",
+ "gdk_1toplevel_1size_1set_1min_1size",
+ "gdk_1toplevel_1size_1set_1size",
"gtk_1box_1append",
"gtk_1box_1insert_1child_1after",
"gtk_1box_1prepend",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h
index 02a396e712..7b931eb5e6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h
@@ -38,6 +38,9 @@ typedef enum {
gdk_1toplevel_1get_1state_FUNC,
gdk_1toplevel_1lower_FUNC,
gdk_1toplevel_1set_1icon_1list_FUNC,
+ gdk_1toplevel_1size_1get_1bounds_FUNC,
+ gdk_1toplevel_1size_1set_1min_1size_FUNC,
+ gdk_1toplevel_1size_1set_1size_FUNC,
gtk_1box_1append_FUNC,
gtk_1box_1insert_1child_1after_FUNC,
gtk_1box_1prepend_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GeometryInterface.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GeometryInterface.java
new file mode 100644
index 0000000000..c75c4b314a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GeometryInterface.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2021 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+public interface GeometryInterface {
+
+ public int getMinWidth();
+ public int getMinHeight();
+ public int getMaxWidth();
+ public int getMaxHeight();
+ public boolean getResize();
+ public boolean getMinSizeRequested();
+ public int getRequestedWidth();
+ public int getRequestedHeight();
+
+ public void setMinWidth(int value);
+ public void setMinHeight(int value);
+ public void setMaxWidth(int value);
+ public void setMaxHeight(int value);
+ public void setResize(boolean value);
+ public void setMinSizeRequested(boolean value);
+ public void setRequestedWidth(int value);
+ public void setRequestedHeight(int value);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index e15e25a232..57051a1d8f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -377,6 +377,7 @@ public class OS extends C {
public static final byte[] notify_default_width = ascii("notify::default-width");
public static final byte[] notify_theme_change = ascii("notify::gtk-application-prefer-dark-theme");
public static final byte[] response = ascii("response");
+ public static final byte[] compute_size = ascii("compute-size");
/** Properties */
public static final byte[] active = ascii("active");
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GdkGeometry.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GdkGeometry.java
index b183909e1b..6729264257 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GdkGeometry.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GdkGeometry.java
@@ -14,7 +14,8 @@
*******************************************************************************/
package org.eclipse.swt.internal.gtk3;
-public class GdkGeometry {
+import org.eclipse.swt.internal.gtk.*;
+public class GdkGeometry implements GeometryInterface{
public int min_width;
public int min_height;
public int max_width;
@@ -27,4 +28,65 @@ public class GdkGeometry {
public double max_aspect;
public int win_gravity;
public static final int sizeof = GTK3.GdkGeometry_sizeof();
+
+ @Override
+ public int getMinWidth() {
+ return min_width;
+ }
+ @Override
+ public int getMinHeight() {
+ return min_height;
+ }
+ @Override
+ public int getMaxWidth() {
+ return max_width;
+ }
+ @Override
+ public int getMaxHeight() {
+ return max_height;
+ }
+ @Override
+ public boolean getResize() {
+ return false;
+ }
+ @Override
+ public int getRequestedWidth() {
+ return 0;
+ }
+ @Override
+ public int getRequestedHeight() {
+ return 0;
+ }
+ @Override
+ public void setMinWidth(int value) {
+ min_width = value;
+ }
+ @Override
+ public void setMinHeight(int value) {
+ min_height = value;
+ }
+ @Override
+ public void setMaxWidth(int value) {
+ max_width = value;
+ }
+ @Override
+ public void setMaxHeight(int value) {
+ max_height = value;
+ }
+ @Override
+ public void setResize(boolean value) {
+ }
+ @Override
+ public void setRequestedWidth(int value) {
+ }
+ @Override
+ public void setRequestedHeight(int value) {
+ }
+ @Override
+ public boolean getMinSizeRequested() {
+ return false;
+ }
+ @Override
+ public void setMinSizeRequested(boolean value) {
+ }
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java
index 8ef32e3bf5..7a596ecbd6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java
@@ -532,4 +532,26 @@ public class GTK4 {
* @param height cast=(int *)
*/
public static final native void gtk_tree_view_column_cell_get_size(long tree_column, int[] x_offset, int[] y_offset, int[] width, int[] height);
+
+ /* GdkToplevelSize */
+ /**
+ * @param size cast=(GdkToplevelSize*)
+ * @param bounds_width cast=(int *)
+ * @param bounds_height cast=(int *)
+ */
+ public static final native void gdk_toplevel_size_get_bounds(long size, int[] bounds_width, int[] bounds_height);
+ /**
+ * @param size cast=(GdkToplevelSize*)
+ * @param min_width cast=(int)
+ * @param min_height cast=(int)
+ */
+ public static final native void gdk_toplevel_size_set_min_size(long size, int min_width, int min_height);
+ /**
+ * @param size cast=(GdkToplevelSize*)
+ * @param width cast=(int)
+ * @param height cast=(int)
+ */
+ public static final native void gdk_toplevel_size_set_size(long size, int width, int height);
+
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SWTGeometry.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SWTGeometry.java
new file mode 100644
index 0000000000..94434449e8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SWTGeometry.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2021 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+import org.eclipse.swt.internal.gtk.*;
+
+public class SWTGeometry implements GeometryInterface {
+ public int min_width;
+ public int min_height;
+ public int max_width;
+ public int max_height;
+ public boolean resizeToplevel;
+ public boolean minSizeRequested;
+ public int requestedWidth;
+ public int requestedHeight;
+
+ @Override
+ public int getMinWidth() {
+ return min_width;
+ }
+ @Override
+ public int getMinHeight() {
+ return min_height;
+ }
+ @Override
+ public int getMaxWidth() {
+ return max_width;
+ }
+ @Override
+ public int getMaxHeight() {
+ return max_height;
+ }
+ @Override
+ public boolean getResize() {
+ return resizeToplevel;
+ }
+ @Override
+ public int getRequestedWidth() {
+ return requestedWidth;
+ }
+ @Override
+ public int getRequestedHeight() {
+ return requestedHeight;
+ }
+ @Override
+ public void setMinWidth(int value) {
+ min_width = value;
+ }
+ @Override
+ public void setMinHeight(int value) {
+ min_height = value;
+ }
+ @Override
+ public void setMaxWidth(int value) {
+ max_width = value;
+ }
+ @Override
+ public void setMaxHeight(int value) {
+ max_height = value;
+ }
+ @Override
+ public void setResize(boolean value) {
+ resizeToplevel = value;
+ }
+ @Override
+ public void setRequestedWidth(int value) {
+ requestedWidth = value;
+ }
+ @Override
+ public void setRequestedHeight(int value) {
+ requestedHeight = value;
+ }
+ @Override
+ public boolean getMinSizeRequested() {
+ return minSizeRequested;
+ }
+ @Override
+ public void setMinSizeRequested(boolean value) {
+ minSizeRequested = value;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 74ea637b46..7e778211b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -127,6 +127,7 @@ public class Display extends Device {
long fds;
int allocated_nfds;
boolean wake;
+ boolean windowSizeSet;
int [] max_priority = new int [1], timeout = new int [1];
Callback eventCallback;
long eventProc, windowProc2, windowProc3, windowProc4, windowProc5, windowProc6;
@@ -134,9 +135,10 @@ public class Display extends Device {
long snapshotDrawProc, keyPressReleaseProc, focusProc, enterMotionProc, leaveProc,
scrollProc, resizeProc, activateProc, gesturePressReleaseProc;
long notifyProc;
+ long computeSizeProc;
Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6;
Callback changeValue;
- Callback snapshotDraw, keyPressReleaseCallback, focusCallback, enterMotionCallback,
+ Callback snapshotDraw, keyPressReleaseCallback, focusCallback, enterMotionCallback, computeSizeCallback,
scrollCallback, leaveCallback, resizeCallback, activateCallback, gesturePressReleaseCallback;
Callback notifyCallback;
EventTable eventTable, filterTable;
@@ -1156,6 +1158,7 @@ void createDisplay (DeviceData data) {
GDK.gdk_threads_enter ();
}
boolean init;
+ windowSizeSet = false;
if (GTK.GTK4) {
init = GTK4.gtk_init_check();
} else {
@@ -3532,6 +3535,7 @@ void initializeCallbacks () {
signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event, GTK.GTK_TYPE_WIDGET ());
signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate, GTK.GTK_TYPE_WIDGET ());
signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event, GTK.GTK_TYPE_WIDGET ());
+ signalIds [Widget.COMPUTE_SIZE] = OS.g_signal_lookup(OS.compute_size, GTK.GTK_TYPE_WIDGET() );
/*
* Connect to the "popped-up" signal on GTK3.22+ if the user has specified the
* SWT_MENU_LOCATION_DEBUGGING environment variable.
@@ -3589,6 +3593,9 @@ void initializeCallbacks () {
activateCallback = new Callback(this, "activateProc", void.class, new Type[] {long.class, long.class, long.class}); //$NON-NLS-1$
activateProc = activateCallback.getAddress();
+
+ computeSizeCallback = new Callback(this, "computeSizeProc", void.class, new Type[] {long.class, long.class, long.class}); //$NON-NLS-1$
+ computeSizeProc = computeSizeCallback.getAddress();
}
notifyCallback = new Callback(this, "notifyProc", long.class, new Type[] {
@@ -6100,6 +6107,16 @@ void leaveProc(long controller, long user_data) {
if (widget != null) widget.leaveProc(controller, handle, user_data);
}
+void computeSizeProc(long toplevel, long size, long user_data) {
+ Shell shell = (Shell)getWidget(user_data);
+ if(shell == null) return;
+ if(windowSizeSet && !shell.geometry.getResize() ) return;
+ GTK4.gdk_toplevel_size_set_size(size,shell.geometry.getRequestedWidth(),shell.geometry.getRequestedHeight() );
+ windowSizeSet = true;
+ shell.geometry.setResize(false);
+
+}
+
void activateProc(long action, long parameter, long user_data) {
Widget widget = getWidget(user_data);
if(widget == null) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index e0d50d72d2..d06d92e4af 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -127,7 +127,7 @@ public class Shell extends Decorations {
long shellHandle, tooltipsHandle, tooltipWindow, group, modalGroup;
boolean mapped, moved, resized, opened, fullScreen, showWithParent, modified, center;
int oldX, oldY, oldWidth, oldHeight;
- GdkGeometry geometry;
+ GeometryInterface geometry;
Control lastActive;
ToolTip [] toolTips;
boolean ignoreFocusOut, ignoreFocusIn;
@@ -290,7 +290,12 @@ Shell (Display display, Shell parent, int style, long handle, boolean embedded)
state |= FOREIGN_HANDLE;
}
}
- this.geometry = new GdkGeometry();
+ if(!GTK.GTK4) {
+ geometry = new GdkGeometry();
+ }
+ else {
+ geometry = new SWTGeometry();
+ }
reskinWidget();
createWidget (0);
}
@@ -935,6 +940,7 @@ void hookEvents () {
GTK.gtk_widget_realize(shellHandle);
long gdkSurface = gtk_widget_get_surface (shellHandle);
OS.g_signal_connect (gdkSurface, OS.notify_state, display.notifyProc, shellHandle);
+ OS.g_signal_connect (gdkSurface, OS.compute_size, display.computeSizeProc, shellHandle);
OS.g_signal_connect(shellHandle, OS.notify_default_height, display.notifyProc, Widget.NOTIFY_DEFAULT_HEIGHT);
OS.g_signal_connect(shellHandle, OS.notify_default_width, display.notifyProc, Widget.NOTIFY_DEFAULT_WIDTH);
} else {
@@ -1279,8 +1285,8 @@ public Point getMinimumSize () {
Point getMinimumSizeInPixels () {
checkWidget ();
- int width = Math.max (1, geometry.min_width + trimWidth ());
- int height = Math.max (1, geometry.min_height + trimHeight ());
+ int width = Math.max (1, geometry.getMinWidth() + trimWidth ());
+ int height = Math.max (1, geometry.getMinHeight() + trimHeight ());
return new Point (width, height);
}
@@ -1307,8 +1313,8 @@ public Point getMaximumSize () {
Point getMaximumSizeInPixels () {
checkWidget ();
- int width = Math.min (Integer.MAX_VALUE, geometry.max_width + trimWidth ());
- int height = Math.min (Integer.MAX_VALUE, geometry.max_height + trimHeight ());
+ int width = Math.min (Integer.MAX_VALUE, geometry.getMaxWidth() + trimWidth ());
+ int height = Math.min (Integer.MAX_VALUE, geometry.getMaxHeight() + trimHeight ());
return new Point (width, height);
}
@@ -1689,8 +1695,8 @@ long gtk_motion_notify_event (long widget, long event) {
int y = display.resizeBoundsY;
int width = display.resizeBoundsWidth;
int height = display.resizeBoundsHeight;
- int newWidth = Math.max(width - dx, Math.max(geometry.min_width, border + border));
- int newHeight = Math.max(height - dy, Math.max(geometry.min_height, border + border));
+ int newWidth = Math.max(width - dx, Math.max(geometry.getMinWidth(), border + border));
+ int newHeight = Math.max(height - dy, Math.max(geometry.getMinHeight(), border + border));
switch (display.resizeMode) {
case SWT.CURSOR_SIZEW:
x += width - newWidth;
@@ -1707,24 +1713,24 @@ long gtk_motion_notify_event (long widget, long event) {
height = newHeight;
break;
case SWT.CURSOR_SIZENE:
- width = Math.max(width + dx, Math.max(geometry.min_width, border + border));
+ width = Math.max(width + dx, Math.max(geometry.getMinWidth(), border + border));
y += height - newHeight;
height = newHeight;
break;
case SWT.CURSOR_SIZEE:
- width = Math.max(width + dx, Math.max(geometry.min_width, border + border));
+ width = Math.max(width + dx, Math.max(geometry.getMinWidth(), border + border));
break;
case SWT.CURSOR_SIZESE:
- width = Math.max(width + dx, Math.max(geometry.min_width, border + border));
- height = Math.max(height + dy, Math.max(geometry.min_height, border + border));
+ width = Math.max(width + dx, Math.max(geometry.getMinWidth(), border + border));
+ height = Math.max(height + dy, Math.max(geometry.getMinHeight(), border + border));
break;
case SWT.CURSOR_SIZES:
- height = Math.max(height + dy, Math.max(geometry.min_height, border + border));
+ height = Math.max(height + dy, Math.max(geometry.getMinHeight(), border + border));
break;
case SWT.CURSOR_SIZESW:
x += width - newWidth;
width = newWidth;
- height = Math.max(height + dy, Math.max(geometry.min_height, border + border));
+ height = Math.max(height + dy, Math.max(geometry.getMinHeight(), border + border));
break;
}
if (x != display.resizeBoundsX || y != display.resizeBoundsY) {
@@ -2298,19 +2304,19 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
}
}
if (resize) {
- width = Math.max (1, Math.max (geometry.min_width, width - trimWidth ()));
- if (geometry.max_width > 0) {
- width = Math.min( width, geometry.max_width);
+ width = Math.max (1, Math.max (geometry.getMinWidth(), width - trimWidth ()));
+ if (geometry.getMaxWidth() > 0) {
+ width = Math.min( width, geometry.getMaxWidth());
}
- height = Math.max (1, Math.max (geometry.min_height, height - trimHeight ()));
- if (geometry.max_height > 0) {
- height = Math.min(height, geometry.max_height);
+ height = Math.max (1, Math.max (geometry.getMinHeight(), height - trimHeight ()));
+ if (geometry.getMaxHeight() > 0) {
+ height = Math.min(height, geometry.getMaxHeight());
}
/*
* If the shell is created without a RESIZE style bit, and the
* minWidth/minHeight/maxWidth/maxHeight have been set, allow the resize.
*/
- if ((style & SWT.RESIZE) != 0 || (geometry.min_height != 0 || geometry.min_width != 0 || geometry.max_height != 0 || geometry.max_width != 0)) {
+ if ((style & SWT.RESIZE) != 0 || (geometry.getMinHeight() != 0 || geometry.getMinWidth() != 0 || geometry.getMaxHeight() != 0 || geometry.getMaxWidth() != 0)) {
if (GTK.GTK4) {
/*
* On GTK4, GtkWindow size includes the header bar. In order to keep window size allocation of the client area
@@ -2320,6 +2326,9 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
int[] headerNaturalHeight = new int[1];
GTK4.gtk_widget_measure(header, GTK.GTK_ORIENTATION_VERTICAL, 0, null, headerNaturalHeight, null, null);
+ geometry.setRequestedWidth(width);
+ geometry.setRequestedHeight(height + headerNaturalHeight[0]);
+ geometry.setResize(true);
GTK.gtk_window_set_default_size(shellHandle, width, height + headerNaturalHeight[0]);
} else {
GTK3.gtk_window_resize (shellHandle, width, height);
@@ -2619,13 +2628,19 @@ public void setMinimumSize (int width, int height) {
void setMinimumSizeInPixels (int width, int height) {
checkWidget ();
- geometry.min_width = Math.max (width, trimWidth ()) - trimWidth ();
- geometry.min_height = Math.max (height, trimHeight ()) - trimHeight ();
+ geometry.setMinWidth(Math.max (width, trimWidth ()) - trimWidth ());
+ geometry.setMinHeight(Math.max (height, trimHeight ()) - trimHeight ());
+
+ if(GTK.GTK4) {
+ geometry.setMinSizeRequested(true);
+ return;
+ }
+
int hint = GDK.GDK_HINT_MIN_SIZE;
- if (geometry.max_height > 0 || geometry.max_width > 0) {
+ if (geometry.getMaxHeight() > 0 || geometry.getMaxWidth() > 0) {
hint = hint | GDK.GDK_HINT_MAX_SIZE;
}
- GTK3.gtk_window_set_geometry_hints (shellHandle, 0, geometry, hint);
+ GTK3.gtk_window_set_geometry_hints (shellHandle, 0, (GdkGeometry) geometry, hint);
}
/**
@@ -2716,13 +2731,13 @@ void setMaximumSizeInPixels (Point size) {
void setMaximumSizeInPixels (int width, int height) {
checkWidget ();
- geometry.max_width = Math.max (width, trimWidth ()) - trimWidth ();
- geometry.max_height = Math.max (height, trimHeight ()) - trimHeight ();
+ geometry.setMaxWidth(Math.max (width, trimWidth ()) - trimWidth ());
+ geometry.setMaxHeight(Math.max (height, trimHeight ()) - trimHeight ());
int hint = GDK.GDK_HINT_MAX_SIZE;
- if (geometry.min_width > 0 || geometry.min_height > 0) {
+ if (geometry.getMinWidth() > 0 || geometry.getMinHeight() > 0) {
hint = hint | GDK.GDK_HINT_MIN_SIZE;
}
- GTK3.gtk_window_set_geometry_hints (shellHandle, 0, geometry, hint);
+ GTK3.gtk_window_set_geometry_hints (shellHandle, 0, (GdkGeometry) geometry, hint);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 9a52d8c9d2..c0334dcaaf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -242,7 +242,8 @@ public abstract class Widget {
static final int DPI_CHANGED = 104;
static final int NOTIFY_DEFAULT_HEIGHT = 105;
static final int NOTIFY_DEFAULT_WIDTH = 106;
- static final int LAST_SIGNAL = 107;
+ static final int COMPUTE_SIZE = 107;
+ static final int LAST_SIGNAL = 108;
static final String IS_ACTIVE = "org.eclipse.swt.internal.control.isactive"; //$NON-NLS-1$
static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$

Back to the top