Bug 519808 - [GTK] Shell.getBounds returns obsolete values
Using gdk_window_get_root_origin before it's mapped returns 0,0
coordinates. As gtk_window_get_position returns correct coordinates in
general except after unmap when it returns the last "set" coordinates
gdk_window_get_root_origin should be used only for DISPOSE_SENT to
retrieve the last real coordinates.
Change-Id: I1f9f6ad8df62fb246f6219c54a085e4c4dbdd97e
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 5f51873..8788256 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -2730,7 +2730,11 @@
Rectangle getBoundsInPixels () {
checkWidget ();
int [] x = new int [1], y = new int [1];
- OS.gdk_window_get_root_origin(OS.gtk_widget_get_window(shellHandle), x, y);
+ if ((state & Widget.DISPOSE_SENT) == 0) {
+ OS.gtk_window_get_position (shellHandle, x, y);
+ } else {
+ OS.gdk_window_get_root_origin(OS.gtk_widget_get_window(shellHandle), x, y);
+ }
GtkAllocation allocation = new GtkAllocation ();
OS.gtk_widget_get_allocation (vboxHandle, allocation);
int width = allocation.width;