Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Pun2017-04-04 16:04:20 +0000
committerLeo Ufimtsev2017-04-04 23:35:54 +0000
commit9dc0136dddbf36d56a54a14430749427e4bd5a81 (patch)
treeb84409b41eb31f9953f51477435a4faf15b8b38f
parentc9638870aad9c83e38f8a6825bee806214995a2a (diff)
downloadeclipse.platform.swt-9dc0136dddbf36d56a54a14430749427e4bd5a81.tar.gz
eclipse.platform.swt-9dc0136dddbf36d56a54a14430749427e4bd5a81.tar.xz
eclipse.platform.swt-9dc0136dddbf36d56a54a14430749427e4bd5a81.zip
Bug 510446 [wayland] StyledText DnD not signalling, move drag detectionI20170404-2000
to mouse_move revert styledtext changes, but keep remainder of DnD to keep everything else working in x11/wayland (except for styledText). Change-Id: I4420c9ec5ff49d8a2c12d3c28dd463dca06c444b Signed-off-by: Ian Pun <ipun@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java77
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java9
6 files changed, 35 insertions, 100 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 599fbea6bb..b601f841f5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -171,11 +171,6 @@ public class StyledText extends Canvas {
int blockXAnchor = -1, blockYAnchor = -1;
int blockXLocation = -1, blockYLocation = -1;
- /**
- * GTK specific DnD variables
- */
- boolean blockSelected, movingSelection, isDragDetecting;
-
final static boolean IS_MAC, IS_GTK;
static {
String platform = SWT.getPlatform();
@@ -1994,9 +1989,6 @@ boolean checkDragDetect(Event event) {
return dragDetect(event);
}
} else {
- if (IS_GTK && isInSelection(event)) {
- return dragDetect(event);
- }
if (selection.x == selection.y) return false;
int offset = getOffsetAtPoint(event.x, event.y, null, true);
if (selection.x <= offset && offset < selection.y) {
@@ -2007,18 +1999,6 @@ boolean checkDragDetect(Event event) {
return false;
}
-private boolean checkDragDetectOnMove(Event event) {
- if (!isListening(SWT.DragDetect)) return false;
- if (blockSelection && blockXLocation != -1) {
- Rectangle rect = getBlockSelectionRectangle();
- if (rect.contains(event.x, event.y)) {
- return dragDetect(event);
- }
- } else {
- return dragDetect(event);
- }
- return false;
-}
/**
* Creates default key bindings.
*/
@@ -6097,7 +6077,7 @@ void handleMouseDown(Event event) {
forceFocus();
//drag detect
- if (!IS_GTK && dragDetect && checkDragDetect(event)) return;
+ if (dragDetect && checkDragDetect(event)) return;
//paste clipboard selection
if (event.button == 2) {
@@ -6120,14 +6100,6 @@ void handleMouseDown(Event event) {
}
clickCount = event.count;
if (clickCount == 1) {
- if (IS_GTK) {
- if (isInSelection(event)) {
- blockSelected = true;
- return;
- } else {
- movingSelection = true;
- }
- }
boolean select = (event.stateMask & SWT.MOD2) != 0;
doMouseLocationChange(event.x, event.y, select);
} else {
@@ -6168,26 +6140,7 @@ void handleMouseMove(Event event) {
if (clickCount > 0) {
update();
doAutoScroll(event);
- /* Bug 503431: Handle drag detection within mouse move instead
- * of mouse click. We are setting the event.button to 1 because
- * mouse movement events do not keep mouse status information
- * (whether you move the mouse or you hold a button while moving)
- * which is needed for DnD detection.
- */
- if (IS_GTK) {
- if (dragDetect && isInSelection(event) && !movingSelection) {
- event.button = 1;
- event.count = clickCount;
- checkDragDetectOnMove(event);
- isDragDetecting = true;
- return;
- }
- if (!isDragDetecting) {
- doMouseLocationChange(event.x, event.y, true);
- }
- } else {
- doMouseLocationChange(event.x, event.y, true);
- }
+ doMouseLocationChange(event.x, event.y, true);
}
if (renderer.hasLinks) {
doMouseLinkCursor(event.x, event.y);
@@ -6198,23 +6151,10 @@ void handleMouseMove(Event event) {
*/
void handleMouseUp(Event event) {
clickCount = 0;
- movingSelection = false;
endAutoScroll();
if (event.button == 1) {
copySelection(DND.SELECTION_CLIPBOARD);
}
- // set cursor position on release. Related to Bug 503431.
- if (IS_GTK) {
- if (blockSelected) {
- if (!isDragDetecting) {
- Point caretPosition = defaultCaret.getLocation();
- doMouseLocationChange(caretPosition.x, caretPosition.y, false);
- } else {
- isDragDetecting = false;
- }
- blockSelected = false;
- }
- }
}
/**
* Renders the invalidated area specified in the paint event.
@@ -7363,19 +7303,6 @@ boolean isSingleLine() {
}
/**
- * Returns whether the current mouse click is in side a selected area
- *
- * @return true if the mouse click event position is inside the
- * selected area.
- */
-private boolean isInSelection(Event event) {
- if (selection.x == selection.y) return false;
- int offset = getOffsetAtPoint(event.x, event.y, null, true);
- if (selection.x <= offset && offset < selection.y) return true;
- return false;
-}
-
-/**
* Sends the specified verify event, replace/insert text as defined by
* the event and send a modify event.
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
index c6c2be5bf8..f4299e2ee9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
@@ -346,7 +346,7 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){
*/
if (OS.GTK3) {
action = OS.gdk_drag_context_get_selected_action(context);
- if (OS.GTK_VERSION < OS.VERSION(3, 14, 0)) {
+ if (OS.isX11()) { // Wayland
dest_window = OS.gdk_drag_context_get_dest_window(context);
}
} else {
@@ -355,7 +355,7 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){
dest_window = gdkDragContext.dest_window;
action = gdkDragContext.action;
}
- if (dest_window != 0 || OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) { //NOTE: if dest_window is 0, drag was aborted
+ if (dest_window != 0 || !OS.isX11()) { // Wayland. NOTE: if dest_window is 0, drag was aborted
if (moveData) {
operation = DND.DROP_MOVE;
} else {
@@ -371,7 +371,7 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){
event.detail = operation;
notifyListeners(DND.DragEnd, event);
- if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
+ if (!OS.isX11()) { // Wayland
/*
* Feature in GTK: release events are not signaled during the dragEnd phrase of a Drag and Drop
* in Wayland. In order to work with the current logic for DnD in multiselection
@@ -384,11 +384,11 @@ void dragEnd(long /*int*/ widget, long /*int*/ context){
long /*int*/ selection = OS.gtk_tree_view_get_selection (widget);
OS.gtk_tree_selection_set_select_function(selection,0,0,0);
}
-
- /*
+
+ /*
* send a mouse Up signal for >GTK3.14 as Wayland (support as of 3.14)
* does not trigger a MouseUp/Mouse_release_event on DragEnd.
- * See Bug 510446.
+ * See Bug 510446.
*/
control.notifyListeners(SWT.MouseUp, event);
}
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 227d46f537..90134bfd8d 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
@@ -2501,7 +2501,7 @@ boolean dragDetect (int button, int count, int stateMask, int x, int y) {
* Bug 503431: Some applications use CTabFolder that isn't handling DND
* correctly in this condition.
*/
- if (OS.GTK_VERSION < OS.VERSION(3, 14, 0) && !dragDetect (x, y, false, true, null)) {
+ if (OS.isX11() && !dragDetect (x, y, false, true, null)) { // Not Wayland
return false;
}
return sendDragEvent (button, stateMask, x, y, true);
@@ -2514,7 +2514,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
* as of GTK3.14 in order to acquire mouse position offsets to decide on dragging.
* See Bug 503431.
*/
- if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
+ if (!OS.isX11()) { // Wayland
double [] offsetX = new double[1];
double [] offsetY = new double [1];
double [] startX = new double[1];
@@ -2530,7 +2530,6 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
}
} else {
boolean quit = false;
-
//428852 DND workaround for GTk3.
//Gtk3 no longer sends motion events on the same control during thread sleep
//before a drag started. This is due to underlying gdk changes.
@@ -3238,9 +3237,9 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event, bo
}
/*
* Feature in GTK: DND detection for X.11 & Wayland support is done through motion notify event
- * instead of mouse click event as of GTK3.14. See Bug 503431.
+ * instead of mouse click event. See Bug 503431.
*/
- if (OS.GTK_VERSION < OS.VERSION (3, 14, 0)) {
+ if (OS.isX11()) { // Wayland
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) {
if (gdkEvent.button == 1) {
boolean [] consume = new boolean [1];
@@ -3258,9 +3257,9 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event, bo
if (isDisposed ()) return 1;
/*
* Feature in GTK: DND detection for X.11 & Wayland support is done through motion notify event
- * instead of mouse click event as of GTK3.14. See Bug 503431.
+ * instead of mouse click event. See Bug 503431.
*/
- if (OS.GTK_VERSION < OS.VERSION (3, 14, 0)) {
+ if (OS.isX11()) { // Wayland
if (dragging) {
sendDragEvent (gdkEvent.button, gdkEvent.state, (int) gdkEvent.x, (int) gdkEvent.y, false);
if (isDisposed ()) return 1;
@@ -3583,9 +3582,9 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) {
OS.memmove (gdkEvent, event, GdkEventMotion.sizeof);
/*
* Feature in GTK: DND detection for X.11 & Wayland support is done through motion notify event
- * instead of mouse click event as of GTK3.14. See Bug 503431.
+ * instead of mouse click event. See Bug 503431.
*/
- if (OS.GTK_VERSION >= OS.VERSION (3, 14, 0)) {
+ if (!OS.isX11()) { // Wayland
boolean dragging = false;
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) {
boolean [] consume = new boolean [1];
@@ -4601,7 +4600,7 @@ void setCursor (long /*int*/ cursor) {
long /*int*/ window = eventWindow ();
if (window != 0) {
OS.gdk_window_set_cursor (window, cursor);
- if (!OS.isX11()) {
+ if (!OS.isX11()) { // Wayland
OS.gdk_flush ();
} else {
long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default());
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index c987ebba42..1d784afe67 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -398,7 +398,7 @@ public void deselectAll () {
@Override
boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) {
boolean selected = false;
- if (OS.GTK_VERSION < OS.VERSION(3, 14, 0)) {
+ if (OS.isX11()) { //Wayland
if (filter) {
long /*int*/ [] path = new long /*int*/ [1];
if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
@@ -411,6 +411,9 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
return false;
}
}
+ boolean dragDetect = super.dragDetect (x, y, filter, false, consume);
+ if (dragDetect && selected && consume != null) consume [0] = true;
+ return dragDetect;
} else {
double [] startX = new double[1];
double [] startY = new double [1];
@@ -831,7 +834,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) &&
- OS.GTK_VERSION >= OS.VERSION(3,14,0) && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+ !OS.isX11() && gdkEvent.type == OS.GDK_BUTTON_PRESS) { // Wayland
// check to see if there is another event coming in that is not a double/triple click, this is to prevent Bug 514531
long /*int*/ nextEvent = OS.gdk_event_peek ();
if (nextEvent == 0) {
@@ -931,7 +934,7 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event)
* selected, we can give the DnD handling to MOTION-NOTIFY. On release, we can then re-enable the selection method
* and also select the item in the tree by moving the selection logic to release instead. See Bug 503431.
*/
- if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) && OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
+ if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) && !OS.isX11()) { // Wayland
long /*int*/ [] path = new long /*int*/ [1];
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
// free up the selection function on release.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index a3d52871f9..954167d1bb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -1112,7 +1112,7 @@ void destroyItem (TableItem item) {
@Override
boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) {
boolean selected = false;
- if (OS.GTK_VERSION < OS.VERSION(3, 14, 0)) {
+ if (OS.isX11()) { // Wayland
if (filter) {
long /*int*/ [] path = new long /*int*/ [1];
if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
@@ -1125,6 +1125,9 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
return false;
}
}
+ boolean dragDetect = super.dragDetect (x, y, filter, false, consume);
+ if (dragDetect && selected && consume != null) consume [0] = true;
+ return dragDetect;
} else {
double [] startX = new double[1];
double [] startY = new double [1];
@@ -2007,7 +2010,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
* selected, we can give the DnD handling to MOTION-NOTIFY. Seee Bug 503431
*/
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) &&
- OS.GTK_VERSION >= OS.VERSION(3,14,0) && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+ !OS.isX11() && gdkEvent.type == OS.GDK_BUTTON_PRESS) { // Wayland
// check to see if there is another event coming in that is not a double/triple click, this is to prevent Bug 514531
long /*int*/ nextEvent = OS.gdk_event_peek ();
if (nextEvent == 0) {
@@ -2141,7 +2144,7 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event)
* selected, we can give the DnD handling to MOTION-NOTIFY. On release, we can then re-enable the selection method
* and also select the item in the tree by moving the selection logic to release instead. See Bug 503431.
*/
- if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) && OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
+ if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) && !OS.isX11()) { // Wayland
long /*int*/ [] path = new long /*int*/ [1];
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
// free up the selection function on release.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 10e82957cd..0e22dffdef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -1110,7 +1110,7 @@ void destroyItem (TreeItem item) {
@Override
boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) {
boolean selected = false;
- if (OS.GTK_VERSION < OS.VERSION(3, 14, 0)) {
+ if (OS.isX11()) { // Wayland
if (filter) {
long /*int*/ [] path = new long /*int*/ [1];
if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
@@ -1123,6 +1123,9 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
return false;
}
}
+ boolean dragDetect = super.dragDetect (x, y, filter, false, consume);
+ if (dragDetect && selected && consume != null) consume [0] = true;
+ return dragDetect;
} else {
double [] startX = new double[1];
double [] startY = new double [1];
@@ -2042,7 +2045,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
* selected, we can give the DnD handling to MOTION-NOTIFY. Seee Bug 503431
*/
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) &&
- OS.GTK_VERSION >= OS.VERSION(3,14,0) && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+ !OS.isX11() && gdkEvent.type == OS.GDK_BUTTON_PRESS) { // Wayland
// check to see if there is another event coming in that is not a double/triple click, this is to prevent Bug 514531
long /*int*/ nextEvent = OS.gdk_event_peek ();
if (nextEvent == 0) {
@@ -2175,7 +2178,7 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event)
* selected, we can give the DnD handling to MOTION-NOTIFY. On release, we can then re-enable the selection method
* and also select the item in the tree by moving the selection logic to release instead. See Bug 503431.
*/
- if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) && OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
+ if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) && !OS.isX11()) { //Wayland
long /*int*/ [] path = new long /*int*/ [1];
long /*int*/ selection = OS.gtk_tree_view_get_selection (handle);
// free up the selection function on release.

Back to the top