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 @@ -3353,7 +3353,10 @@ public void setBounds (Rectangle rect) {
* Thus, reduce the control size in case it would not fit anyway
*/
private void fitInParentBounds(Rectangle boundsInPixels, int zoom) {
if (parent == null) {
if (parent == null || this instanceof Shell) {
// A Shell is a geometric top-level element and must not be fit into any
// logical parent's bounds — even if it has another Shell set as parent
// (which denotes an owner relationship, not geometric containment).
return;
}
Rectangle parentBoundsInPixels = parent.getBoundsInPixels();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,33 @@ public void test_setSizeLorg_eclipse_swt_graphics_Point() {
}
}

// See https://github.com/eclipse-platform/eclipse.platform.swt/issues/3597
@Test
public void test_setSize_ownedShellNotConstrainedByOwnerBounds() throws InterruptedException {
shell.setSize(500, 500);
shell.open();

int ownerHeight = shell.getSize().y;
int ownerWidth = shell.getSize().x;
testShell.open();

// Make shell vertically exceed parent shell bounds
int requestedHeight = 100;
testShell.setLocation(0, ownerHeight - requestedHeight + 1);
testShell.setSize(200, requestedHeight);
SwtTestUtil.processEvents(10000, () -> testShell.getSize().y == requestedHeight);
assertEquals(requestedHeight, testShell.getSize().y,
"Owned Shell height must not be constrained by owner Shell bounds");

// Make shell horizontally exceed parent shell bounds
int requestedWidth = 100;
testShell.setLocation(ownerWidth - requestedWidth + 1, 0);
testShell.setSize(requestedWidth, 200);
SwtTestUtil.processEvents(10000, () -> testShell.getSize().x == requestedWidth);
assertEquals(requestedWidth, testShell.getSize().x,
"Owned Shell width must not be constrained by owner Shell bounds");
}

private void assertShellProperlySized(Shell shell, Point expectedSize) {
int tolerance = shell.getZoom() != 100 ? 1 : 0;
Point actualSize = shell.getSize();
Expand Down
Loading