Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 407642

Summary: Kubuntu: shell ignores set menubar for calculation of preferred size
Product: [Eclipse Project] Platform Reporter: Thomas Singer <eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: ericwill
Version: 4.3Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Thomas Singer CLA 2013-05-09 08:43:25 EDT
Execute following snippet on Ubuntu 12.04 (using SWT version 4.317, gtk.linux bundle):

final Display display = new Display();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setText("Kubuntu-Test");

final Menu menuBar = new Menu(shell, SWT.BAR);
new MenuItem(menuBar, SWT.PUSH).setText("Menu");
shell.setMenuBar(menuBar);

shell.setLayout(new Layout() {
    @Override
    protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
        return new Point(200, 100);
    }

    @Override
    protected void layout(Composite composite, boolean flushCache) {
        System.out.println("Bounds: " + shell.getBounds() + ", clientArea: " + shell.getClientArea());
    }
});

final Point defaultSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
System.out.println("default size: " + defaultSize);
shell.setMinimumSize(defaultSize);
shell.setSize(defaultSize);

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


resize the bottom border a little bit and you will see following output:

default size: Point {206, 129}
Bounds: Rectangle {0, 0, 206, 129}, clientArea: Rectangle {0, 0, 200, 100}
Bounds: Rectangle {1033, 24, 202, 131}, clientArea: Rectangle {0, 0, 200, 102}

Execute the same snippet on Kubuntu 13.04 and you will see following output:

default size: Point {206, 129}
Bounds: Rectangle {0, 0, 206, 129}, clientArea: Rectangle {0, 0, 200, 100}
Bounds: Rectangle {0, 0, 204, 128}, clientArea: Rectangle {0, 0, 200, 82}

Note, that the clientArea becomes much smaller though the component height had been increased! This causes the status bar of our application (SmartGit) to not be visible until the user resizes the window. It looks like the SWT code does not take into account, that on Kubuntu the menubar is shown inside the window where on Ubuntu it is shown at the top of the screen.
Comment 1 Eric Williams CLA 2018-05-11 11:30:07 EDT
(In reply to Thomas Singer from comment #0)
> resize the bottom border a little bit and you will see following output:
> 
> default size: Point {206, 129}
> Bounds: Rectangle {0, 0, 206, 129}, clientArea: Rectangle {0, 0, 200, 100}
> Bounds: Rectangle {1033, 24, 202, 131}, clientArea: Rectangle {0, 0, 200,
> 102}
> 
> Execute the same snippet on Kubuntu 13.04 and you will see following output:
> 
> default size: Point {206, 129}
> Bounds: Rectangle {0, 0, 206, 129}, clientArea: Rectangle {0, 0, 200, 100}
> Bounds: Rectangle {0, 0, 204, 128}, clientArea: Rectangle {0, 0, 200, 82}
> 
> Note, that the clientArea becomes much smaller though the component height
> had been increased! This causes the status bar of our application (SmartGit)
> to not be visible until the user resizes the window. It looks like the SWT
> code does not take into account, that on Kubuntu the menubar is shown inside
> the window where on Ubuntu it is shown at the top of the screen.

I cannot reproduce this behaviour, my system behaves like the first example. This is Fedora 28, GTK3.22, and SWT 4.8 M7. Can you still reproduce this issue?
Comment 2 Eric Williams CLA 2018-06-13 10:35:18 EDT
Closing this ticket now, please re-open the bug if you see the issue on 4.8 with GTK3.22.