Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXi Yan2019-01-25 15:23:47 -0500
committerEric Williams2019-01-31 09:36:28 -0500
commitd70957069be27c7a0616832a3d0c5f9364e95bb0 (patch)
tree7ce515bbd5b783ba1f4c3f15833e6aed2b168031
parent6c97ab637f4d1fc5a5d255581eb6be2b5eaa2a45 (diff)
downloadeclipse.platform.swt-d70957069be27c7a0616832a3d0c5f9364e95bb0.tar.gz
eclipse.platform.swt-d70957069be27c7a0616832a3d0c5f9364e95bb0.tar.xz
eclipse.platform.swt-d70957069be27c7a0616832a3d0c5f9364e95bb0.zip
Bug 541376 - [GTK4] Replace signals which have been removed
- Replace button-press-event/button-release-event/configure-event signal with generic event handler. Change-Id: Ic3726b03041d332d75c2c170dfc25966d53afe61 Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java21
8 files changed, 167 insertions, 26 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 c056bc2f49..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;
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 b0687c9b09..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
@@ -853,17 +853,23 @@ void hookEvents(long /*int*/ [] handles) {
OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT), false);
OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT_INVERSE), true);
}
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT), false);
+ if (GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ } else {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT), false);
+ }
/*
- * Feature in GTK. Events such as mouse move are propagated up
+ * Feature in GTK3. Events such as mouse move are propagated up
* the widget hierarchy and are seen by the parent. This is the
* correct GTK behavior but not correct for SWT. The fix is to
* hook a signal after and stop the propagation using a negative
* event number to distinguish this case.
*/
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT_INVERSE), true);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT_INVERSE), true);
+ if (!GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT_INVERSE), true);
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT_INVERSE), true);
+ }
/* Connect the event_after signal for both key and mouse */
if (eventHandle != focusHandle ()) {
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 86e3fcbb9b..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
@@ -172,7 +172,6 @@ void connectPaint () {
int paintMask = GDK.GDK_EXPOSURE_MASK;
GTK.gtk_widget_add_events (paintHandle, paintMask);
OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [DRAW], 0, display.getClosure (EXPOSE_EVENT_INVERSE), false);
-
OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [DRAW], 0, display.getClosure (DRAW), true);
}
}
@@ -408,7 +407,7 @@ void hookEvents () {
OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.getClosure (FOCUS_OUT_EVENT), false);
}
OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [POPUP_MENU], 0, display.getClosure (POPUP_MENU), false);
- OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [SHOW_HELP], 0, display.getClosure (SHOW_HELP), false);
+ if (!GTK.GTK4) OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [SHOW_HELP], 0, display.getClosure (SHOW_HELP), false);
OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS], 0, display.getClosure (FOCUS), false);
/* Connect the mouse signals */
@@ -457,8 +456,13 @@ void hookEvents () {
OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.getClosure (LEAVE_NOTIFY_EVENT), false);
OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [SCROLL_EVENT], 0, display.getClosure (SCROLL_EVENT), false);
}
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT), false);
+ if (GTK.GTK4) {
+ // GTK4: button-press/release-event dropped, use generic event instead
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ } else {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT), false);
+ }
/*Connect gesture signals */
setZoomGesture();
@@ -466,7 +470,7 @@ void hookEvents () {
setRotateGesture();
/*
- * Feature in GTK. Events such as mouse move are propagate up
+ * Feature in GTK3. Events such as mouse move are propagate up
* the widget hierarchy and are seen by the parent. This is the
* correct GTK behavior but not correct for SWT. The fix is to
* hook a signal after and stop the propagation using a negative
@@ -474,15 +478,23 @@ void hookEvents () {
*
* The signal is hooked to the fixedHandle to catch events sent to
* lightweight widgets.
+ *
+ * Events are not propagated up on GTK4
*/
- OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT_INVERSE), true);
- OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT_INVERSE), true);
- if (!GTK.GTK4) OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT_INVERSE), true);
+ if (!GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT_INVERSE), true);
+ OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT_INVERSE), true);
+ OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT_INVERSE), true);
+ }
/* Connect the event_after signal for both key and mouse */
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
- if (focusHandle != eventHandle) {
- OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
+ if (GTK.GTK4) {
+ // TODO: Replacements for event-after, no GdkEventController for button-press/release-event
+ } else {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
+ if (focusHandle != eventHandle) {
+ OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
+ }
}
/* Connect the paint signal */
@@ -3361,6 +3373,26 @@ void gtk_style_context_get_border (long /*int*/ context, int state, GtkBorder pa
GTK.gtk_style_context_get_border(context, state, padding);
}
}
+/**
+ * Generic "event" handler for signals that are dropped in GTK4
+ * This method routes the following signals:
+ * - button-press-event
+ * - button-release-event
+ */
+@Override
+long /*int*/ gtk_event (long /*int*/ widget, long /*int*/ event) {
+ if (!GTK.GTK4) return 0;
+ int eventType = GDK.gdk_event_get_event_type(event);
+ switch (eventType) {
+ case GDK.GDK4_BUTTON_PRESS: {
+ return gtk_button_press_event(widget, event);
+ }
+ case GDK.GDK4_BUTTON_RELEASE: {
+ return gtk_button_release_event(widget, event);
+ }
+ }
+ return 0;
+}
@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
index f26e2b8c9f..e4d253e73e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java
@@ -356,6 +356,21 @@ long /*int*/ gtk_activate (long /*int*/ widget) {
}
@Override
+long /*int*/ gtk_event (long /*int*/ widget, long /*int*/ event) {
+ if (!GTK.GTK4) return 0;
+ int eventType = GDK.gdk_event_get_event_type(event);
+ switch (eventType) {
+ case GDK.GDK4_BUTTON_PRESS: {
+ return gtk_button_press_event(widget, event);
+ }
+ case GDK.GDK4_BUTTON_RELEASE: {
+ return gtk_button_release_event(widget, event);
+ }
+ }
+ return 0;
+}
+
+@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
setFocus ();
return 0;
@@ -389,7 +404,11 @@ void hookEvents () {
super.hookEvents ();
OS.g_signal_connect_closure (handle, OS.activate, display.getClosure (ACTIVATE), false);
OS.g_signal_connect_closure (handle, OS.activate, display.getClosure (ACTIVATE_INVERSE), true);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ if (GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ } else {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ }
OS.g_signal_connect_closure_by_id (handle, display.signalIds [FOCUS_OUT_EVENT], 0, display.getClosure (FOCUS_OUT_EVENT), false);
OS.g_signal_connect_closure (clientHandle, OS.size_allocate, display.getClosure (SIZE_ALLOCATE), true);
if (GTK.GTK4) {
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 6a2da2e7f3..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
@@ -502,6 +502,21 @@ public boolean getVisible () {
}
@Override
+long /*int*/ gtk_event (long /*int*/ widget, long /*int*/ event) {
+ if (!GTK.GTK4) return 0;
+ int eventType = GDK.gdk_event_get_event_type(event);
+ switch (eventType) {
+ case GDK.GDK4_BUTTON_PRESS: {
+ return gtk_button_press_event(widget, event);
+ }
+ case GDK.GDK4_BUTTON_RELEASE: {
+ return gtk_button_release_event(widget, event);
+ }
+ }
+ return 0;
+}
+
+@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ eventPtr) {
long /*int*/ result = super.gtk_button_press_event (widget, eventPtr);
if (result != 0) return result;
@@ -578,7 +593,11 @@ void hookEvents () {
OS.g_signal_connect_closure (handle, OS.change_value, display.getClosure (CHANGE_VALUE), false);
OS.g_signal_connect_closure (adjustmentHandle, OS.value_changed, display.getClosure (VALUE_CHANGED), false);
OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ if (GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ } else {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ }
}
/**
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 7ebfeeccae..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
@@ -917,9 +917,15 @@ boolean hasBorder () {
@Override
void hookEvents () {
super.hookEvents ();
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [WINDOW_STATE_EVENT], 0, display.getClosure (WINDOW_STATE_EVENT), false);
+ if (GTK.GTK4) {
+ // Replace configure-event with generic event handler
+ 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);
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [MAP_EVENT], 0, display.shellMapProcClosure, false);
+ }
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [SIZE_ALLOCATE], 0, display.getClosure (SIZE_ALLOCATE), false);
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [CONFIGURE_EVENT], 0, display.getClosure (CONFIGURE_EVENT), false);
if (GTK.GTK4) {
OS.g_signal_connect_closure (shellHandle, OS.close_request, display.getClosure (CLOSE_REQUEST), false);
long /*int*/ keyController = GTK.gtk_event_controller_key_new();
@@ -953,7 +959,6 @@ void hookEvents () {
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.getClosure (FOCUS_OUT_EVENT), false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
}
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [MAP_EVENT], 0, display.shellMapProcClosure, false);
OS.g_signal_connect_closure (shellHandle, OS.move_focus, display.getClosure (MOVE_FOCUS), false);
if (isCustomResize ()) {
if (!GTK.GTK4) {
@@ -961,9 +966,10 @@ void hookEvents () {
GTK.gtk_widget_add_events (shellHandle, mask);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT), false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.getClosure (LEAVE_NOTIFY_EVENT), false);
+
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), false);
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
}
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), false);
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
}
}
@@ -1388,6 +1394,24 @@ public Shell [] getShells () {
}
@Override
+long /*int*/ gtk_event (long /*int*/ widget, long /*int*/ event) {
+ if (!GTK.GTK4) return 0;
+ int eventType = GDK.gdk_event_get_event_type(event);
+ switch (eventType) {
+ case GDK.GDK4_BUTTON_PRESS: {
+ return gtk_button_press_event(widget, event);
+ }
+ case GDK.GDK4_BUTTON_RELEASE: {
+ return gtk_button_release_event(widget, event);
+ }
+ case GDK.GDK4_CONFIGURE: {
+ return gtk_configure_event(widget, event);
+ }
+ }
+ return 0;
+}
+
+@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
if (widget == shellHandle) {
if (isCustomResize ()) {
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 a121b97446..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
@@ -469,6 +469,21 @@ int getWidthInPixels () {
}
@Override
+long /*int*/ gtk_event (long /*int*/ widget, long /*int*/ event) {
+ if (!GTK.GTK4) return 0;
+ int eventType = GDK.gdk_event_get_event_type(event);
+ switch (eventType) {
+ case GDK.GDK4_BUTTON_PRESS: {
+ return gtk_button_press_event(widget, event);
+ }
+ case GDK.GDK4_BUTTON_RELEASE: {
+ return gtk_button_release_event(widget, event);
+ }
+ }
+ return 0;
+}
+
+@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
return parent.gtk_button_press_event (widget, event);
}
@@ -755,8 +770,12 @@ void hookEvents () {
GDK.GDK_KEY_PRESS_MASK | GDK.GDK_KEY_RELEASE_MASK |
GDK.GDK_FOCUS_CHANGE_MASK;
GTK.gtk_widget_add_events (eventHandle, mask);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT), false);
+ if (GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ } else {
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.getClosure (BUTTON_RELEASE_EVENT), false);
+ }
OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.getClosure (EVENT_AFTER), false);
long /*int*/ topHandle = topHandle ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 66dbc0f552..2a909e7409 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -481,6 +481,21 @@ public boolean getVisible () {
}
@Override
+long /*int*/ gtk_event (long /*int*/ widget, long /*int*/ event) {
+ if (!GTK.GTK4) return 0;
+ int eventType = GDK.gdk_event_get_event_type(event);
+ switch (eventType) {
+ case GDK.GDK4_BUTTON_PRESS: {
+ return gtk_button_press_event(widget, event);
+ }
+ case GDK.GDK4_BUTTON_RELEASE: {
+ return gtk_button_release_event(widget, event);
+ }
+ }
+ return 0;
+}
+
+@Override
long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) {
sendSelectionEvent (SWT.Selection, null, true);
setVisible (false);
@@ -593,7 +608,11 @@ void hookEvents () {
OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT], 0, display.getClosure (EXPOSE_EVENT), true);
OS.g_signal_connect_closure_by_id (handle, display.signalIds [EXPOSE_EVENT_INVERSE], 0, display.getClosure (EXPOSE_EVENT_INVERSE), true);
GTK.gtk_widget_add_events (handle, GDK.GDK_BUTTON_PRESS_MASK);
- OS.g_signal_connect_closure (handle, OS.button_press_event, display.getClosure (BUTTON_PRESS_EVENT), false);
+ if (GTK.GTK4) {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT], 0, display.getClosure (EVENT), false);
+ } else {
+ OS.g_signal_connect_closure (handle, OS.button_press_event, display.getClosure (BUTTON_PRESS_EVENT), false);
+ }
}
}

Back to the top