diff options
author | Niraj Modi | 2014-05-21 18:08:07 +0000 |
---|---|---|
committer | Niraj Modi | 2014-05-21 18:08:07 +0000 |
commit | 20a78c3f41cf33cd567a5e2c6f2e5b079601072a (patch) | |
tree | 02cde6fd1a6d5b99e42d9536cb46c7658067cbec | |
parent | 0fc715ad3225dc7b91ceef95969ce79b13bc7afe (diff) | |
download | eclipse.platform.swt-20a78c3f41cf33cd567a5e2c6f2e5b079601072a.tar.gz eclipse.platform.swt-20a78c3f41cf33cd567a5e2c6f2e5b079601072a.tar.xz eclipse.platform.swt-20a78c3f41cf33cd567a5e2c6f2e5b079601072a.zip |
Bug 434772 - Coordinate mapping is inconsistent between platformsv4426hI20140521-2000
Change-Id: I6ed67a61010d1f4881dda5b365472d4ce499e0a0
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | 49 |
1 files changed, 37 insertions, 12 deletions
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 1909073ba7..15e9b57fb7 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,20 +3044,32 @@ 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) { - long /*int*/ window = from.eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - OS.gdk_window_get_origin (window, origin_x, origin_y); - if ((from.style & SWT.MIRRORED) != 0) point.x = from.getClientWidth () - point.x; + 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]; } if (to != null) { - long /*int*/ window = to.eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - OS.gdk_window_get_origin (window, origin_x, origin_y); + 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 ((to.style & SWT.MIRRORED) != 0) point.x = to.getClientWidth () - point.x; + if (!toIsSubshell) { + if ((to.style & SWT.MIRRORED) != 0) point.x = to.getClientWidth () - point.x; + } } return point; } @@ -3173,21 +3185,34 @@ 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) { - long /*int*/ window = from.eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - OS.gdk_window_get_origin (window, origin_x, origin_y); - if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = from.getClientWidth() - rect.x; + 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]; } if (to != null) { - long /*int*/ window = to.eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; - OS.gdk_window_get_origin (window, origin_x, origin_y); + 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 (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = to.getClientWidth () - rect.x; + if (!toIsSubshell) { + if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = to.getClientWidth () - rect.x; + } } + if (fromRTL != toRTL) rect.x -= rect.width; return rect; } |