Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-01-16 14:20:14 -0500
committerEric Williams2019-01-23 13:32:54 -0500
commit4c6f9b48145b05e0fa1ba1ca2d72508f386576b0 (patch)
tree8ae319569c0596c0aab103421d5df3fc4046b7ee
parentbcc8a8572b7f424ff4c8eae419a0e75ea2be2ff8 (diff)
downloadeclipse.platform.swt-4c6f9b48145b05e0fa1ba1ca2d72508f386576b0.tar.gz
eclipse.platform.swt-4c6f9b48145b05e0fa1ba1ca2d72508f386576b0.tar.xz
eclipse.platform.swt-4c6f9b48145b05e0fa1ba1ca2d72508f386576b0.zip
Bug 539524: [GTK3.24] Port event handling to GtkEventController
Port motion (enter/leave/motion) and scroll events to GTK4. Change-Id: I20f80c93aed61c06e0b597564fb73f62d0b00e0b Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java35
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java31
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java38
13 files changed, 240 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 3a9e943c6d..0a79e11d58 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -5488,6 +5488,30 @@ JNIEXPORT jintLong JNICALL GTK_NATIVE(_1gtk_1event_1controller_1key_1new)
}
#endif
+#ifndef NO__1gtk_1event_1controller_1motion_1new
+JNIEXPORT jintLong JNICALL GTK_NATIVE(_1gtk_1event_1controller_1motion_1new)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1event_1controller_1motion_1new_FUNC);
+ rc = (jintLong)gtk_event_controller_motion_new();
+ GTK_NATIVE_EXIT(env, that, _1gtk_1event_1controller_1motion_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1event_1controller_1scroll_1new
+JNIEXPORT jintLong JNICALL GTK_NATIVE(_1gtk_1event_1controller_1scroll_1new)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jintLong rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1event_1controller_1scroll_1new_FUNC);
+ rc = (jintLong)gtk_event_controller_scroll_new(arg0);
+ GTK_NATIVE_EXIT(env, that, _1gtk_1event_1controller_1scroll_1new_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1event_1controller_1set_1propagation_1phase
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1event_1controller_1set_1propagation_1phase)
(JNIEnv *env, jclass that, jintLong arg0, jint arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
index 542b9a00f3..36f8ca2b1b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
@@ -439,7 +439,11 @@
#define NO__1gdk_1cursor_1new_1from_1name___3BJ
#define NO__1gdk_1display_1get_1keymap
#define NO__1gtk_1style_1context_1add_1provider_1for_1display
+
+// GtkEventController related functions for GTK4
#define NO__1gtk_1event_1controller_1key_1new
+#define NO__1gtk_1event_1controller_1motion_1new
+#define NO__1gtk_1event_1controller_1scroll_1new
#define NO__1gtk_1widget_1add_1controller
// GdkEvent functions which do not exist on GTK3
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 9bcbfa3c73..cc4f8e54ea 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -496,6 +496,8 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1event_1controller_1get_1widget",
"_1gtk_1event_1controller_1handle_1event",
"_1gtk_1event_1controller_1key_1new",
+ "_1gtk_1event_1controller_1motion_1new",
+ "_1gtk_1event_1controller_1scroll_1new",
"_1gtk_1event_1controller_1set_1propagation_1phase",
"_1gtk_1expander_1get_1expanded",
"_1gtk_1expander_1new",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index dba5be2a6d..365dad3bfe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -494,6 +494,8 @@ typedef enum {
_1gtk_1event_1controller_1get_1widget_FUNC,
_1gtk_1event_1controller_1handle_1event_FUNC,
_1gtk_1event_1controller_1key_1new_FUNC,
+ _1gtk_1event_1controller_1motion_1new_FUNC,
+ _1gtk_1event_1controller_1scroll_1new_FUNC,
_1gtk_1event_1controller_1set_1propagation_1phase_FUNC,
_1gtk_1expander_1get_1expanded_FUNC,
_1gtk_1expander_1new_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 13e50f607d..85c7601e21 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -90,6 +90,12 @@ public class GTK extends OS {
public static final int GTK_PRINT_DUPLEX_SIMPLEX = 0;
public static final int GTK_PRINT_DUPLEX_HORIZONTAL = 1;
public static final int GTK_PRINT_DUPLEX_VERTICAL = 2;
+ public static final int GTK_EVENT_CONTROLLER_SCROLL_NONE = 0;
+ public static final int GTK_EVENT_CONTROLLER_SCROLL_VERTICAL = 1;
+ public static final int GTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL = 2;
+ public static final int GTK_EVENT_CONTROLLER_SCROLL_DISCRETE = 3;
+ public static final int GTK_EVENT_CONTROLLER_SCROLL_KINETIC = 4;
+ public static final int GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES = 5;
public static final int GTK_PHASE_NONE = 0;
public static final int GTK_PHASE_CAPTURE = 1;
public static final int GTK_PHASE_BUBBLE = 2;
@@ -2458,6 +2464,26 @@ public class GTK extends OS {
lock.unlock();
}
}
+ public static final native long /*int*/ _gtk_event_controller_motion_new();
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final long /*int*/ gtk_event_controller_motion_new() {
+ lock.lock();
+ try {
+ return _gtk_event_controller_motion_new();
+ } finally {
+ lock.unlock();
+ }
+ }
+ public static final native long /*int*/ _gtk_event_controller_scroll_new(int flag);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final long /*int*/ gtk_event_controller_scroll_new(int flag) {
+ lock.lock();
+ try {
+ return _gtk_event_controller_scroll_new(flag);
+ } finally {
+ lock.unlock();
+ }
+ }
/**
* @param widget cast=(GtkWidget *)
* @param controller cast=(GtkEventController *)
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 7391691951..9e70d60b6d 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
@@ -842,10 +842,19 @@ void hookEvents(long /*int*/ [] handles) {
long /*int*/ eventHandle = handles [i];
if (eventHandle != 0) {
/* Connect the mouse signals */
- GTK.gtk_widget_add_events (eventHandle, eventMask);
+ if (GTK.GTK4) {
+ long /*int*/ motionController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(eventHandle, motionController);
+ long /*int*/ motionAddress = display.enterMotionScrollCallback.getAddress();
+ OS.g_signal_connect (motionController, OS.motion, motionAddress, MOTION);
+ OS.g_signal_connect (motionController, OS.motion, motionAddress, MOTION_INVERSE);
+ } else {
+ GTK.gtk_widget_add_events (eventHandle, eventMask);
+ 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);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT), false);
/*
* Feature in GTK. Events such as mouse move are propagated up
* the widget hierarchy and are seen by the parent. This is the
@@ -855,7 +864,6 @@ void hookEvents(long /*int*/ [] handles) {
*/
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);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_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 660d1853a2..285bd7bba8 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
@@ -413,19 +413,52 @@ void hookEvents () {
/* Connect the mouse signals */
long /*int*/ eventHandle = eventHandle ();
- int eventMask = GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_PRESS_MASK | GDK.GDK_BUTTON_RELEASE_MASK | GDK.GDK_SCROLL_MASK | GDK.GDK_SMOOTH_SCROLL_MASK;
- if (!GTK.GTK4) GTK.gtk_widget_add_events (eventHandle, eventMask);
+ long /*int*/ blockHandle = fixedHandle != 0 ? fixedHandle : eventHandle;
+ long /*int*/ enterExitHandle = enterExitHandle ();
+ if (GTK.GTK4) {
+ long /*int*/ motionController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(eventHandle, motionController);
+ GTK.gtk_event_controller_set_propagation_phase(motionController, GTK.GTK_PHASE_BUBBLE);
+
+ long /*int*/ enterMotionScrollAddress = display.enterMotionScrollCallback.getAddress();
+ OS.g_signal_connect (motionController, OS.motion, enterMotionScrollAddress, MOTION);
+
+ long /*int*/ enterLeaveController;
+ enterLeaveController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(enterExitHandle, enterLeaveController);
+ GTK.gtk_event_controller_set_propagation_phase(enterLeaveController, GTK.GTK_PHASE_TARGET);
+
+ long /*int*/ leaveAddress = display.leaveCallback.getAddress();
+ OS.g_signal_connect (enterLeaveController, OS.leave, leaveAddress, LEAVE);
+ OS.g_signal_connect (enterLeaveController, OS.enter, enterMotionScrollAddress, ENTER);
+
+ long /*int*/ motionInverseController;
+ if (blockHandle != eventHandle) {
+ motionInverseController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(blockHandle, motionInverseController);
+ GTK.gtk_event_controller_set_propagation_phase(motionInverseController, GTK.GTK_PHASE_TARGET);
+ } else {
+ motionInverseController = motionController;
+ }
+ OS.g_signal_connect (motionInverseController, OS.motion, enterMotionScrollAddress, MOTION_INVERSE);
+
+ long /*int*/ scrollController = GTK.gtk_event_controller_scroll_new(GTK.GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES);
+ GTK.gtk_widget_add_controller(eventHandle, scrollController);
+ GTK.gtk_event_controller_set_propagation_phase(scrollController, GTK.GTK_PHASE_TARGET);
+ OS.g_signal_connect (scrollController, OS.scroll, enterMotionScrollAddress, SCROLL);
+ } else {
+ int eventMask = GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_PRESS_MASK | GDK.GDK_BUTTON_RELEASE_MASK | GDK.GDK_SCROLL_MASK | GDK.GDK_SMOOTH_SCROLL_MASK;
+ GTK.gtk_widget_add_events (eventHandle, eventMask);
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.getClosure (MOTION_NOTIFY_EVENT), false);
+
+ int enterExitMask = GDK.GDK_ENTER_NOTIFY_MASK | GDK.GDK_LEAVE_NOTIFY_MASK;
+ GTK.gtk_widget_add_events (enterExitHandle, enterExitMask);
+ OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
+ 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);
- 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 [SCROLL_EVENT], 0, display.getClosure (SCROLL_EVENT), false);
-
- /* Connect enter/exit signals */
- long /*int*/ enterExitHandle = enterExitHandle ();
- int enterExitMask = GDK.GDK_ENTER_NOTIFY_MASK | GDK.GDK_LEAVE_NOTIFY_MASK;
- if (!GTK.GTK4) GTK.gtk_widget_add_events (enterExitHandle, enterExitMask);
- OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
- OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.getClosure (LEAVE_NOTIFY_EVENT), false);
/*Connect gesture signals */
setZoomGesture();
@@ -442,10 +475,9 @@ void hookEvents () {
* The signal is hooked to the fixedHandle to catch events sent to
* lightweight widgets.
*/
- long /*int*/ blockHandle = fixedHandle != 0 ? fixedHandle : eventHandle;
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);
+ if (!GTK.GTK4) 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);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index c1e1f89adb..4c95960a22 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -128,10 +128,10 @@ public class Display extends Device {
Callback eventCallback;
long /*int*/ eventProc, windowProc2, windowProc3, windowProc4, windowProc5, windowProc6;
long /*int*/ snapshotDrawProc;
- long /*int*/ keyPressReleaseProc, focusProc;
+ long /*int*/ keyPressReleaseProc, focusProc, enterMotionScrollProc, leaveProc;
Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6;
Callback snapshotDraw;
- Callback keyPressReleaseCallback, focusCallback;
+ Callback keyPressReleaseCallback, focusCallback, enterMotionScrollCallback, leaveCallback;
EventTable eventTable, filterTable;
static String APP_NAME = "SWT"; //$NON-NLS-1$
static String APP_VERSION = ""; //$NON-NLS-1$
@@ -3617,8 +3617,25 @@ void initializeCallbacks () {
long.class, long.class}); //$NON-NLS-1$
focusProc = focusCallback.getAddress ();
if (focusProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
closuresProc [Widget.FOCUS_IN] = focusProc;
closuresProc [Widget.FOCUS_OUT] = focusProc;
+
+ enterMotionScrollCallback = new Callback (this, "enterMotionScrollProc", long.class, new Type[] {
+ long.class, double.class, double.class, long.class}); //$NON-NLS-1$
+ enterMotionScrollProc = enterMotionScrollCallback.getAddress ();
+ if (enterMotionScrollProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ closuresProc [Widget.ENTER] = enterMotionScrollProc;
+ closuresProc [Widget.MOTION] = enterMotionScrollProc;
+ closuresProc [Widget.SCROLL] = enterMotionScrollProc;
+
+ leaveCallback = new Callback (this, "leaveProc", long.class, new Type[] {
+ long.class, long.class}); //$NON-NLS-1$
+ leaveProc = leaveCallback.getAddress ();
+ if (leaveProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ closuresProc [Widget.LEAVE] = leaveProc;
}
closuresProc [Widget.ACTIVATE] = windowProc2;
@@ -5935,6 +5952,13 @@ void wakeThread () {
wake = true;
}
+long /*int*/ enterMotionScrollProc (long /*int*/ controller, double x, double y, long /*int*/ user_data) {
+ long /*int*/ handle = GTK.gtk_event_controller_get_widget(controller);
+ Widget widget = getWidget (handle);
+ if (widget == null) return 0;
+ return widget.enterMotionScrollProc(handle, x, y, user_data);
+}
+
long /*int*/ focusProc (long /*int*/ controller, long /*int*/ user_data) {
long /*int*/ handle = GTK.gtk_event_controller_get_widget(controller);
Widget widget = getWidget (handle);
@@ -5949,6 +5973,13 @@ long /*int*/ keyPressReleaseProc (long /*int*/ controller, int keyval, int keyco
return widget.keyPressReleaseProc(handle, keyval, keycode, state, user_data);
}
+long /*int*/ leaveProc (long /*int*/ controller, long /*int*/ user_data) {
+ long /*int*/ handle = GTK.gtk_event_controller_get_widget(controller);
+ Widget widget = getWidget (handle);
+ if (widget == null) return 0;
+ return widget.leaveProc(handle, user_data);
+}
+
long /*int*/ windowProc (long /*int*/ handle, long /*int*/ user_data) {
Widget widget = getWidget (handle);
if (widget == null) return 0;
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 ffa8e8959b..5a8e92a04f 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
@@ -392,7 +392,16 @@ void hookEvents () {
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);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
+ if (GTK.GTK4) {
+ long /*int*/ motionController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(handle, motionController);
+ GTK.gtk_event_controller_set_propagation_phase(motionController, GTK.GTK_PHASE_TARGET);
+
+ long /*int*/ enterAddress = display.enterMotionScrollCallback.getAddress();
+ OS.g_signal_connect (motionController, OS.enter, enterAddress, ENTER);
+ } else {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
+ }
}
void redraw () {
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 0226498a1f..0e46391345 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
@@ -926,26 +926,43 @@ void hookEvents () {
GTK.gtk_widget_add_controller(shellHandle, keyController);
GTK.gtk_event_controller_set_propagation_phase(keyController, GTK.GTK_PHASE_TARGET);
- long keyPressReleaseAddress = display.keyPressReleaseCallback.getAddress();
- long focusAddress = display.focusCallback.getAddress();
+ long /*int*/ keyPressReleaseAddress = display.keyPressReleaseCallback.getAddress();
+ long /*int*/ focusAddress = display.focusCallback.getAddress();
OS.g_signal_connect (keyController, OS.key_pressed, keyPressReleaseAddress, KEY_PRESSED);
OS.g_signal_connect (keyController, OS.focus_in, focusAddress, FOCUS_IN);
OS.g_signal_connect (keyController, OS.focus_out, focusAddress, FOCUS_OUT);
+
+ long /*int*/ enterLeaveController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(shellHandle, enterLeaveController);
+
+ long /*int*/ enterMotionAddress = display.enterMotionScrollCallback.getAddress();
+ OS.g_signal_connect (enterLeaveController, OS.enter, enterMotionAddress, ENTER);
+ if (isCustomResize()) {
+ long /*int*/ motionController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(shellHandle, motionController);
+ GTK.gtk_event_controller_set_propagation_phase(motionController, GTK.GTK_PHASE_TARGET);
+
+ OS.g_signal_connect (motionController, OS.motion, enterMotionAddress, MOTION);
+ long /*int*/ leaveAddress = display.leaveCallback.getAddress();
+ OS.g_signal_connect (enterLeaveController, OS.leave, leaveAddress, LEAVE);
+ }
} else {
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [DELETE_EVENT], 0, display.getClosure (DELETE_EVENT), false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [KEY_PRESS_EVENT], 0, display.getClosure (KEY_PRESS_EVENT), false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [FOCUS_IN_EVENT], 0, display.getClosure (FOCUS_IN_EVENT), false);
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_by_id (shellHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
OS.g_signal_connect_closure (shellHandle, OS.move_focus, display.getClosure (MOVE_FOCUS), false);
if (isCustomResize ()) {
- int mask = GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_RELEASE_MASK | GDK.GDK_BUTTON_PRESS_MASK | GDK.GDK_ENTER_NOTIFY_MASK | GDK.GDK_LEAVE_NOTIFY_MASK;
- if (!GTK.GTK4) GTK.gtk_widget_add_events (shellHandle, mask);
+ if (!GTK.GTK4) {
+ int mask = GDK.GDK_POINTER_MOTION_MASK | GDK.GDK_BUTTON_RELEASE_MASK | GDK.GDK_BUTTON_PRESS_MASK | GDK.GDK_ENTER_NOTIFY_MASK | GDK.GDK_LEAVE_NOTIFY_MASK;
+ 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 [LEAVE_NOTIFY_EVENT], 0, display.getClosure (LEAVE_NOTIFY_EVENT), false);
- 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 [BUTTON_PRESS_EVENT], 0, display.getClosure (BUTTON_PRESS_EVENT), false);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index 95d544ecc7..b6f0e4afee 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -235,7 +235,16 @@ long /*int*/ gtk_mnemonic_activate (long /*int*/ widget, long /*int*/ arg1) {
void hookEvents () {
super.hookEvents ();
if (labelHandle != 0) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.getClosure (MNEMONIC_ACTIVATE), false);
- OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
+ if (GTK.GTK4) {
+ long /*int*/ motionController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(handle, motionController);
+ GTK.gtk_event_controller_set_propagation_phase(motionController, GTK.GTK_PHASE_TARGET);
+
+ long /*int*/ enterMotionAddress = display.enterMotionScrollCallback.getAddress();
+ OS.g_signal_connect (motionController, OS.enter, enterMotionAddress, ENTER);
+ } else {
+ OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
+ }
}
@Override
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 0380376a05..a121b97446 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
@@ -716,20 +716,29 @@ void hookEvents () {
if (arrowHandle != 0) OS.g_signal_connect_closure (arrowHandle, OS.clicked, display.getClosure (CLICKED), false);
}
OS.g_signal_connect_closure (handle, OS.create_menu_proxy, display.getClosure (CREATE_MENU_PROXY), false);
-
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
- OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.getClosure (LEAVE_NOTIFY_EVENT), false);
if (GTK.GTK4) {
long /*int*/ keyController = GTK.gtk_event_controller_key_new();
GTK.gtk_widget_add_controller(eventHandle, keyController);
GTK.gtk_event_controller_set_propagation_phase(keyController, GTK.GTK_PHASE_TARGET);
- long focusAddress = display.focusCallback.getAddress();
+ long /*int*/ focusAddress = display.focusCallback.getAddress();
OS.g_signal_connect (keyController, OS.focus_in, focusAddress, FOCUS_IN);
OS.g_signal_connect (keyController, OS.focus_out, focusAddress, FOCUS_OUT);
+
+ long /*int*/ motionController = GTK.gtk_event_controller_motion_new();
+ GTK.gtk_widget_add_controller(eventHandle, motionController);
+ GTK.gtk_event_controller_set_propagation_phase(motionController, GTK.GTK_PHASE_TARGET);
+
+ long /*int*/ enterAddress = display.enterMotionScrollCallback.getAddress();
+ long /*int*/ leaveAddress = display.leaveCallback.getAddress();
+ OS.g_signal_connect (motionController, OS.enter, enterAddress, ENTER);
+ OS.g_signal_connect (motionController, OS.leave, leaveAddress, LEAVE);
} else {
OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [FOCUS_IN_EVENT], 0, display.getClosure (FOCUS_IN_EVENT), false);
OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.getClosure (FOCUS_OUT_EVENT), false);
+
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.getClosure (ENTER_NOTIFY_EVENT), false);
+ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.getClosure (LEAVE_NOTIFY_EVENT), false);
}
/*
* Feature in GTK. Usually, GTK widgets propagate all events to their
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 d609988da0..047c811c50 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
@@ -230,8 +230,9 @@ public abstract class Widget {
static final int ENTER = 95;
static final int LEAVE = 96;
static final int MOTION = 97;
- static final int CLOSE_REQUEST = 98;
- static final int LAST_SIGNAL = 99;
+ static final int MOTION_INVERSE = 98;
+ static final int CLOSE_REQUEST = 99;
+ static final int LAST_SIGNAL = 100;
static final String IS_ACTIVE = "org.eclipse.swt.internal.control.isactive"; //$NON-NLS-1$
static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$
@@ -2045,6 +2046,27 @@ boolean translateTraversal (int event) {
return false;
}
+long /*int*/ enterMotionScrollProc (long /*int*/ handle, double x, double y, long /*int*/ user_data) {
+ long /*int*/ event = GTK.gtk_get_current_event();
+ long /*int*/ result = 0;
+ switch ((int)/*64*/user_data) {
+ case ENTER:
+ result = gtk_enter_notify_event(handle, event);
+ break;
+ case MOTION:
+ result = gtk_motion_notify_event(handle, event);
+ break;
+ case MOTION_INVERSE:
+ result = 1;
+ break;
+ case SCROLL:
+ result = gtk_scroll_event(handle, event);
+ break;
+ }
+ gdk_event_free(event);
+ return result;
+}
+
long /*int*/ focusProc (long /*int*/ handle, long /*int*/ user_data) {
long /*int*/ event = GTK.gtk_get_current_event();
long /*int*/ result = 0;
@@ -2075,6 +2097,18 @@ long /*int*/ keyPressReleaseProc (long /*int*/ handle, int keyval, int keycode,
return result;
}
+long /*int*/ leaveProc (long /*int*/ handle, long /*int*/ user_data) {
+ long /*int*/ event = GTK.gtk_get_current_event();
+ long /*int*/ result = 0;
+ switch ((int)/*64*/user_data) {
+ case LEAVE:
+ result = gtk_leave_notify_event(handle, event);
+ break;
+ }
+ gdk_event_free(event);
+ return result;
+}
+
long /*int*/ windowProc (long /*int*/ handle, long /*int*/ user_data) {
switch ((int)/*64*/user_data) {
case ACTIVATE: return gtk_activate (handle);

Back to the top