Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2361,8 +2361,10 @@ void resizeBounds (int width, int height, boolean notify) {
GDK.gdk_window_resize (enableWindow, width, height);
}
}
int boxWidth = width - 2*border;
int boxHeight = height - 2*border;
// GTK rejects negative allocations; a shell smaller than its own border must not
// leak a negative size into gtk_widget_size_allocate().
int boxWidth = Math.max (0, width - 2*border);
Comment thread
vogella marked this conversation as resolved.
int boxHeight = Math.max (0, height - 2*border);
if ((style & SWT.RESIZE) == 0) {
GTK.gtk_widget_set_size_request (vboxHandle, boxWidth, boxHeight);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,4 +1054,24 @@ public void test_setLocationII() {
}
super.test_setLocationII();
}

@Test
public void test_degenerateSizeDoesNotExpandShell() {
// A bordered popup asked for a height of 0 used to be allocated -1, which GTK rejects,
// so it fell back to its natural size with its content never laid out. See issue 3539.
// GTK4 backs these shells with a GtkPopover, which never went through that box maths
// and enforces a minimum height of its own.
assumeTrue(SwtTestUtil.isGTK && !SwtTestUtil.isGTK4());
Shell popup = new Shell(shell, SWT.TOOL | SWT.ON_TOP);
popup.setLayout(new FillLayout());
Button child = new Button(popup, SWT.PUSH);
child.setText("some content that is clearly taller than two pixels");
popup.setSize(228, 0);
popup.setVisible(true);
SwtTestUtil.processEvents();
Rectangle clientArea = popup.getClientArea();
popup.dispose();
assertTrue(clientArea.height >= 0, "negative client area: " + clientArea);
assertTrue(clientArea.height <= 2, "shell expanded to its natural size: " + clientArea);
}
}
Loading