Bug 319612 - [Gtk] Shell.getSize() returns wrong value when created with style SWT.RESIZE | SWT.ON_TOP
Summary: [Gtk] Shell.getSize() returns wrong value when created with style SWT.RESIZE ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.9 M2   Edit
Assignee: Eric Williams CLA
QA Contact:
URL:
Whiteboard: hasSnippet
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2010-07-12 12:54 EDT by Pawel Piech CLA
Modified: 2018-08-03 09:51 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.