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

Bug 407635

Summary: Size-related problems on Kubuntu
Product: [Eclipse Project] Platform Reporter: Thomas Singer <eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, ericwill
Version: 4.3Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
screenshot none

Description Thomas Singer CLA 2013-05-09 06:47:34 EDT
Created attachment 230717 [details]
screenshot

When running following code on Kubuntu 13.04 with SWT (gtk.linux bundle, version 4.317):

		final Display display = new Display();
		final Shell shell = new Shell(display, SWT.SHELL_TRIM);
		shell.setText("Kubuntu-Test");
		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();

and resize the bottom corner of the window, I'm getting 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, 101}

This means, the actual window size becomes smaller than its set minimum size!
Comment 1 Thomas Singer CLA 2013-05-09 07:01:41 EDT
The problem also can be reproduced on Ubuntu 12.04:

default size: Point {206, 129}
Bounds: Rectangle {0, 0, 206, 129}, clientArea: Rectangle {0, 0, 200, 100}
Bounds: Rectangle {49, 567, 202, 131}, clientArea: Rectangle {0, 0, 200, 102}
Comment 2 Alexander Kurtakov CLA 2018-01-15 16:09:23 EST
Is this still reproducible?
Comment 3 Thomas Singer CLA 2018-01-17 02:50:27 EST
Have you tried it? Even with the latest SWT 4.7 the set minimum size seems to be ignored (tried Fedora 27).
Comment 4 Eric Williams CLA 2018-05-11 11:20:15 EDT
(In reply to Thomas Singer from comment #0)
> 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, 101}
> 
> This means, the actual window size becomes smaller than its set minimum size!

Is this not by design? The client area is the area in which the widget is capable of displaying data (i.e. minus all trimmings). I observe a ~30 px difference in height between the default size, and the client area. This accounts for the height of the title bar, which is about the same (~30 px).

IMO this isn't a bug, as the default size returns the preferred size of the entire Shell widget, including trimmings. The client area is the size of the Shell minus these components.
Comment 5 Thomas Singer CLA 2018-05-11 11:56:36 EDT
(In reply to Eric Williams from comment #4)
> (In reply to Thomas Singer from comment #0)
> > 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, 101}
> > 
> > This means, the actual window size becomes smaller than its set minimum size!
> 
> Is this not by design?

Err, no, the set minimum size should be the _minimum_ size. It should NOT be possible to resize the window to become smaller than the set minimum size.
Comment 6 Eric Williams CLA 2018-05-11 12:05:23 EDT
(In reply to Thomas Singer from comment #5)
> Err, no, the set minimum size should be the _minimum_ size. It should NOT be
> possible to resize the window to become smaller than the set minimum size.

Correct, but the bounds are reflecting that. The client area isn't the same as the widget size. 

The client area will always be <= the bounds, as there are trimmings to take into account. Bounds will always be >= minimum size. I believe the output from comment 0 reflects that. Also on my Fedora 28 system with SWT 4.8 M7, I cannot get the bounds to be smaller than the minimum size.
Comment 7 Thomas Singer CLA 2018-05-11 12:31:45 EDT
(In reply to Eric Williams from comment #6)
> (In reply to Thomas Singer from comment #5)
> > Err, no, the set minimum size should be the _minimum_ size. It should NOT be
> > possible to resize the window to become smaller than the set minimum size.
> 
> Correct, but the bounds are reflecting that. The client area isn't the same
> as the widget size. 
> 
> The client area will always be <= the bounds, as there are trimmings to take
> into account. Bounds will always be >= minimum size. I believe the output
> from comment 0 reflects that.

No, they did not reflect this. Though a minimum size of {206, 129} had been set, I was able to size the shell to {0, 0, 204, 128} (204 < 206 and 128 < 129).
Comment 8 Eric Williams CLA 2018-05-11 13:57:21 EDT
(In reply to Thomas Singer from comment #7)
> No, they did not reflect this. Though a minimum size of {206, 129} had been
> set, I was able to size the shell to {0, 0, 204, 128} (204 < 206 and 128 <
> 129).

Does it get any smaller than this? I'm wondering if maybe there is some small trimming (a border or something that's ~2px) not being taken into account. Does the issue still reproduce for you on Kubuntu? Or even Fedora?
Comment 9 Thomas Singer CLA 2018-05-12 04:06:18 EDT
(In reply to Eric Williams from comment #8)
> (In reply to Thomas Singer from comment #7)
> > No, they did not reflect this. Though a minimum size of {206, 129} had been
> > set, I was able to size the shell to {0, 0, 204, 128} (204 < 206 and 128 <
> > 129).
> 
> Does it get any smaller than this? I'm wondering if maybe there is some
> small trimming (a border or something that's ~2px) not being taken into
> account. Does the issue still reproduce for you on Kubuntu? Or even Fedora?

I've reinstalled Kubuntu 16.10 now. With 4.7 I was able to reproduce this problem (it printed 2 "Bounds: " lines as shown in the initial posting), but with 4.8M7 only 1 "Bounds: " line is shown and I was not able any more to make the shell smaller than its initially set minimum size.
Comment 10 Eric Williams CLA 2018-05-12 10:59:31 EDT
(In reply to Thomas Singer from comment #9)
> I've reinstalled Kubuntu 16.10 now. With 4.7 I was able to reproduce this
> problem (it printed 2 "Bounds: " lines as shown in the initial posting), but
> with 4.8M7 only 1 "Bounds: " line is shown and I was not able any more to
> make the shell smaller than its initially set minimum size.

This is the same behaviour I see on Fedora 28 with 4.8 M7. I'm going to close this ticket, please let me know if this bug reappears somewhere.