Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java64
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java11
3 files changed, 41 insertions, 49 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index fafbdbd166..c0aaffb72a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -5512,4 +5512,19 @@ long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ us
}
return super.windowProc (handle, arg0, user_data);
}
+
+/**
+ * Gets the coordinates for the top left position of the control with respect to parent
+ *
+ * @return Coordinates for top left position of the control
+ */
+Point getWindowOrigin () {
+ int [] x = new int [1];
+ int [] y = new int [1];
+
+ long /*int*/ window = eventWindow ();
+ OS.gdk_window_get_origin (window, x, y);
+
+ return new Point (x [0], y [0]);
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 24d2d345ca..d4d76ca569 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -3046,32 +3046,16 @@ public Point map (Control from, Control to, int x, int y) {
Point point = new Point (x, y);
if (from == to) return point;
if (from != null) {
- int [] origin_x = new int [1], origin_y = new int [1];
- boolean fromIsSubshell = from instanceof Shell && from.getParent() != null;
- if (fromIsSubshell) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434772
- OS.gtk_window_get_position (((Shell) from).shellHandle, origin_x, origin_y);
- } else {
- long /*int*/ window = from.eventWindow ();
- OS.gdk_window_get_origin (window, origin_x, origin_y);
- if ((from.style & SWT.MIRRORED) != 0) point.x = from.getClientWidth() - point.x;
- }
- point.x += origin_x [0];
- point.y += origin_y [0];
+ Point origin = from.getWindowOrigin ();
+ if ((from.style & SWT.MIRRORED) != 0) point.x = from.getClientWidth () - point.x;
+ point.x += origin.x;
+ point.y += origin.y;
}
if (to != null) {
- int [] origin_x = new int [1], origin_y = new int [1];
- boolean toIsSubshell = to instanceof Shell && to.getParent() != null;
- if (toIsSubshell) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434772
- OS.gtk_window_get_position (((Shell) to).shellHandle, origin_x, origin_y);
- } else {
- long /*int*/ window = to.eventWindow ();
- OS.gdk_window_get_origin (window, origin_x, origin_y);
- }
- point.x -= origin_x [0];
- point.y -= origin_y [0];
- if (!toIsSubshell) {
- if ((to.style & SWT.MIRRORED) != 0) point.x = to.getClientWidth () - point.x;
- }
+ Point origin = to.getWindowOrigin ();
+ point.x -= origin.x;
+ point.y -= origin.y;
+ if ((to.style & SWT.MIRRORED) != 0) point.x = to.getClientWidth () - point.x;
}
return point;
}
@@ -3187,32 +3171,16 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
if (from == to) return rect;
boolean fromRTL = false, toRTL = false;
if (from != null) {
- int [] origin_x = new int [1], origin_y = new int [1];
- boolean fromIsSubshell = from instanceof Shell && from.getParent() != null;
- if (fromIsSubshell) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434772
- OS.gtk_window_get_position (((Shell) from).shellHandle, origin_x, origin_y);
- } else {
- long /*int*/ window = from.eventWindow ();
- OS.gdk_window_get_origin (window, origin_x, origin_y);
- if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = from.getClientWidth() - rect.x;
- }
- rect.x += origin_x [0];
- rect.y += origin_y [0];
+ Point origin = from.getWindowOrigin ();
+ if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = from.getClientWidth () - rect.x;
+ rect.x += origin.x;
+ rect.y += origin.y;
}
if (to != null) {
- int [] origin_x = new int [1], origin_y = new int [1];
- boolean toIsSubshell = to instanceof Shell && to.getParent() != null;
- if (toIsSubshell) { // workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=434772
- OS.gtk_window_get_position (((Shell) to).shellHandle, origin_x, origin_y);
- } else {
- long /*int*/ window = to.eventWindow ();
- OS.gdk_window_get_origin (window, origin_x, origin_y);
- }
- rect.x -= origin_x [0];
- rect.y -= origin_y [0];
- if (!toIsSubshell) {
- if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = to.getClientWidth () - rect.x;
- }
+ Point origin = to.getWindowOrigin ();
+ rect.x -= origin.x;
+ rect.y -= origin.y;
+ if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = to.getClientWidth () - rect.x;
}
if (fromRTL != toRTL) rect.x -= rect.width;
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 b5f235d9e1..947e67c643 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -2701,5 +2701,14 @@ void setToolTipText (long /*int*/ rootWidget, long /*int*/ tipWidget, String str
}
}
+@Override
+Point getWindowOrigin () {
+ /*
+ * Need to overide this since the handle attribute will not be intialized
+ * if the shell is not made visible. So need to get the location from the shell handle
+ * getLocation() method in shell will provide us the location of the control
+ */
+ return getLocation();
+}
}

Back to the top