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

Bug 319612

Summary: [Gtk] Shell.getSize() returns wrong value when created with style SWT.RESIZE | SWT.ON_TOP
Product: [Eclipse Project] Platform Reporter: Pawel Piech <pawel.1.piech>
Component: SWTAssignee: Eric Williams <ericwill>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, lufimtse, markus.kell.r, pwebster, xixiyan
Version: 4.8Keywords: triaged
Target Milestone: 4.9 M2   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/123875
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=820c46cbb7018b48aa8791ca34c8025246bda964
Whiteboard: hasSnippet

Description Pawel Piech CLA 2010-07-12 12:54:42 EDT
Build id: I20100603-1500

The Shell.adjustTrim() method seems to fail with this style combination and as a result the returned getSize() value is too small.  The following snippet demonstrates the bug by calling getSize()/setSize() in a loop.

public class MagicalShrinkingShell {

public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell (display, SWT.RESIZE | SWT.ON_TOP);
    
    GridLayout layout= new GridLayout(1, false);
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    shell.setLayout(layout);

    shell.setSize (200, 200);
    shell.open ();

    for (int i = 0; i < 50; i++) {
        while (display.readAndDispatch ());
    
        Point p = shell.getSize();
        shell.setSize(p.x, p.y);
        
        try {
            Thread.currentThread().sleep(100);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}

}
Comment 1 Eric Williams CLA 2016-10-18 16:00:09 EDT
This issue is still reproducible!
Comment 2 Leo Ufimtsev CLA 2018-02-07 10:17:09 EST
Eric mentioned it reproduces on Gtk3.22. Bug reported on Gtk2 initially.
Comment 3 Eric Williams CLA 2018-05-31 11:32:58 EDT
This is a good candidate for 4.9 IMO.
Comment 5 Eric Williams CLA 2018-06-07 10:30:39 EDT
(In reply to Eclipse Genie from comment #4)
> Gerrit change https://git.eclipse.org/r/123875 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=820c46cbb7018b48aa8791ca34c8025246bda964

In master now.