Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2019-01-31 15:17:10 -0500
committerXi Yan2019-01-31 15:17:10 -0500
commitecf521c3d6bf4f8734858eb1d2b7d39de0a0ad17 (patch)
tree7ce515bbd5b783ba1f4c3f15833e6aed2b168031
parent2f5a98b4cbd50b436a5ffad0a1d5949f3b9a1b18 (diff)
downloadeclipse.platform.swt-ecf521c3d6bf4f8734858eb1d2b7d39de0a0ad17.tar.gz
eclipse.platform.swt-ecf521c3d6bf4f8734858eb1d2b7d39de0a0ad17.tar.xz
eclipse.platform.swt-ecf521c3d6bf4f8734858eb1d2b7d39de0a0ad17.zip
Revert "Bug 543984 - [GTK4] Adapt to GdkEventType constants changes"
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java79
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java210
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java51
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java99
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java66
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java34
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug543984_GTK4EventTypeConstants.java66
18 files changed, 300 insertions, 518 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
index 564f80db17..a819889460 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
@@ -41,11 +41,14 @@ public class GDK extends OS {
public static final int GDK_BUTTON2_MOTION_MASK = 1 << 6;
public static final int GDK_BUTTON3_MOTION_MASK = 1 << 7;
public static final int GDK_BUTTON_PRESS = 0x4;
+ public static final int GDK4_BUTTON_PRESS = 0x5;
public static final int GDK_BUTTON_PRESS_MASK = 0x100;
public static final int GDK_BUTTON_RELEASE = 0x7;
+ public static final int GDK4_BUTTON_RELEASE = 0x6;
public static final int GDK_BUTTON_RELEASE_MASK = 0x200;
public static final int GDK_COLORSPACE_RGB = 0;
public static final int GDK_CONFIGURE = 13;
+ public static final int GDK4_CONFIGURE = 12;
public static final int GDK_CONTROL_MASK = 0x4;
public static final int GDK_CROSS = 0x1e;
public static final int GDK_CROSSING_NORMAL = 0;
@@ -257,20 +260,6 @@ public class GDK extends OS {
public static final int GDK_WINDOW_TYPE_HINT_UTILITY = 5;
public static final int GDK_WINDOW_TYPE_HINT_TOOLTIP = 10;
- /** GdkEventType constants are different on GTK4 */
- public static final int GDK4_EXPOSE = 3;
- public static final int GDK4_MOTION_NOTIFY = 4;
- public static final int GDK4_BUTTON_PRESS = 5;
- public static final int GDK4_BUTTON_RELEASE = 6;
- public static final int GDK4_KEY_PRESS = 7;
- public static final int GDK4_KEY_RELEASE = 8;
- public static final int GDK4_ENTER_NOTIFY = 9;
- public static final int GDK4_LEAVE_NOTIFY = 10;
- public static final int GDK4_FOCUS_CHANGE = 11;
- public static final int GDK4_CONFIGURE = 12;
- public static final int GDK4_MAP = 13;
- public static final int GDK4_UNMAP = 14;
-
/** sizeof(TYPE) for 32/64 bit support */
public static final native int GdkKeymapKey_sizeof();
public static final native int GdkRGBA_sizeof();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index d859b6a5c2..8e21524239 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -1329,9 +1329,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
int [] eventButton = new int [1];
GDK.gdk_event_get_button(event, eventButton);
int eventType = GDK.gdk_event_get_event_type(event);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- if ((GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS) && eventButton[0] == 1) {
+ if (eventType == GDK.GDK_BUTTON_PRESS && eventButton[0] == 1) {
return gtk_button_press_event(widget, event, false);
}
return super.gtk_button_press_event (widget, event);
@@ -1537,50 +1535,51 @@ long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
* field.
*/
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- boolean GTK4_FOCUS_CHANGE = GTK.GTK4 && eventType == GDK.GDK4_FOCUS_CHANGE;
- boolean GTK3_FOCUS_CHANGE = !GTK.GTK4 && eventType == GDK.GDK_FOCUS_CHANGE;
- if (GTK4_BUTTON_PRESS || GTK3_BUTTON_PRESS) {
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- int eventTime = GDK.gdk_event_get_time(gdkEvent);
- double [] eventRX = new double [1];
- double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
- int [] eventState = new int [1];
- GDK.gdk_event_get_state(gdkEvent, eventState);
- if (eventButton[0] == 1) {
- if (!sendMouseEvent (SWT.MouseDown, eventButton[0], display.clickCount, 0, false, eventTime, eventRX[0], eventRY[0], false, eventState[0])) {
- return 1;
- }
- if ((style & SWT.READ_ONLY) == 0 && widget == buttonHandle) {
- GTK.gtk_widget_grab_focus (entryHandle);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_PRESS: {
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ int eventTime = GDK.gdk_event_get_time(gdkEvent);
+ double [] eventRX = new double [1];
+ double [] eventRY = new double [1];
+ GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
+ int [] eventState = new int [1];
+ GDK.gdk_event_get_state(gdkEvent, eventState);
+ if (eventButton[0] == 1) {
+ if (!sendMouseEvent (SWT.MouseDown, eventButton[0], display.clickCount, 0, false, eventTime, eventRX[0], eventRY[0], false, eventState[0])) {
+ return 1;
+ }
+ if ((style & SWT.READ_ONLY) == 0 && widget == buttonHandle) {
+ GTK.gtk_widget_grab_focus (entryHandle);
+ }
}
+ break;
}
- } else if (GTK4_FOCUS_CHANGE || GTK3_FOCUS_CHANGE) {
- if ((style & SWT.READ_ONLY) == 0) {
- boolean [] focusIn = new boolean [1];
- if (GTK.GTK4) {
- GDK.gdk_event_get_focus_in(gdkEvent, focusIn);
- } else {
- GdkEventFocus gdkEventFocus = new GdkEventFocus ();
- OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
- focusIn[0] = gdkEventFocus.in != 0;
- }
- if (focusIn[0]) {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
- GTK.gtk_widget_set_focus_on_click(handle, false);
+ case GDK.GDK_FOCUS_CHANGE: {
+ if ((style & SWT.READ_ONLY) == 0) {
+ boolean [] focusIn = new boolean [1];
+ if (GTK.GTK4) {
+ GDK.gdk_event_get_focus_in(gdkEvent, focusIn);
} else {
- GTK.gtk_combo_box_set_focus_on_click (handle, false);
+ GdkEventFocus gdkEventFocus = new GdkEventFocus ();
+ OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
+ focusIn[0] = gdkEventFocus.in != 0;
}
- } else {
- if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
- GTK.gtk_widget_set_focus_on_click(handle, true);
+ if (focusIn[0]) {
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
+ GTK.gtk_widget_set_focus_on_click(handle, false);
+ } else {
+ GTK.gtk_combo_box_set_focus_on_click (handle, false);
+ }
} else {
- GTK.gtk_combo_box_set_focus_on_click (handle, true);
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
+ GTK.gtk_widget_set_focus_on_click(handle, true);
+ } else {
+ GTK.gtk_combo_box_set_focus_on_click (handle, true);
+ }
}
}
+ break;
}
}
return super.gtk_event_after(widget, gdkEvent);
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 d235f6a583..5f4da94ea5 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
@@ -2711,82 +2711,47 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean
display.sendPostExternalEventDispatchEvent();
if (dragging) return true; //428852
if (eventPtr == 0) return dragOnTimeout;
- if (GTK.GTK4) {
- switch (GDK.GDK_EVENT_TYPE (eventPtr)) {
- case GDK.GDK4_MOTION_NOTIFY: {
- int [] state = new int[1];
- GDK.gdk_event_get_state(eventPtr, state);
- long /*int*/ gdkResource = gdk_event_get_surface_or_window(eventPtr);
- double [] eventX = new double[1];
- double [] eventY = new double[1];
- GDK.gdk_event_get_coords(eventPtr, eventX, eventY);
- if ((state[0] & GDK.GDK_BUTTON1_MASK) != 0) {
- if (GTK.gtk_drag_check_threshold (handle, x, y, (int) eventX[0], (int) eventY[0])) {
- dragging = true;
- quit = true;
- }
- } else {
+ switch (GDK.GDK_EVENT_TYPE (eventPtr)) {
+ case GDK.GDK_MOTION_NOTIFY: {
+ int [] state = new int[1];
+ GDK.gdk_event_get_state(eventPtr, state);
+ long /*int*/ gdkResource = gdk_event_get_surface_or_window(eventPtr);
+ double [] eventX = new double[1];
+ double [] eventY = new double[1];
+ GDK.gdk_event_get_coords(eventPtr, eventX, eventY);
+ if ((state[0] & GDK.GDK_BUTTON1_MASK) != 0) {
+ if (GTK.gtk_drag_check_threshold (handle, x, y, (int) eventX[0], (int) eventY[0])) {
+ dragging = true;
quit = true;
}
- int [] newX = new int [1], newY = new int [1];
- display.gdk_surface_get_device_position (gdkResource, newX, newY, null);
- break;
- }
- case GDK.GDK4_KEY_PRESS:
- case GDK.GDK4_KEY_RELEASE: {
- int [] eventKeyval = new int [1];
- GDK.gdk_event_get_keyval(eventPtr, eventKeyval);
- if (eventKeyval[0] == GDK.GDK_Escape) quit = true;
- break;
- }
- case GDK.GDK4_BUTTON_RELEASE:
- case GDK.GDK4_BUTTON_PRESS: {
- GDK.gdk_event_put (eventPtr);
+ } else {
quit = true;
- break;
}
- default:
- GTK.gtk_main_do_event (eventPtr);
- }
- } else {
- switch (GDK.GDK_EVENT_TYPE (eventPtr)) {
- case GDK.GDK_MOTION_NOTIFY: {
- int [] state = new int[1];
- GDK.gdk_event_get_state(eventPtr, state);
- long /*int*/ gdkResource = gdk_event_get_surface_or_window(eventPtr);
- double [] eventX = new double[1];
- double [] eventY = new double[1];
- GDK.gdk_event_get_coords(eventPtr, eventX, eventY);
- if ((state[0] & GDK.GDK_BUTTON1_MASK) != 0) {
- if (GTK.gtk_drag_check_threshold (handle, x, y, (int) eventX[0], (int) eventY[0])) {
- dragging = true;
- quit = true;
- }
- } else {
- quit = true;
- }
- int [] newX = new int [1], newY = new int [1];
+ int [] newX = new int [1], newY = new int [1];
+ if (GTK.GTK4) {
+ display.gdk_surface_get_device_position (gdkResource, newX, newY, null);
+ } else {
display.gdk_window_get_device_position (gdkResource, newX, newY, null);
- break;
- }
- case GDK.GDK_KEY_PRESS:
- case GDK.GDK_KEY_RELEASE: {
- int [] eventKeyval = new int [1];
- GDK.gdk_event_get_keyval(eventPtr, eventKeyval);
- if (eventKeyval[0] == GDK.GDK_Escape) quit = true;
- break;
}
- case GDK.GDK_BUTTON_RELEASE:
- case GDK.GDK_BUTTON_PRESS:
- case GDK.GDK_2BUTTON_PRESS:
- case GDK.GDK_3BUTTON_PRESS: {
- GDK.gdk_event_put (eventPtr);
- quit = true;
- break;
- }
- default:
- GTK.gtk_main_do_event (eventPtr);
+ break;
}
+ case GDK.GDK_KEY_PRESS:
+ case GDK.GDK_KEY_RELEASE: {
+ int [] eventKeyval = new int [1];
+ GDK.gdk_event_get_keyval(eventPtr, eventKeyval);
+ if (eventKeyval[0] == GDK.GDK_Escape) quit = true;
+ break;
+ }
+ case GDK.GDK_BUTTON_RELEASE:
+ case GDK.GDK_BUTTON_PRESS:
+ case GDK.GDK_2BUTTON_PRESS:
+ case GDK.GDK_3BUTTON_PRESS: {
+ GDK.gdk_event_put (eventPtr);
+ quit = true;
+ break;
+ }
+ default:
+ GTK.gtk_main_do_event (eventPtr);
}
GDK.gdk_event_free (eventPtr);
}
@@ -3468,7 +3433,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event, bo
shell.forceActive();
}
long /*int*/ result = 0;
- if ((GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS) || ((!GTK.GTK4) && eventType == GDK.GDK_BUTTON_PRESS)) {
+ if (eventType == GDK.GDK_BUTTON_PRESS) {
boolean dragging = false;
display.clickCount = 1;
long /*int*/ defaultDisplay = GDK.gdk_display_get_default();
@@ -3634,65 +3599,66 @@ boolean checkSubwindow () {
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- boolean GTK4_FOCUS_CHANGE = GTK.GTK4 && eventType == GDK.GDK4_FOCUS_CHANGE;
- boolean GTK3_FOCUS_CHANGE = !GTK.GTK4 && eventType == GDK.GDK_FOCUS_CHANGE;
- if (GTK4_BUTTON_PRESS || GTK3_BUTTON_PRESS) {
- if (widget != eventHandle ()) return 0;
- /*
- * Pop up the context menu in the event_after signal to allow
- * the widget to process the button press. This allows widgets
- * such as GtkTreeView to select items before a menu is shown.
- */
- if ((state & MENU) == 0) {
- double [] eventRX = new double [1];
- double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- if (eventButton[0] == 3) {
- showMenu ((int) eventRX[0], (int) eventRY[0]);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_PRESS: {
+ if (widget != eventHandle ()) break;
+ /*
+ * Pop up the context menu in the event_after signal to allow
+ * the widget to process the button press. This allows widgets
+ * such as GtkTreeView to select items before a menu is shown.
+ */
+ if ((state & MENU) == 0) {
+ double [] eventRX = new double [1];
+ double [] eventRY = new double [1];
+ GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ if (eventButton[0] == 3) {
+ showMenu ((int) eventRX[0], (int) eventRY[0]);
+ }
}
+ break;
}
- } else if (GTK4_FOCUS_CHANGE || GTK3_FOCUS_CHANGE) {
- if (!isFocusHandle (widget)) return 0;
- boolean [] focusIn = new boolean [1];
- if (GTK.GTK4) {
- GDK.gdk_event_get_focus_in(gdkEvent, focusIn);
- } else {
- GdkEventFocus gdkEventFocus = new GdkEventFocus ();
- OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
- focusIn[0] = gdkEventFocus.in != 0;
- }
+ case GDK.GDK_FOCUS_CHANGE: {
+ if (!isFocusHandle (widget)) break;
+ boolean [] focusIn = new boolean [1];
+ if (GTK.GTK4) {
+ GDK.gdk_event_get_focus_in(gdkEvent, focusIn);
+ } else {
+ GdkEventFocus gdkEventFocus = new GdkEventFocus ();
+ OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
+ focusIn[0] = gdkEventFocus.in != 0;
+ }
- /*
- * Feature in GTK. The GTK combo box popup under some window managers
- * is implemented as a GTK_MENU. When it pops up, it causes the combo
- * box to lose focus when focus is received for the menu. The
- * fix is to check the current grab handle and see if it is a GTK_MENU
- * and ignore the focus event when the menu is both shown and hidden.
- *
- * NOTE: This code runs for all menus.
- */
- Display display = this.display;
- if (focusIn[0]) {
- if (display.ignoreFocus) {
+ /*
+ * Feature in GTK. The GTK combo box popup under some window managers
+ * is implemented as a GTK_MENU. When it pops up, it causes the combo
+ * box to lose focus when focus is received for the menu. The
+ * fix is to check the current grab handle and see if it is a GTK_MENU
+ * and ignore the focus event when the menu is both shown and hidden.
+ *
+ * NOTE: This code runs for all menus.
+ */
+ Display display = this.display;
+ if (focusIn[0]) {
+ if (display.ignoreFocus) {
+ display.ignoreFocus = false;
+ break;
+ }
+ } else {
display.ignoreFocus = false;
- return 0;
- }
- } else {
- display.ignoreFocus = false;
- long /*int*/ grabHandle = GTK.gtk_grab_get_current ();
- if (grabHandle != 0) {
- if (OS.G_OBJECT_TYPE (grabHandle) == GTK.GTK_TYPE_MENU ()) {
- display.ignoreFocus = true;
- return 0;
+ long /*int*/ grabHandle = GTK.gtk_grab_get_current ();
+ if (grabHandle != 0) {
+ if (OS.G_OBJECT_TYPE (grabHandle) == GTK.GTK_TYPE_MENU ()) {
+ display.ignoreFocus = true;
+ break;
+ }
}
}
- }
- sendFocusEvent (focusIn[0] ? SWT.FocusIn : SWT.FocusOut);
+ sendFocusEvent (focusIn[0] ? SWT.FocusIn : SWT.FocusOut);
+ break;
+ }
}
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 4cb8f2054e..41a8950842 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -337,9 +337,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
double [] eventX = new double [1];
double [] eventY = new double [1];
GDK.gdk_event_get_coords(event, eventX, eventY);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- if (eventButton[0] == 1 && (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS)) {
+ if (eventButton[0] == 1 && eventType == GDK.GDK_BUTTON_PRESS) {
if (focusIndex != -1) setFocus ();
int x = (int) eventX[0];
int y = (int) eventY[0];
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 f0523f21d3..29f64fd599 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
@@ -804,10 +804,8 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
GDK.gdk_event_get_state(event, eventState);
int [] eventButton = new int [1];
GDK.gdk_event_get_button(event, eventButton);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) &&
- !OS.isX11() && (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS)) { // Wayland
+ !OS.isX11() && eventType == GDK.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 = GDK.gdk_event_peek ();
if (nextEvent == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index e1fba9e87c..9eb7d92f94 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -256,9 +256,9 @@ void _setVisible (boolean visible) {
if (ableToSetLocation()) {
// Create the GdkEvent manually as we need to control
// certain fields like the event window
- eventPtr = GDK.gdk_event_new(GTK.GTK4 ? GDK.GDK4_BUTTON_PRESS : GDK.GDK_BUTTON_PRESS);
+ eventPtr = GDK.gdk_event_new(GDK.GDK_BUTTON_PRESS);
GdkEventButton event = new GdkEventButton ();
- event.type = GTK.GTK4 ? GDK.GDK4_BUTTON_PRESS : GDK.GDK_BUTTON_PRESS;
+ event.type = GDK.GDK_BUTTON_PRESS;
event.device = GDK.gdk_get_pointer(GDK.gdk_display_get_default());
event.time = display.getLastEventTime();
@@ -309,9 +309,9 @@ void _setVisible (boolean visible) {
*/
eventPtr = GTK.gtk_get_current_event();
if (eventPtr == 0) {
- eventPtr = GDK.gdk_event_new(GTK.GTK4 ? GDK.GDK4_BUTTON_PRESS : GDK.GDK_BUTTON_PRESS);
+ eventPtr = GDK.gdk_event_new(GDK.GDK_BUTTON_PRESS);
GdkEventButton event = new GdkEventButton ();
- event.type = GTK.GTK4 ? GDK.GDK4_BUTTON_PRESS : GDK.GDK_BUTTON_PRESS;
+ event.type = GDK.GDK_BUTTON_PRESS;
// Only assign a window on X11, as on Wayland the window is that of the mouse pointer
if (OS.isX11()) {
event.window = OS.g_object_ref(GTK.gtk_widget_get_window (getShell().handle));
@@ -1215,36 +1215,19 @@ void adjustParentWindowWayland (long /*int*/ eventPtr) {
}
OS.g_object_ref(deviceResource);
int eventType = GDK.gdk_event_get_event_type(eventPtr);
- if (GTK.GTK4) {
- switch (eventType) {
- case GDK.GDK4_BUTTON_PRESS:
- GdkEventButton eventButton = new GdkEventButton();
- OS.memmove (eventButton, eventPtr, GdkEventButton.sizeof);
- eventButton.window = deviceResource;
- OS.memmove(eventPtr, eventButton, GdkEventButton.sizeof);
- break;
- case GDK.GDK4_KEY_PRESS:
- GdkEventKey eventKey = new GdkEventKey();
- OS.memmove (eventKey, eventPtr, GdkEventKey.sizeof);
- eventKey.window = deviceResource;
- OS.memmove(eventPtr, eventKey, GdkEventKey.sizeof);
- break;
- }
- } else {
- switch (eventType) {
- case GDK.GDK_BUTTON_PRESS:
- GdkEventButton eventButton = new GdkEventButton();
- OS.memmove (eventButton, eventPtr, GdkEventButton.sizeof);
- eventButton.window = deviceResource;
- OS.memmove(eventPtr, eventButton, GdkEventButton.sizeof);
- break;
- case GDK.GDK_KEY_PRESS:
- GdkEventKey eventKey = new GdkEventKey();
- OS.memmove (eventKey, eventPtr, GdkEventKey.sizeof);
- eventKey.window = deviceResource;
- OS.memmove(eventPtr, eventKey, GdkEventKey.sizeof);
- break;
- }
+ switch (eventType) {
+ case GDK.GDK_BUTTON_PRESS:
+ GdkEventButton eventButton = new GdkEventButton();
+ OS.memmove (eventButton, eventPtr, GdkEventButton.sizeof);
+ eventButton.window = deviceResource;
+ OS.memmove(eventPtr, eventButton, GdkEventButton.sizeof);
+ break;
+ case GDK.GDK_KEY_PRESS:
+ GdkEventKey eventKey = new GdkEventKey();
+ OS.memmove (eventKey, eventPtr, GdkEventKey.sizeof);
+ eventKey.window = deviceResource;
+ OS.memmove(eventPtr, eventKey, GdkEventKey.sizeof);
+ break;
}
}
return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index f5913885dd..9bbf761d5b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -567,21 +567,22 @@ long /*int*/ gtk_value_changed (long /*int*/ adjustment) {
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_RELEASE = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_RELEASE;
- boolean GTK3_BUTTON_RELEASE = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_RELEASE;
- if (GTK4_BUTTON_RELEASE || GTK3_BUTTON_RELEASE) {
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- if (eventButton[0] == 1 && detail == GTK.GTK_SCROLL_JUMP) {
- if (!dragSent) {
- Event event = new Event ();
- event.detail = SWT.DRAG;
- sendSelectionEvent (SWT.Selection, event, false);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_RELEASE: {
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ if (eventButton[0] == 1 && detail == GTK.GTK_SCROLL_JUMP) {
+ if (!dragSent) {
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ sendSelectionEvent (SWT.Selection, event, false);
+ }
+ sendSelectionEvent (SWT.Selection);
}
- sendSelectionEvent (SWT.Selection);
+ detail = GTK.GTK_SCROLL_NONE;
+ dragSent = false;
+ break;
}
- detail = GTK.GTK_SCROLL_NONE;
- dragSent = false;
}
return super.gtk_event_after (widget, gdkEvent);
}
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 4c17c3800a..de880e81f6 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
@@ -919,9 +919,7 @@ void hookEvents () {
super.hookEvents ();
if (GTK.GTK4) {
// Replace configure-event with generic event handler
- if (eventHandle() == 0) {
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
- }
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
} else {
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [WINDOW_STATE_EVENT], 0, display.getClosure (WINDOW_STATE_EVENT), false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [CONFIGURE_EVENT], 0, display.getClosure (CONFIGURE_EVENT), false);
@@ -2676,25 +2674,15 @@ public void setVisible (boolean visible) {
}
if (isDisposed ()) return;
if (!(OS.isX11() && GTK.GTK_IS_PLUG (shellHandle))) {
- if (GTK.GTK4) {
- display.dispatchEvents = new int [] {
- GDK.GDK_EXPOSE,
- GDK.GDK_FOCUS_CHANGE,
- GDK.GDK_CONFIGURE,
- GDK.GDK_MAP,
- GDK.GDK_UNMAP,
- GDK.GDK_NO_EXPOSE,
- GDK.GDK_WINDOW_STATE
- };
- } else {
- display.dispatchEvents = new int [] {
- GDK.GDK4_EXPOSE,
- GDK.GDK4_FOCUS_CHANGE,
- GDK.GDK4_CONFIGURE,
- GDK.GDK4_MAP,
- GDK.GDK4_UNMAP,
- };
- }
+ display.dispatchEvents = new int [] {
+ GDK.GDK_EXPOSE,
+ GDK.GDK_FOCUS_CHANGE,
+ GDK.GDK_CONFIGURE,
+ GDK.GDK_MAP,
+ GDK.GDK_UNMAP,
+ GDK.GDK_NO_EXPOSE,
+ GDK.GDK_WINDOW_STATE
+ };
Display display = this.display;
display.putGdkEvents();
boolean iconic = false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
index 3e98a87b34..86f1742aa2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
@@ -224,21 +224,22 @@ long /*int*/ gtk_value_changed (long /*int*/ adjustment) {
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_RELEASE = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_RELEASE;
- boolean GTK3_BUTTON_RELEASE = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_RELEASE;
- if (GTK4_BUTTON_RELEASE || GTK3_BUTTON_RELEASE) {
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- if (eventButton[0] == 1 && detail == SWT.DRAG) {
- if (!dragSent) {
- Event event = new Event ();
- event.detail = SWT.DRAG;
- sendSelectionEvent (SWT.Selection, event, false);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_RELEASE: {
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ if (eventButton[0] == 1 && detail == SWT.DRAG) {
+ if (!dragSent) {
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ sendSelectionEvent (SWT.Selection, event, false);
+ }
+ sendSelectionEvent (SWT.Selection);
}
- sendSelectionEvent (SWT.Selection);
+ detail = GTK.GTK_SCROLL_NONE;
+ dragSent = false;
+ break;
}
- detail = GTK.GTK_SCROLL_NONE;
- dragSent = false;
}
return super.gtk_event_after (widget, gdkEvent);
}
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 3f379eac08..42aa4372ec 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
@@ -2009,10 +2009,8 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
* in GTK in the case that additional items aren't being added (CTRL_MASK or SHIFT_MASK) and the item being dragged is already
* selected, we can give the DnD handling to MOTION-NOTIFY. Seee Bug 503431
*/
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) &&
- !OS.isX11() && (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS)) { // Wayland
+ !OS.isX11() && eventType == GDK.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 = GDK.gdk_event_peek ();
if (nextEvent == 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
index f5875f6e7f..da4add2fad 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java
@@ -353,15 +353,16 @@ long /*int*/ gtk_clicked (long /*int*/ widget) {
GDK.gdk_event_get_button(eventPtr, eventButton);
int eventType = GDK.gdk_event_get_event_type(eventPtr);
int eventTime = GDK.gdk_event_get_time(eventPtr);
- boolean GTK4_BUTTON_RELEASE = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_RELEASE;
- boolean GTK3_BUTTON_RELEASE = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_RELEASE;
- if (GTK4_BUTTON_RELEASE || GTK3_BUTTON_RELEASE) {
- int clickTime = display.getDoubleClickTime ();
- if (lastButton == eventButton[0] && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
- doubleClick = true;
+ switch (eventType) {
+ case GDK.GDK_BUTTON_RELEASE: {
+ int clickTime = display.getDoubleClickTime ();
+ if (lastButton == eventButton[0] && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
+ doubleClick = true;
+ }
+ lastTime = eventTime == 0 ? 1: eventTime;
+ lastButton = eventButton[0];
+ break;
}
- lastTime = eventTime == 0 ? 1: eventTime;
- lastButton = eventButton[0];
}
gdk_event_free (eventPtr);
}
@@ -372,16 +373,17 @@ long /*int*/ gtk_clicked (long /*int*/ widget) {
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- if (GTK4_BUTTON_PRESS || GTK3_BUTTON_PRESS) {
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- if (eventButton[0] == 3) {
- double [] eventRX = new double [1];
- double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
- parent.showMenu ((int) eventRX[0], (int) eventRY[0]);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_PRESS: {
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ if (eventButton[0] == 3) {
+ double [] eventRX = new double [1];
+ double [] eventRY = new double [1];
+ GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
+ parent.showMenu ((int) eventRX[0], (int) eventRY[0]);
+ }
+ break;
}
}
return 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index df0c97b75f..15755288c6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -501,62 +501,32 @@ long /*int*/ gtk_clicked (long /*int*/ widget) {
if (eventPtr != 0) {
int eventType = GDK.gdk_event_get_event_type(eventPtr);
long /*int*/ topHandle = topHandle();
- if (GTK.GTK4) {
- switch (eventType) {
- case GDK.GDK4_KEY_RELEASE: //Fall Through..
- case GDK.GDK4_BUTTON_PRESS:
- case GDK.GDK4_BUTTON_RELEASE: {
- boolean isArrow = false;
- if (widget == arrowHandle) {
- isArrow = true;
- topHandle = widget;
- /*
- * Feature in GTK. ArrowButton stays in toggled state if there is no popup menu.
- * It is required to set back the state of arrow to normal state after it is clicked.
- */
- OS.g_signal_handlers_block_matched (widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
- GTK.gtk_toggle_button_set_active(widget, false);
- OS.g_signal_handlers_unblock_matched (widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
- }
- if (isArrow) {
- event.detail = SWT.ARROW;
- GtkAllocation allocation = new GtkAllocation ();
- GTK.gtk_widget_get_allocation (topHandle, allocation);
- event.x = DPIUtil.autoScaleDown(allocation.x);
- if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()- allocation.width) - event.x;
- event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
- }
- break;
+ switch (eventType) {
+ case GDK.GDK_KEY_RELEASE: //Fall Through..
+ case GDK.GDK_BUTTON_PRESS:
+ case GDK.GDK_2BUTTON_PRESS:
+ case GDK.GDK_BUTTON_RELEASE: {
+ boolean isArrow = false;
+ if (widget == arrowHandle) {
+ isArrow = true;
+ topHandle = widget;
+ /*
+ * Feature in GTK. ArrowButton stays in toggled state if there is no popup menu.
+ * It is required to set back the state of arrow to normal state after it is clicked.
+ */
+ OS.g_signal_handlers_block_matched (widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
+ GTK.gtk_toggle_button_set_active(widget, false);
+ OS.g_signal_handlers_unblock_matched (widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
}
- }
- } else {
- switch (eventType) {
- case GDK.GDK_KEY_RELEASE: //Fall Through..
- case GDK.GDK_BUTTON_PRESS:
- case GDK.GDK_2BUTTON_PRESS:
- case GDK.GDK_BUTTON_RELEASE: {
- boolean isArrow = false;
- if (widget == arrowHandle) {
- isArrow = true;
- topHandle = widget;
- /*
- * Feature in GTK. ArrowButton stays in toggled state if there is no popup menu.
- * It is required to set back the state of arrow to normal state after it is clicked.
- */
- OS.g_signal_handlers_block_matched (widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
- GTK.gtk_toggle_button_set_active(widget, false);
- OS.g_signal_handlers_unblock_matched (widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
- }
- if (isArrow) {
- event.detail = SWT.ARROW;
- GtkAllocation allocation = new GtkAllocation ();
- GTK.gtk_widget_get_allocation (topHandle, allocation);
- event.x = DPIUtil.autoScaleDown(allocation.x);
- if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()- allocation.width) - event.x;
- event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
- }
- break;
+ if (isArrow) {
+ event.detail = SWT.ARROW;
+ GtkAllocation allocation = new GtkAllocation ();
+ GTK.gtk_widget_get_allocation (topHandle, allocation);
+ event.x = DPIUtil.autoScaleDown(allocation.x);
+ if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()- allocation.width) - event.x;
+ event.y = DPIUtil.autoScaleDown(allocation.y + allocation.height);
}
+ break;
}
}
gdk_event_free (eventPtr);
@@ -685,16 +655,17 @@ long /*int*/ gtk_enter_notify_event (long /*int*/ widget, long /*int*/ event) {
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- if (GTK4_BUTTON_PRESS || GTK3_BUTTON_PRESS) {
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- if (eventButton[0] == 3) {
- double [] eventRX = new double [1];
- double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
- parent.showMenu ((int) eventRX[0], (int) eventRY[0]);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_PRESS: {
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ if (eventButton[0] == 3) {
+ double [] eventRX = new double [1];
+ double [] eventRY = new double [1];
+ GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
+ parent.showMenu ((int) eventRX[0], (int) eventRY[0]);
+ }
+ break;
}
}
return 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index d152a92d1e..ebc834e103 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -478,7 +478,7 @@ boolean grab () {
@Override
long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event) {
Control.mouseDown = false;
- return gtk_mouse (GTK.GTK4 ? GDK.GDK4_BUTTON_RELEASE : GDK.GDK_BUTTON_RELEASE, widget, event);
+ return gtk_mouse (GDK.GDK_BUTTON_RELEASE, widget, event);
}
@Override
@@ -625,7 +625,7 @@ long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ eventPtr
grabbed = grab ();
lastCursor = cursor;
}
- return gtk_mouse (GTK.GTK4 ? GDK.GDK4_MOTION_NOTIFY : GDK.GDK_MOTION_NOTIFY, widget, eventPtr);
+ return gtk_mouse (GDK.GDK_MOTION_NOTIFY, widget, eventPtr);
}
long /*int*/ gtk_mouse (int eventType, long /*int*/ widget, long /*int*/ eventPtr) {
@@ -736,11 +736,7 @@ long /*int*/ gtk_mouse (int eventType, long /*int*/ widget, long /*int*/ eventPt
oldX = newX [0];
oldY = newY [0];
}
- if (GTK.GTK4) {
- tracking = eventType != GDK.GDK4_BUTTON_RELEASE;
- } else {
- tracking = eventType != GDK.GDK_BUTTON_RELEASE;
- }
+ tracking = eventType != GDK.GDK_BUTTON_RELEASE;
return 0;
}
@@ -907,44 +903,24 @@ private void setTrackerBackground(boolean opaque) {
boolean processEvent (long /*int*/ eventPtr) {
int eventType = GDK.gdk_event_get_event_type(eventPtr);
long /*int*/ widget = GTK.gtk_get_event_widget (eventPtr);
- if (GTK.GTK4) {
- switch (eventType) {
- case GDK.GDK4_MOTION_NOTIFY: gtk_motion_notify_event (widget, eventPtr); break;
- case GDK.GDK4_BUTTON_RELEASE: gtk_button_release_event (widget, eventPtr); break;
- case GDK.GDK4_KEY_PRESS: gtk_key_press_event (widget, eventPtr); break;
- case GDK.GDK4_KEY_RELEASE: gtk_key_release_event (widget, eventPtr); break;
- case GDK.GDK4_BUTTON_PRESS:
- case GDK.GDK_ENTER_NOTIFY:
- case GDK.GDK_LEAVE_NOTIFY:
- /* Do not dispatch these */
- break;
- case GDK.GDK4_EXPOSE:
- update ();
- GTK.gtk_main_do_event (eventPtr);
- break;
- default:
- return true;
- }
- } else {
- switch (eventType) {
- case GDK.GDK_MOTION_NOTIFY: gtk_motion_notify_event (widget, eventPtr); break;
- case GDK.GDK_BUTTON_RELEASE: gtk_button_release_event (widget, eventPtr); break;
- case GDK.GDK_KEY_PRESS: gtk_key_press_event (widget, eventPtr); break;
- case GDK.GDK_KEY_RELEASE: gtk_key_release_event (widget, eventPtr); break;
- case GDK.GDK_BUTTON_PRESS:
- case GDK.GDK_2BUTTON_PRESS:
- case GDK.GDK_3BUTTON_PRESS:
- case GDK.GDK_ENTER_NOTIFY:
- case GDK.GDK_LEAVE_NOTIFY:
- /* Do not dispatch these */
- break;
- case GDK.GDK_EXPOSE:
- update ();
- GTK.gtk_main_do_event (eventPtr);
- break;
- default:
- return true;
- }
+ switch (eventType) {
+ case GDK.GDK_MOTION_NOTIFY: gtk_motion_notify_event (widget, eventPtr); break;
+ case GDK.GDK_BUTTON_RELEASE: gtk_button_release_event (widget, eventPtr); break;
+ case GDK.GDK_KEY_PRESS: gtk_key_press_event (widget, eventPtr); break;
+ case GDK.GDK_KEY_RELEASE: gtk_key_release_event (widget, eventPtr); break;
+ case GDK.GDK_BUTTON_PRESS:
+ case GDK.GDK_2BUTTON_PRESS:
+ case GDK.GDK_3BUTTON_PRESS:
+ case GDK.GDK_ENTER_NOTIFY:
+ case GDK.GDK_LEAVE_NOTIFY:
+ /* Do not dispatch these */
+ break;
+ case GDK.GDK_EXPOSE:
+ update ();
+ GTK.gtk_main_do_event (eventPtr);
+ break;
+ default:
+ return true;
}
return false;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index 7e98aefdcb..0e49decdae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
@@ -264,14 +264,8 @@ long /*int*/ gtk_activate (long /*int*/ widget) {
gdk_event_free(currEvent);
}
GDK.gdk_event_free (nextEvent);
- if (GTK.GTK4) {
- if (currEventType == GDK.GDK4_BUTTON_PRESS && nextEventType == GDK.GDK4_BUTTON_PRESS) {
- sendSelectionEvent (SWT.DefaultSelection);
- }
- } else {
- if (currEventType == GDK.GDK_BUTTON_PRESS && nextEventType == GDK.GDK_2BUTTON_PRESS) {
- sendSelectionEvent (SWT.DefaultSelection);
- }
+ if (currEventType == GDK.GDK_BUTTON_PRESS && nextEventType == GDK.GDK_2BUTTON_PRESS) {
+ sendSelectionEvent (SWT.DefaultSelection);
}
}
return 0;
@@ -282,10 +276,8 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
int eventType = GDK.gdk_event_get_event_type(event);
int [] eventButton = new int [1];
GDK.gdk_event_get_button(event, eventButton);
- if (!GTK.GTK4 && eventType == GDK.GDK_3BUTTON_PRESS) return 0;
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- if (eventButton[0] == 3 && (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS)) {
+ if (eventType == GDK.GDK_3BUTTON_PRESS) return 0;
+ if (eventButton[0] == 3 && eventType == GDK.GDK_BUTTON_PRESS) {
sendEvent (SWT.MenuDetect);
return 0;
}
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 49a8039498..80af7c4ae6 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
@@ -2075,10 +2075,8 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
* in GTK in the case that additional items aren't being added (CTRL_MASK or SHIFT_MASK) and the item being dragged is already
* selected, we can give the DnD handling to MOTION-NOTIFY. Seee Bug 503431
*/
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect) &&
- !OS.isX11() && (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS)) { // Wayland
+ !OS.isX11() && eventType == GDK.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 = GDK.gdk_event_peek ();
if (nextEvent == 0) {
@@ -2116,7 +2114,7 @@ long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
* run the default handler when the item is already part of the current selection.
*/
int button = eventButton[0];
- if (button == 3 && (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS)) {
+ if (button == 3 && eventType == GDK.GDK_BUTTON_PRESS) {
long /*int*/ [] path = new long /*int*/ [1];
if (GTK.gtk_tree_view_get_path_at_pos (handle, (int)eventX[0], (int)eventY[0], path, null, null, null)) {
if (path [0] != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
index 9f0ac2c4ec..3f82e32523 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java
@@ -355,15 +355,16 @@ long /*int*/ gtk_clicked (long /*int*/ widget) {
GDK.gdk_event_get_button(eventPtr, eventButton);
int eventType = GDK.gdk_event_get_event_type(eventPtr);
int eventTime = GDK.gdk_event_get_time(eventPtr);
- boolean GTK4_BUTTON_RELEASE = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_RELEASE;
- boolean GTK3_BUTTON_RELEASE = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_RELEASE;
- if (GTK4_BUTTON_RELEASE || GTK3_BUTTON_RELEASE) {
- int clickTime = display.getDoubleClickTime ();
- if (lastButton == eventButton[0] && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
- doubleClick = true;
+ switch (eventType) {
+ case GDK.GDK_BUTTON_RELEASE: {
+ int clickTime = display.getDoubleClickTime ();
+ if (lastButton == eventButton[0] && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
+ doubleClick = true;
+ }
+ lastTime = eventTime == 0 ? 1: eventTime;
+ lastButton = eventButton[0];
+ break;
}
- lastTime = eventTime == 0 ? 1: eventTime;
- lastButton = eventButton[0];
}
gdk_event_free (eventPtr);
}
@@ -374,16 +375,17 @@ long /*int*/ gtk_clicked (long /*int*/ widget) {
@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
int eventType = GDK.gdk_event_get_event_type(gdkEvent);
- boolean GTK4_BUTTON_PRESS = GTK.GTK4 && eventType == GDK.GDK4_BUTTON_PRESS;
- boolean GTK3_BUTTON_PRESS = !GTK.GTK4 && eventType == GDK.GDK_BUTTON_PRESS;
- if (GTK3_BUTTON_PRESS || GTK4_BUTTON_PRESS) {
- int [] eventButton = new int [1];
- GDK.gdk_event_get_button(gdkEvent, eventButton);
- double [] eventRX = new double [1];
- double [] eventRY = new double [1];
- GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
- if (eventButton[0] == 3) {
- parent.showMenu ((int) eventRX[0], (int) eventRY[0]);
+ switch (eventType) {
+ case GDK.GDK_BUTTON_PRESS: {
+ int [] eventButton = new int [1];
+ GDK.gdk_event_get_button(gdkEvent, eventButton);
+ double [] eventRX = new double [1];
+ double [] eventRY = new double [1];
+ GDK.gdk_event_get_root_coords(gdkEvent, eventRX, eventRY);
+ if (eventButton[0] == 3) {
+ parent.showMenu ((int) eventRX[0], (int) eventRY[0]);
+ }
+ break;
}
}
return 0;
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 950db9a1ad..7001a6c20b 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
@@ -1536,30 +1536,16 @@ void sendSelectionEvent (int eventType, Event event, boolean send) {
long /*int*/ ptr = GTK.gtk_get_current_event ();
if (ptr != 0) {
int currentEventType = GDK.gdk_event_get_event_type(ptr);
- if (GTK.GTK4) {
- switch (currentEventType) {
- case GDK.GDK4_KEY_PRESS:
- case GDK.GDK4_KEY_RELEASE:
- case GDK.GDK4_BUTTON_PRESS:
- case GDK.GDK4_BUTTON_RELEASE: {
- int [] state = new int [1];
- GDK.gdk_event_get_state (ptr, state);
- setInputState (event, state [0]);
- break;
- }
- }
- } else {
- switch (currentEventType) {
- case GDK.GDK_KEY_PRESS:
- case GDK.GDK_KEY_RELEASE:
- case GDK.GDK_BUTTON_PRESS:
- case GDK.GDK_2BUTTON_PRESS:
- case GDK.GDK_BUTTON_RELEASE: {
- int [] state = new int [1];
- GDK.gdk_event_get_state (ptr, state);
- setInputState (event, state [0]);
- break;
- }
+ switch (currentEventType) {
+ case GDK.GDK_KEY_PRESS:
+ case GDK.GDK_KEY_RELEASE:
+ case GDK.GDK_BUTTON_PRESS:
+ case GDK.GDK_2BUTTON_PRESS:
+ case GDK.GDK_BUTTON_RELEASE: {
+ int [] state = new int [1];
+ GDK.gdk_event_get_state (ptr, state);
+ setInputState (event, state [0]);
+ break;
}
}
gdk_event_free (ptr);
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug543984_GTK4EventTypeConstants.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug543984_GTK4EventTypeConstants.java
deleted file mode 100644
index 75724e3e21..0000000000
--- a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug543984_GTK4EventTypeConstants.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 Red Hat and others. All rights reserved.
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- *
- * Contributors:
- * Red Hat - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.tests.gtk.snippets;
-
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/*
- * Title:
- * How to run:
- * Bug description:
- * Expected results:
- * GTK Version(s):
- */
-public class Bug543984_GTK4EventTypeConstants {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- shell.setSize(500, 200);
-
- shell.open();
-
- shell.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseUp(MouseEvent e) {
- System.out.println("MouseUp");
-
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- System.out.println("MouseDown");
-
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- // TODO: GDK_2BUTTON_PRESS removed in GTK4, no signal for double click
- System.out.println("MouseDoubleClick");
-
- }
- });
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
-}

Back to the top