aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2014-08-04 09:16:51 (EDT)
committerArun Thondapu2014-08-06 05:55:24 (EDT)
commit3d649bface4c6ff0c9af55d005bd7a2726420174 (patch)
tree3bc9ec1a925d140b49dcf76b7f843988c3810584
parent7430285b3a6fae4ee743c775c7760d6dfdd786e8 (diff)
downloadeclipse.platform.swt-3d649bface4c6ff0c9af55d005bd7a2726420174.zip
eclipse.platform.swt-3d649bface4c6ff0c9af55d005bd7a2726420174.tar.gz
eclipse.platform.swt-3d649bface4c6ff0c9af55d005bd7a2726420174.tar.bz2
Bug 434772 - Coordinate mapping is inconsistent between platformsrefs/changes/33/31033/3
Change-Id: Id089df3b8e081a6743459ccc5bb9136aaa7bf1d8 Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-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 045c011..aa42217 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 a3cfacf..635a09d 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
@@ -3044,32 +3044,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;
}
@@ -3185,32 +3169,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 bca5915..4ea0167 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();
+}
}