Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2019-02-24 14:56:53 +0000
committerAndrey Loskutov2019-02-24 15:42:15 +0000
commitaf1739f0a419f059708841f6526b19d89e01bd59 (patch)
tree8691bb197f2ef9eba22442084fc61e6198d6f955
parentfc92d596be590fa40e39a54d5dc762fc8b53869a (diff)
downloadeclipse.platform.ui-af1739f0a419f059708841f6526b19d89e01bd59.tar.gz
eclipse.platform.ui-af1739f0a419f059708841f6526b19d89e01bd59.tar.xz
eclipse.platform.ui-af1739f0a419f059708841f6526b19d89e01bd59.zip
Bug 532464 - Opening a new window destroys/blocks tab dragging in firstY20190225-0415I20190226-0600I20190225-1800I20190225-0600I20190225-0200I20190224-1800
window Fixed search order for the control search. The active shell should be checked first, otherwise the findControl() could find "visible" widgets from shells which are overlapped with the active one. Reduced visibility of findControl() methods to avoid cases clients search for controls in a wrong order. The org.eclipse.e4.ui.workbench.addons.dndaddon package is not API, so should be OK to do so. Change-Id: Ia7e4f48f76cc043a6e905e892745ae13e141c18b Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DragAndDropUtil.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DragAndDropUtil.java b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DragAndDropUtil.java
index 6df4b0e9326..e2b66b22312 100644
--- a/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DragAndDropUtil.java
+++ b/bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/DragAndDropUtil.java
@@ -55,11 +55,35 @@ class DragAndDropUtil {
*/
public static Control findControl(Display displayToSearch, Point locationToFind) {
Shell[] shells = displayToSearch.getShells();
-
+ fixShellOrder(displayToSearch, shells);
return findControl(shells, locationToFind);
}
/**
+ * Finds the active shell and moves it to the end of the given array, so that
+ * findControl() will find the controls from the active shell first.
+ */
+ private static void fixShellOrder(Display display, Shell[] shells) {
+ if (shells.length <= 1) {
+ return;
+ }
+ Shell activeShell = display.getActiveShell();
+ int lastIndex = shells.length - 1;
+ if (activeShell == null || shells[lastIndex] == activeShell) {
+ return;
+ }
+ // Find the index of the active shell and exchange last one with active
+ for (int i = 0; i < shells.length; i++) {
+ if (shells[i] == activeShell) {
+ Shell toMove = shells[lastIndex];
+ shells[i] = toMove;
+ shells[lastIndex] = activeShell;
+ break;
+ }
+ }
+ }
+
+ /**
* Searches the given list of controls for a control containing the given
* point. If the array contains any composites, those composites will be
* recursively searched to find the most specific child that contains the
@@ -73,7 +97,7 @@ class DragAndDropUtil {
* @return the most specific Control that overlaps the given point, or null
* if none
*/
- public static Control findControl(Control[] toSearch, Point locationToFind) {
+ private static Control findControl(Control[] toSearch, Point locationToFind) {
for (int idx = toSearch.length - 1; idx >= 0; idx--) {
Control next = toSearch[idx];
@@ -111,7 +135,7 @@ class DragAndDropUtil {
* location (in display coordinates)
* @return the control at the given location
*/
- public static Control findControl(Composite toSearch, Point locationToFind) {
+ private static Control findControl(Composite toSearch, Point locationToFind) {
Control[] children = toSearch.getChildren();
return findControl(children, locationToFind);

Back to the top