Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-04-16 13:49:37 -0400
committerEric Williams2019-04-16 13:52:45 -0400
commitbfbff4c83c848210dc0210324cab85b42b965a4e (patch)
tree62d7cc1cd7b31dc1b10b16f41d059926a52c7480 /bundles/org.eclipse.swt
parentbb98207d55709a339e0a6668837bc9377d627a44 (diff)
downloadeclipse.platform.swt-bfbff4c83c848210dc0210324cab85b42b965a4e.tar.gz
eclipse.platform.swt-bfbff4c83c848210dc0210324cab85b42b965a4e.tar.xz
eclipse.platform.swt-bfbff4c83c848210dc0210324cab85b42b965a4e.zip
Bug 546488: [GTK4] Cursor never reverts back to normal
Use gtk_widget_set_cursor() in certain instances in order to make sure the cursor is set/unset properly. Change-Id: Iad680c4ab71aae79faf6ac7e61513b793dd5380a Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java6
7 files changed, 31 insertions, 6 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 90815ab001..483247a7d2 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
@@ -12672,6 +12672,16 @@ fail:
}
#endif
+#ifndef NO__1gtk_1widget_1set_1cursor
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1cursor)
+ (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1cursor_FUNC);
+ gtk_widget_set_cursor((GtkWidget *)arg0, (GdkCursor *)arg1);
+ GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1cursor_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1widget_1set_1default_1direction
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1set_1default_1direction)
(JNIEnv *env, jclass that, jint arg0)
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 1b346b1121..99b1e5f6b5 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
@@ -451,6 +451,7 @@
#define NO__1gdk_1cursor_1new_1from_1name___3BI
#define NO__1gdk_1cursor_1new_1from_1name___3BJ
#define NO__1gdk_1cursor_1new_1from_1texture
+#define NO__1gtk_1widget_1set_1cursor
// No GdkTexture on GTK3
#define NO__1gdk_1texture_1new_1for_1pixbuf
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 d863e2af8f..d507b756f3 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
@@ -998,6 +998,7 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1widget_1set_1can_1default",
"_1gtk_1widget_1set_1can_1focus",
"_1gtk_1widget_1set_1clip",
+ "_1gtk_1widget_1set_1cursor",
"_1gtk_1widget_1set_1default_1direction",
"_1gtk_1widget_1set_1direction",
"_1gtk_1widget_1set_1double_1buffered",
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 cbb6566264..b895961cfe 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
@@ -996,6 +996,7 @@ typedef enum {
_1gtk_1widget_1set_1can_1default_FUNC,
_1gtk_1widget_1set_1can_1focus_FUNC,
_1gtk_1widget_1set_1clip_FUNC,
+ _1gtk_1widget_1set_1cursor_FUNC,
_1gtk_1widget_1set_1default_1direction_FUNC,
_1gtk_1widget_1set_1direction_FUNC,
_1gtk_1widget_1set_1double_1buffered_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 399aa54052..66c9cb1cb6 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
@@ -8999,6 +8999,20 @@ public class GTK extends OS {
}
/**
* @param widget cast=(GtkWidget *)
+ * @param cursor cast=(GdkCursor *)
+ */
+ public static final native void _gtk_widget_set_cursor(long widget, long cursor);
+ /** [GTK4 only, if-def'd in os.h] */
+ public static final void gtk_widget_set_cursor(long widget, long cursor) {
+ lock.lock();
+ try {
+ _gtk_widget_set_cursor(widget, cursor);
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @param widget cast=(GtkWidget *)
* @param visible cast=(gboolean)
*/
public static final native void _gtk_widget_set_visible(long widget, boolean visible);
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 5b2e0a4b04..a724341256 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
@@ -5183,8 +5183,8 @@ public void setCursor (Cursor cursor) {
void setCursor (long cursor) {
if (GTK.GTK4) {
- long surface = eventSurface ();
- GDK.gdk_surface_set_cursor(surface, cursor);
+ long eventHandle = eventHandle ();
+ GTK.gtk_widget_set_cursor (eventHandle, cursor);
} else {
long window = eventWindow ();
if (window != 0) {
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 8a1178eee4..3d19416e8a 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
@@ -1589,8 +1589,7 @@ long gtk_leave_notify_event (long widget, long event) {
GDK.gdk_event_get_state(event, state);
if ((state[0] & GDK.GDK_BUTTON1_MASK) == 0) {
if (GTK.GTK4) {
- long surface = gtk_widget_get_surface (shellHandle);
- GDK.gdk_surface_set_cursor(surface, 0);
+ GTK.gtk_widget_set_cursor (shellHandle, 0);
} else {
long window = gtk_widget_get_window (shellHandle);
GDK.gdk_window_set_cursor (window, 0);
@@ -1707,9 +1706,8 @@ long gtk_motion_notify_event (long widget, long event) {
case GDK.GDK_RIGHT_SIDE: name = Converter.wcsToMbcs("e-resize", true); break;
default: name = Converter.wcsToMbcs("none", true); break;
}
- long surface = gtk_widget_get_surface(shellHandle);
cursor = GDK.gdk_cursor_new_from_name(name, 0);
- GDK.gdk_surface_set_cursor(surface, cursor);
+ GTK.gtk_widget_set_cursor (shellHandle, cursor);
} else {
long window = gtk_widget_get_window (shellHandle);
cursor = GDK.gdk_cursor_new_for_display (GDK.gdk_display_get_default(), mode);

Back to the top