Skip to content

[GTK, Wayland] Shell can be resized smaller than set minimum size #3281

@tmssngr

Description

@tmssngr

Describe the bug
When setting the minimum size of a shell, it is expected that the user can't make it smaller than this by resizing the window. This works as expected on Windows, macOS and Linux with X11, but not on Linux with Wayland.

To Reproduce

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;

public class MinimumSizeShell {

	public static void main(String[] args) {
		final Display display = new Display();

		final Shell shell = new Shell(display);
		final Composite composite = new Composite(shell, 0);
		composite.addListener(SWT.Paint, event -> {
			final Point size = composite.getSize();
			event.gc.setForeground(new Color(255, 0, 0));
			event.gc.setLineWidth(5);
			event.gc.drawRectangle(0, 0, size.x - 1, size.y - 1);
		});
		shell.setLayout(new Layout() {
			@Override
			protected Point computeSize(Composite unused, int wHint, int hHint, boolean flushCache) {
				return new Point(400, 300);
			}

			@Override
			protected void layout(Composite unused, boolean flushCache) {
				composite.setSize(400, 300);
			}
		});

		final Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		shell.setSize(size);
		shell.setMinimumSize(size);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}

		display.dispose();
	}
}
  • launch and try to make the shell smaller

Expected behavior
It must not be possible to make the shell smaller than the set minimum size.

Screenshots
Initially:
Image

After making smaller:
Image

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Tried on Ubuntu 26.04 and Fedora Silverblue 43.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions