[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Control.setSize / Control.getSize discrepancy

Hi,

experimenting with code to restore window positions and sizes on
subsequent starts, I've come across the following issue:

When setting a window's size, e.g. by calling something like
shell.setSize(x, y), the actual size of that window differs from the one
specified in the setSize call. This happens on Linux GTK (Ubuntu 8.04,
Gnome 2.22.1, GTK+ 2.12.9), Eclipse 3.4M7.

The following snippet demonstrates the "sizing discrepancy":


package snippets;


import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class SetSizeDiscrepancy {

  private static final int SIZE_X = 500;
  private static final int SIZE_Y = 350;


  public static void main(String[] args) {

    final Display display = new Display();
    final Shell shell = new Shell();

    shell.setSize(SIZE_X, SIZE_Y);
    shell.open();

    System.out.println("Size should be  : " + SIZE_X + "x" + SIZE_Y);
    System.out.println("Size actually is: " + shell.getSize().x + "x" +
        shell.getSize().y + " [as returned by Control.getSize()]");

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

    display.dispose();

  }

}


On my system, this returns 500x343, instead of the expected 500x350. Any
ideas on this? Is this intended behaviour, or rather a bug?

Best wishes
Karsten

-- 
PGP Public Key ID 0x708CD1FE (pgpkeys.pca.dfn.de)
"When the light of day is dead, the spark of night ignites"