diff options
author | Alexander Kurtakov | 2018-08-22 15:22:35 +0000 |
---|---|---|
committer | Eric Williams | 2018-08-24 14:04:04 +0000 |
commit | d8772ff696a4bb41625e7b7e0282697146c213f8 (patch) | |
tree | 9f2ff0e7bc2d43f8114a903d642164e86c6a49f9 | |
parent | e352f348c21c994af3ec8aeea61baa2466d79984 (diff) | |
download | eclipse.platform.swt-d8772ff696a4bb41625e7b7e0282697146c213f8.tar.gz eclipse.platform.swt-d8772ff696a4bb41625e7b7e0282697146c213f8.tar.xz eclipse.platform.swt-d8772ff696a4bb41625e7b7e0282697146c213f8.zip |
Revert "Revert "Bug 518414 - [gtk] Package explorer double click opens currently selected (highlighted) resource""
This reverts commit c6e37ef2ef76ca1acb81b99cc5b292749901055b.
Change-Id: Ib47c7b77433cad1b10ecaf537d7aded9cc6b17f1
4 files changed, 74 insertions, 25 deletions
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 595ea124dd..86da9b8b8e 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 @@ -49,6 +49,7 @@ public class List extends Scrollable { static final int TEXT_COLUMN = 0; double cachedAdjustment, currentAdjustment; + boolean rowActivated; /** * Constructs a new instance of this class given its parent @@ -907,14 +908,27 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) { } } - //If Mouse double-click pressed, manually send a DefaultSelection. See Bug 312568. - if (gdkEvent.type == GDK.GDK_2BUTTON_PRESS) { + /* + * Bug 312568: If mouse double-click pressed, manually send a DefaultSelection. + * Bug 518414: Added rowActivated guard flag to only send a DefaultSelection when the + * double-click triggers a 'row-activated' signal. Note that this relies on the fact + * that 'row-activated' signal comes before double-click event. This prevents + * opening of the current highlighted item when double clicking on any expander arrow. + */ + if (gdkEvent.type == GDK.GDK_2BUTTON_PRESS && rowActivated) { sendTreeDefaultSelection (); + rowActivated = false; } return result; } +@Override +long /*int*/ gtk_row_activated (long /*int*/ tree, long /*int*/ path, long /*int*/ column) { + rowActivated = true; + return 0; +} + @Override long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) { @@ -977,19 +991,20 @@ void keyPressDefaultSelectionHandler (long /*int*/ event, int key) { } } -//Used to emulate DefaultSelection event. See Bug 312568. -//Feature in GTK. 'row-activation' event comes before DoubleClick event. -//This is causing the editor not to get focus after doubleclick. -//The solution is to manually send the DefaultSelection event after a doubleclick, -//and to emulate it for Space/Return. +/** + * Used to emulate DefaultSelection event. See Bug 312568. + * Feature in GTK. 'row-activation' event comes before DoubleClick event. + * This is causing the editor not to get focus after double-click. + * The solution is to manually send the DefaultSelection event after a double-click, + * and to emulate it for Space/Return. + */ void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree Event event = new Event (); event.index = this.getFocusIndex (); - if (event.index >= 0) - event.text = this.getItem (event.index); + if (event.index >= 0) event.text = this.getItem (event.index); sendSelectionEvent (SWT.DefaultSelection, event, false); } 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 5db25e2a0a..8c9a3920b8 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 @@ -94,6 +94,7 @@ public class Table extends Composite { double cachedAdjustment, currentAdjustment; int pixbufHeight, pixbufWidth; boolean boundsChangedSinceLastDraw; + boolean rowActivated; static final int CHECKED_COLUMN = 0; static final int GRAYED_COLUMN = 1; @@ -2140,15 +2141,29 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) { } } - //If Mouse double-click pressed, manually send a DefaultSelection. See Bug 312568. - if (gdkEvent.type == GDK.GDK_2BUTTON_PRESS) { + /* + * Bug 312568: If mouse double-click pressed, manually send a DefaultSelection. + * Bug 518414: Added rowActivated guard flag to only send a DefaultSelection when the + * double-click triggers a 'row-activated' signal. Note that this relies on the fact + * that 'row-activated' signal comes before double-click event. This prevents + * opening of the current highlighted item when double clicking on any expander arrow. + */ + if (gdkEvent.type == GDK.GDK_2BUTTON_PRESS && rowActivated) { sendTreeDefaultSelection (); + rowActivated = false; } return result; } @Override +long /*int*/ gtk_row_activated (long /*int*/ tree, long /*int*/ path, long /*int*/ column) { + rowActivated = true; + return 0; +} + + +@Override long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) { GdkEventKey keyEvent = new GdkEventKey (); OS.memmove (keyEvent, event, GdkEventKey.sizeof); @@ -2176,11 +2191,13 @@ void keyPressDefaultSelectionHandler (long /*int*/ event, int key) { } } -//Used to emulate DefaultSelection event. See Bug 312568. -//Feature in GTK. 'row-activation' event comes before DoubleClick event. -//This is causing the editor not to get focus after doubleclick. -//The solution is to manually send the DefaultSelection event after a doubleclick, -//and to emulate it for Space/Return. +/** + * Used to emulate DefaultSelection event. See Bug 312568. + * Feature in GTK. 'row-activation' event comes before DoubleClick event. + * This is causing the editor not to get focus after double-click. + * The solution is to manually send the DefaultSelection event after a double-click, + * and to emulate it for Space/Return. + */ void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree 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 2189f7b081..1963655daf 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 @@ -101,6 +101,7 @@ public class Tree extends Composite { Color headerBackground, headerForeground; String headerCSSBackground, headerCSSForeground; boolean boundsChangedSinceLastDraw; + boolean rowActivated; static final int ID_COLUMN = 0; static final int CHECKED_COLUMN = 1; @@ -2177,15 +2178,28 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) { } } - //If Mouse double-click pressed, manually send a DefaultSelection. See Bug 312568. - if (gdkEvent.type == GDK.GDK_2BUTTON_PRESS) { + /* + * Bug 312568: If mouse double-click pressed, manually send a DefaultSelection. + * Bug 518414: Added rowActivated guard flag to only send a DefaultSelection when the + * double-click triggers a 'row-activated' signal. Note that this relies on the fact + * that 'row-activated' signal comes before double-click event. This prevents + * opening of the current highlighted item when double clicking on any expander arrow. + */ + if (gdkEvent.type == GDK.GDK_2BUTTON_PRESS && rowActivated) { sendTreeDefaultSelection (); + rowActivated = false; } return result; } @Override +long /*int*/ gtk_row_activated (long /*int*/ tree, long /*int*/ path, long /*int*/ column) { + rowActivated = true; + return 0; +} + +@Override long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) { GdkEventKey keyEvent = new GdkEventKey (); OS.memmove (keyEvent, event, GdkEventKey.sizeof); @@ -2213,11 +2227,13 @@ void keyPressDefaultSelectionHandler (long /*int*/ event, int key) { } } -//Used to emulate DefaultSelection event. See Bug 312568. -//Feature in GTK. 'row-activation' event comes before DoubleClick event. -//This is causing the editor not to get focus after doubleclick. -//The solution is to manually send the DefaultSelection event after a doubleclick, -//and to emulate it for Space/Return. +/** + * Used to emulate DefaultSelection event. See Bug 312568. + * Feature in GTK. 'row-activation' event comes before DoubleClick event. + * This is causing the editor not to get focus after double-click. + * The solution is to manually send the DefaultSelection event after a double-click, + * and to emulate it for Space/Return. + */ void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java index d2b568f675..11946f58c6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java @@ -864,8 +864,9 @@ long /*int*/ gtk_realize (long /*int*/ widget) { long /*int*/ gtk_row_activated (long /*int*/ tree, long /*int*/ path, long /*int*/ column) { return 0; - //Note on SWT Tree/Table/List. This signal is no longer used. Instead SendDefaultSelection is - //Manually emitted. See Bug 312568. + // Note on SWT Tree/Table/List. This signal is no longer used for sending events, instead + // Send DefaultSelection is manually emitted. We use this function to know whether a + // 'row-activated' is triggered. See Bug 312568, 518414. } long /*int*/ gtk_row_deleted (long /*int*/ model, long /*int*/ path) { |