Skip to content

Commit bb5417b

Browse files
joel-majanoakurtakov
authored andcommitted
Bug 575814 - [GTK4] Restore default sizing if no setBounds/Size used
This patch restores equivalent functionality to GTK3 to shells that are opened without calling setBounds or setSize. Change-Id: I64ef437f309b89f7b832f79a4a5457dd0317bc47 Signed-off-by: jmajano <[email protected]> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/185564 Tested-by: Platform Bot <[email protected]> Reviewed-by: Alexander Kurtakov <[email protected]>
1 parent 7cad843 commit bb5417b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6143,11 +6143,22 @@ void leaveProc(long controller, long user_data) {
61436143
void computeSizeProc(long toplevel, long size, long user_data) {
61446144
Shell shell = (Shell)getWidget(user_data);
61456145
if(shell == null) return;
6146-
if(windowSizeSet && !shell.geometry.getResize() ) return;
6147-
GTK4.gdk_toplevel_size_set_size(size,shell.geometry.getRequestedWidth(),shell.geometry.getRequestedHeight() );
6146+
if(shell.geometry.getResize()) {
6147+
GTK4.gdk_toplevel_size_set_size(size,shell.geometry.getRequestedWidth(),shell.geometry.getRequestedHeight() );
6148+
windowSizeSet = true;
6149+
shell.geometry.setResize(false);
6150+
}
6151+
if(windowSizeSet) return;
6152+
6153+
//Only used to set initial size if resize not requested
6154+
int[] defaultWidth = new int[1];
6155+
int [] defaultHeight = new int[1];
6156+
GTK4.gdk_toplevel_size_get_bounds(size, defaultWidth, defaultHeight);
6157+
defaultWidth[0] = (int) (defaultWidth[0] * Shell.SHELL_TO_MONITOR_RATIO);
6158+
defaultHeight[0] = (int) (defaultHeight[0] * Shell.SHELL_TO_MONITOR_RATIO);
6159+
GTK4.gdk_toplevel_size_set_size(size, defaultWidth[0], defaultHeight[0]);
61486160
windowSizeSet = true;
61496161
shell.geometry.setResize(false);
6150-
61516162
}
61526163

61536164
void activateProc(long action, long parameter, long user_data) {

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public class Shell extends Decorations {
137137
static final int MAXIMUM_TRIM = 128;
138138
static final int BORDER = 3;
139139

140-
private final double SHELL_TO_MONITOR_RATIO = 0.625; // Fractional: 5 / 8
140+
static final double SHELL_TO_MONITOR_RATIO = 0.625; // Fractional: 5 / 8
141141

142142
/**
143143
* Constructs a new instance of this class. This is equivalent

0 commit comments

Comments
 (0)