Skip to content

[GTK4] Dialog is too large for set size #3333

@tmssngr

Description

@tmssngr

Describe the bug
For a dialog shell (SWT.DIALOG_TRIM) the set size is used for the client area, but not for the full shell.

To Reproduce

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

public class GTK4TooSmallDialog {

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

		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout());

		final Button button = createButton(shell, "Open Dialog");
		button.addListener(SWT.Selection, event -> showDialog(shell));

		shell.setSize(400, 300);
		shell.open();

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

		display.dispose();
	}

	private static void showDialog(Shell parent) {
		final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
		shell.setLayout(new GridLayout(2, true));

		new Label(shell, SWT.NONE).setText("Label:");

		new Text(shell, SWT.BORDER);

		createButton(shell, "OK").addListener(SWT.Selection, event -> shell.dispose());
		createButton(shell, "Cancel").addListener(SWT.Selection, event -> shell.dispose());

		final Point minSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
		System.out.println("minSize = " + minSize);
		shell.setSize(minSize);
		shell.open();
	}

	private static Button createButton(Composite parent, String text) {
		final Button button = new Button(parent, SWT.PUSH);
		button.setText(text);
		button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
		return button;
	}
}
  • run with SWT_GTK4=1
  • click the "Open Dialog" button
  • the occurring dialog is too large (by the title bar height)
  • the printed, calculated minimum size is 177, 117 which matches the size of the shell's client area
  • this bug is not reproducible for SHELL_TRIM

Expected behavior
The dialog shell should have the correct size.

Screenshots
With SWT_GTK4=1 (too large height):
Image

With SWT_GTK4=0 (correct):
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)
    Ubuntu 26.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions