diff options
| author | Nikita Nemkin | 2020-01-22 21:49:55 +0000 |
|---|---|---|
| committer | Nikita Nemkin | 2020-01-25 11:07:24 +0000 |
| commit | 023d007f7773a264857e5cc9500e6d35a52a2ae1 (patch) | |
| tree | 0a5049600d5ae1557ed1b8a8ad4193c9ae258485 | |
| parent | 29efcd671ed1ecb10edb5e11ae9fc76a3c14ed1b (diff) | |
| download | eclipse.platform.swt-023d007f7773a264857e5cc9500e6d35a52a2ae1.tar.gz eclipse.platform.swt-023d007f7773a264857e5cc9500e6d35a52a2ae1.tar.xz eclipse.platform.swt-023d007f7773a264857e5cc9500e6d35a52a2ae1.zip | |
Bug 526357 - [GTK] Cursor lookup failure causes "No more handles"
Remove legacy cursor IDs, load cursors by name.
Use legacy X cursor names if possible, because they are the most
compatible between various cursor themes. Also, if a theme cursor
isn't available, libXcursor can fall back to legacy X Font cursor
(only on X11).
If loading fails, always use an arrow cursor as a fallback.
Note: GTK 3.18+ has a bug, when changing cursor themes on-the-fly
corrupts loaded cursors that were present in the old theme but are
missing from the new theme. This is likely to happen for "sb_up_arrow"
and "crossed_circle", which aren't universally available.
Change-Id: I9eba830f75e7fccc36401363d7dbad81ff32f6e0
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
9 files changed, 81 insertions, 206 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 6d71be3447..c2b3e5b1de 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 @@ -380,46 +380,34 @@ JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1clipboard_1set_1content) } #endif -#ifndef NO_gdk_1cursor_1new_1for_1display -JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1cursor_1new_1for_1display) - (JNIEnv *env, jclass that, jlong arg0, jlong arg1) +#ifndef NO_gdk_1cursor_1new_1from_1name__JLjava_lang_String_2 +JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1cursor_1new_1from_1name__JLjava_lang_String_2) + (JNIEnv *env, jclass that, jlong arg0, jstring arg1) { + const char *lparg1= NULL; jlong rc = 0; - GDK_NATIVE_ENTER(env, that, gdk_1cursor_1new_1for_1display_FUNC); - rc = (jlong)gdk_cursor_new_for_display((GdkDisplay *)arg0, (GdkCursorType)arg1); - GDK_NATIVE_EXIT(env, that, gdk_1cursor_1new_1for_1display_FUNC); - return rc; -} -#endif - -#ifndef NO_gdk_1cursor_1new_1from_1name__J_3B -JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1cursor_1new_1from_1name__J_3B) - (JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1) -{ - jbyte *lparg1=NULL; - jlong rc = 0; - GDK_NATIVE_ENTER(env, that, gdk_1cursor_1new_1from_1name__J_3B_FUNC); - if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + GDK_NATIVE_ENTER(env, that, gdk_1cursor_1new_1from_1name__JLjava_lang_String_2_FUNC); + if (arg1) if ((lparg1 = (*env)->GetStringUTFChars(env, arg1, NULL)) == NULL) goto fail; rc = (jlong)gdk_cursor_new_from_name((GdkDisplay *)arg0, (const gchar *)lparg1); fail: - if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); - GDK_NATIVE_EXIT(env, that, gdk_1cursor_1new_1from_1name__J_3B_FUNC); + if (arg1 && lparg1) (*env)->ReleaseStringUTFChars(env, arg1, lparg1); + GDK_NATIVE_EXIT(env, that, gdk_1cursor_1new_1from_1name__JLjava_lang_String_2_FUNC); return rc; } #endif -#ifndef NO_gdk_1cursor_1new_1from_1name___3BJ -JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1cursor_1new_1from_1name___3BJ) - (JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1) +#ifndef NO_gdk_1cursor_1new_1from_1name__Ljava_lang_String_2J +JNIEXPORT jlong JNICALL GDK_NATIVE(gdk_1cursor_1new_1from_1name__Ljava_lang_String_2J) + (JNIEnv *env, jclass that, jstring arg0, jlong arg1) { - jbyte *lparg0=NULL; + const char *lparg0= NULL; jlong rc = 0; - GDK_NATIVE_ENTER(env, that, gdk_1cursor_1new_1from_1name___3BJ_FUNC); - if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + GDK_NATIVE_ENTER(env, that, gdk_1cursor_1new_1from_1name__Ljava_lang_String_2J_FUNC); + if (arg0) if ((lparg0 = (*env)->GetStringUTFChars(env, arg0, NULL)) == NULL) goto fail; rc = (jlong)gdk_cursor_new_from_name((const gchar *)lparg0, (GdkCursor *)arg1); fail: - if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); - GDK_NATIVE_EXIT(env, that, gdk_1cursor_1new_1from_1name___3BJ_FUNC); + if (arg0 && lparg0) (*env)->ReleaseStringUTFChars(env, arg0, lparg0); + GDK_NATIVE_EXIT(env, that, gdk_1cursor_1new_1from_1name__Ljava_lang_String_2J_FUNC); return rc; } #endif 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 455ec3153d..56d5ab95a6 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 @@ -50,9 +50,8 @@ char * GDK_nativeFunctionNames[] = { "gdk_1cairo_1set_1source_1rgba", "gdk_1cairo_1set_1source_1window", "gdk_1clipboard_1set_1content", - "gdk_1cursor_1new_1for_1display", - "gdk_1cursor_1new_1from_1name__J_3B", - "gdk_1cursor_1new_1from_1name___3BJ", + "gdk_1cursor_1new_1from_1name__JLjava_lang_String_2", + "gdk_1cursor_1new_1from_1name__Ljava_lang_String_2J", "gdk_1cursor_1new_1from_1pixbuf", "gdk_1cursor_1new_1from_1texture", "gdk_1device_1get_1associated_1device", 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 5c11fb4d5b..430f29c5e9 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 @@ -60,9 +60,8 @@ typedef enum { gdk_1cairo_1set_1source_1rgba_FUNC, gdk_1cairo_1set_1source_1window_FUNC, gdk_1clipboard_1set_1content_FUNC, - gdk_1cursor_1new_1for_1display_FUNC, - gdk_1cursor_1new_1from_1name__J_3B_FUNC, - gdk_1cursor_1new_1from_1name___3BJ_FUNC, + gdk_1cursor_1new_1from_1name__JLjava_lang_String_2_FUNC, + gdk_1cursor_1new_1from_1name__Ljava_lang_String_2J_FUNC, gdk_1cursor_1new_1from_1pixbuf_FUNC, gdk_1cursor_1new_1from_1texture_FUNC, gdk_1device_1get_1associated_1device_FUNC, 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 0559eb8520..307fb427bb 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 @@ -30,9 +30,6 @@ public class GDK extends OS { public static final int GDK_Alt_L = 0xffe9; public static final int GDK_Alt_R = 0xffea; public static final int GDK_BackSpace = 0xff08; - public static final int GDK_BOTTOM_LEFT_CORNER = 0xc; - public static final int GDK_BOTTOM_RIGHT_CORNER = 0xe; - public static final int GDK_BOTTOM_SIDE = 0x10; public static final int GDK_BUTTON1_MASK = 0x100; public static final int GDK_BUTTON2_MASK = 0x200; public static final int GDK_BUTTON3_MASK = 0x400; @@ -47,7 +44,6 @@ public class GDK extends OS { public static final int GDK_COLORSPACE_RGB = 0; public static final int GDK_CONFIGURE = 13; public static final int GDK_CONTROL_MASK = 0x4; - public static final int GDK_CROSS = 0x1e; public static final int GDK_CROSSING_NORMAL = 0; public static final int GDK_CROSSING_GRAB = 1; public static final int GDK_CROSSING_UNGRAB = 2; @@ -62,7 +58,6 @@ public class GDK extends OS { public static final int GDK_DECOR_MINIMIZE = 0x20; public static final int GDK_DECOR_RESIZEH = 0x4; public static final int GDK_DECOR_TITLE = 0x8; - public static final int GDK_DOUBLE_ARROW = 0x2a; public static final int GDK_Delete = 0xffff; public static final int GDK_Down = 0xff54; public static final int GDK_ENTER_NOTIFY_MASK = 0x1000; @@ -95,7 +90,6 @@ public class GDK extends OS { public static final int GDK_F9 = 0xffc6; public static final int GDK_KEY_a = 0x061; public static final int GDK_KEY_z = 0x07a; - public static final int GDK_FLEUR = 0x34; public static final int GDK_FOCUS_CHANGE = 0xc; public static final int GDK_FOCUS_CHANGE_MASK = 0x4000; public static final int GDK_FUNC_ALL = 1; @@ -106,7 +100,6 @@ public class GDK extends OS { public static final int GDK_FUNC_CLOSE = 32; public static final int GDK_GRAB_SUCCESS = 0x0; public static final int GDK_GRAVITY_NORTH_WEST = 1; - public static final int GDK_HAND2 = 0x3c; public static final int GDK_Help = 0xFF6A; public static final int GDK_HINT_MIN_SIZE = 1 << 1; public static final int GDK_Home = 0xff50; @@ -148,8 +141,6 @@ public class GDK extends OS { public static final int GDK_KP_Up = 0xFF97; public static final int GDK_LEAVE_NOTIFY = 11; public static final int GDK_LEAVE_NOTIFY_MASK = 0x2000; - public static final int GDK_LEFT_PTR = 0x44; - public static final int GDK_LEFT_SIDE = 0x46; public static final int GDK_Linefeed = 0xff0A; public static final int GDK_Left = 0xff51; public static final int GDK_Meta_L = 0xFFE7; @@ -186,14 +177,9 @@ public class GDK extends OS { public static final int GDK_Page_Up = 0xff55; public static final int GDK_Pause = 0xff13; public static final int GDK_Print = 0xff61; - public static final int GDK_QUESTION_ARROW = 0x5c; - public static final int GDK_RIGHT_SIDE = 0x60; public static final int GDK_Return = 0xff0d; public static final int GDK_Right = 0xff53; public static final int GDK_space = 0x20; - public static final int GDK_SB_H_DOUBLE_ARROW = 0x6c; - public static final int GDK_SB_UP_ARROW = 0x72; - public static final int GDK_SB_V_DOUBLE_ARROW = 0x74; public static final int GDK_SEAT_CAPABILITY_NONE = 0; public static final int GDK_SEAT_CAPABILITY_POINTER = 1 << 0; public static final int GDK_SEAT_CAPABILITY_TOUCH = 1 << 1; @@ -213,21 +199,14 @@ public class GDK extends OS { public static final int GDK_SELECTION_NOTIFY = 19; public static final int GDK_SELECTION_REQUEST = 18; public static final int GDK_SHIFT_MASK = 0x1; - public static final int GDK_SIZING = 0x78; public static final int GDK_SURFACE_STATE_ICONIFIED = 1 << 1; public static final int GDK_SURFACE_STATE_MAXIMIZED = 1 << 2; public static final int GDK_SURFACE_STATE_FULLSCREEN = 1 << 4; public static final int GDK_Shift_L = 0xffe1; public static final int GDK_Shift_R = 0xffe2; public static final int GDK_Scroll_Lock = 0xff14; - public static final int GDK_TOP_LEFT_CORNER = 0x86; - public static final int GDK_TOP_RIGHT_CORNER = 0x88; - public static final int GDK_TOP_SIDE = 0x8a; public static final int GDK_Tab = 0xff09; public static final int GDK_Up = 0xff52; - public static final int GDK_WATCH = 0x96; - public static final int GDK_XTERM = 0x98; - public static final int GDK_X_CURSOR = 0x0; public static final int GDK_WINDOW_CHILD = 2; public static final int GDK_WINDOW_STATE = 32; public static final int GDK_WINDOW_STATE_ICONIFIED = 1 << 1; @@ -404,23 +383,18 @@ public class GDK extends OS { */ /* [GTK3 only, if-def'd in os.h] */ public static final native void gdk_cairo_set_source_window(long cairo, long window, int x, int y); - /** @param display cast=(GdkDisplay *) - * @param cursor_type cast=(GdkCursorType) - */ - /* [GTK3 only, if-def'd in os.h] */ - public static final native long gdk_cursor_new_for_display(long display, long cursor_type); /** * @param display cast=(GdkDisplay *) * @param cursor_name cast=(const gchar *) */ /* [GTK3 only, if-def'd in os.h] */ - public static final native long gdk_cursor_new_from_name(long display, byte[] cursor_name); + public static final native long gdk_cursor_new_from_name(long display, String cursor_name); /** * @param cursor_name cast=(const gchar *) * @param fallback cast=(GdkCursor *) */ /* [GTK4 only, if-def'd in os.h] */ - public static final native long gdk_cursor_new_from_name(byte[] cursor_name, long fallback); + public static final native long gdk_cursor_new_from_name(String cursor_name, long fallback); /** * @param display cast=(GdkDisplay *) * @param pixbuf cast=(GdkPixbuf *) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java index 2d938e40f9..5e3e1be0b3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java @@ -60,32 +60,6 @@ public final class Cursor extends Resource { */ public long handle; - static final byte[] APPSTARTING_SRC = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x7c, 0x00, 0x00, 0x00, (byte)0xfc, 0x00, 0x00, 0x00, (byte)0xfc, 0x01, 0x00, 0x00, - (byte)0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00, - (byte)0xc4, (byte)0xdc, 0x00, 0x00, (byte)0xc0, 0x44, 0x00, 0x00, (byte)0x80, 0x39, 0x00, 0x00, - (byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - static final byte[] APPSTARTING_MASK = { - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - (byte)0xfe, 0x00, 0x00, 0x00, (byte)0xfe, 0x01, 0x00, 0x00, (byte)0xfe, 0x3b, 0x00, 0x00, - (byte)0xfe, 0x7f, 0x00, 0x00, (byte)0xfe, 0x7f, 0x00, 0x00, (byte)0xfe, (byte)0xfe, 0x00, 0x00, - (byte)0xee, (byte)0xff, 0x01, 0x00, (byte)0xe4, (byte)0xff, 0x00, 0x00, (byte)0xc0, 0x7f, 0x00, 0x00, - (byte)0xc0, 0x7f, 0x00, 0x00, (byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - Cursor (Device device) { super(device); } @@ -138,81 +112,41 @@ Cursor (Device device) { */ public Cursor(Device device, int style) { super(device); - int shape = 0; - byte[] name = null; - if (GTK.GTK4) { - switch (style) { - case SWT.CURSOR_APPSTARTING: name = Converter.wcsToMbcs("progress", true) ; break; - case SWT.CURSOR_ARROW: name = Converter.wcsToMbcs("default", true) ; break; - case SWT.CURSOR_WAIT: name = Converter.wcsToMbcs("wait", true) ; break; - case SWT.CURSOR_CROSS: name = Converter.wcsToMbcs("cell", true) ; break; - case SWT.CURSOR_HAND: name = Converter.wcsToMbcs("pointer", true) ; break; - case SWT.CURSOR_HELP: name = Converter.wcsToMbcs("help", true) ; break; - case SWT.CURSOR_SIZEALL: name = Converter.wcsToMbcs("all-scroll", true) ; break; - case SWT.CURSOR_SIZENESW: name = Converter.wcsToMbcs("nesw-resize", true); break; - case SWT.CURSOR_SIZENS: name = Converter.wcsToMbcs("row-resize", true) ; break; - case SWT.CURSOR_SIZENWSE: name = Converter.wcsToMbcs("nwse-resize", true); break; - case SWT.CURSOR_SIZEWE: name = Converter.wcsToMbcs("col-resize", true); break; - case SWT.CURSOR_SIZEN: name = Converter.wcsToMbcs("n-resize", true); break; - case SWT.CURSOR_SIZES: name = Converter.wcsToMbcs("s-resize", true); break; - case SWT.CURSOR_SIZEE: name = Converter.wcsToMbcs("e-resize", true); break; - case SWT.CURSOR_SIZEW: name = Converter.wcsToMbcs("w-resize", true); break; - case SWT.CURSOR_SIZENE: name = Converter.wcsToMbcs("ne-resize", true); break; - case SWT.CURSOR_SIZESE: name = Converter.wcsToMbcs("se-resize", true); break; - case SWT.CURSOR_SIZESW: name = Converter.wcsToMbcs("sw-resize", true); break; - case SWT.CURSOR_SIZENW: name = Converter.wcsToMbcs("nw-resize", true); break; - case SWT.CURSOR_UPARROW: name = Converter.wcsToMbcs("ns-resize", true); break; - case SWT.CURSOR_IBEAM: name = Converter.wcsToMbcs("text", true); break; - case SWT.CURSOR_NO: name = Converter.wcsToMbcs("not-allowed", true) ; break; - default: - SWT.error(SWT.ERROR_INVALID_ARGUMENT); - } - } else { - switch (style) { - case SWT.CURSOR_APPSTARTING: name = Converter.wcsToMbcs("progress", true) ; break; - case SWT.CURSOR_ARROW: shape = GDK.GDK_LEFT_PTR; break; - case SWT.CURSOR_WAIT: shape = GDK.GDK_WATCH; break; - case SWT.CURSOR_CROSS: shape = GDK.GDK_CROSS; break; - case SWT.CURSOR_HAND: shape = GDK.GDK_HAND2; break; - case SWT.CURSOR_HELP: shape = GDK.GDK_QUESTION_ARROW; break; - case SWT.CURSOR_SIZEALL: shape = GDK.GDK_FLEUR; break; - case SWT.CURSOR_SIZENESW: shape = GDK.GDK_SIZING; name=Converter.wcsToMbcs("nesw-resize", true); break; - case SWT.CURSOR_SIZENS: shape = GDK.GDK_DOUBLE_ARROW; break; - case SWT.CURSOR_SIZENWSE: shape = GDK.GDK_SIZING; name=Converter.wcsToMbcs("nwse-resize", true); break; - case SWT.CURSOR_SIZEWE: shape = GDK.GDK_SB_H_DOUBLE_ARROW; break; - case SWT.CURSOR_SIZEN: shape = GDK.GDK_TOP_SIDE; break; - case SWT.CURSOR_SIZES: shape = GDK.GDK_BOTTOM_SIDE; break; - case SWT.CURSOR_SIZEE: shape = GDK.GDK_RIGHT_SIDE; break; - case SWT.CURSOR_SIZEW: shape = GDK.GDK_LEFT_SIDE; break; - case SWT.CURSOR_SIZENE: shape = GDK.GDK_TOP_RIGHT_CORNER; break; - case SWT.CURSOR_SIZESE: shape = GDK.GDK_BOTTOM_RIGHT_CORNER; break; - case SWT.CURSOR_SIZESW: shape = GDK.GDK_BOTTOM_LEFT_CORNER; break; - case SWT.CURSOR_SIZENW: shape = GDK.GDK_TOP_LEFT_CORNER; break; - case SWT.CURSOR_UPARROW: shape = GDK.GDK_SB_UP_ARROW; break; - case SWT.CURSOR_IBEAM: shape = GDK.GDK_XTERM; break; - case SWT.CURSOR_NO: shape = GDK.GDK_X_CURSOR; name=Converter.wcsToMbcs("not-allowed", true) ; break; - default: - SWT.error(SWT.ERROR_INVALID_ARGUMENT); - } + String name1 = null, name2 = null; + switch (style) { + case SWT.CURSOR_APPSTARTING: name1 = "left_ptr_watch"; break; + case SWT.CURSOR_ARROW: name1 = "left_ptr"; break; + case SWT.CURSOR_WAIT: name1 = "watch"; break; + case SWT.CURSOR_CROSS: name1 = "crosshair"; break; + case SWT.CURSOR_HAND: name1 = "hand2"; break; + case SWT.CURSOR_HELP: name1 = "question_arrow"; break; + case SWT.CURSOR_SIZEALL: name1 = "fleur"; break; + case SWT.CURSOR_SIZENESW: name1 = "size_bdiag"; break; + case SWT.CURSOR_SIZENS: name1 = "sb_v_double_arrow"; break; + case SWT.CURSOR_SIZENWSE: name1 = "size_fdiag"; break; + case SWT.CURSOR_SIZEWE: name1 = "sb_h_double_arrow"; break; + case SWT.CURSOR_SIZEN: name1 = "top_side"; break; + case SWT.CURSOR_SIZES: name1 = "bottom_side"; break; + case SWT.CURSOR_SIZEE: name1 = "right_side"; break; + case SWT.CURSOR_SIZEW: name1 = "left_side"; break; + case SWT.CURSOR_SIZENE: name1 = "top_right_corner"; break; + case SWT.CURSOR_SIZESE: name1 = "bottom_right_corner"; break; + case SWT.CURSOR_SIZESW: name1 = "bottom_left_corner"; break; + case SWT.CURSOR_SIZENW: name1 = "top_left_corner"; break; + case SWT.CURSOR_UPARROW: name1 = "sb_up_arrow"; name2 = "up-arrow"; break; + case SWT.CURSOR_IBEAM: name1 = "xterm"; break; + case SWT.CURSOR_NO: name1 = "crossed_circle"; name2 = "not-allowed"; break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - if (name != null) { + for (String name : new String[] { name1, name2, "left_ptr", "default" }) { + if (name == null) continue; if (GTK.GTK4) { - handle = GDK.gdk_cursor_new_from_name(name, 0); + handle = GDK.gdk_cursor_new_from_name (name, 0); } else { handle = GDK.gdk_cursor_new_from_name (GDK.gdk_display_get_default(), name); } - } - if (handle == 0) { - if (shape == 0 && style == SWT.CURSOR_APPSTARTING) { - byte[] src = new byte[APPSTARTING_SRC.length]; - System.arraycopy(APPSTARTING_SRC, 0, src, 0, src.length); - byte[] mask = new byte[APPSTARTING_MASK.length]; - System.arraycopy(APPSTARTING_MASK, 0, mask, 0, mask.length); - handle = createCursor(src, mask, 32, 32, 2, 2, true); - } else { - if (!GTK.GTK4) handle = GDK.gdk_cursor_new_for_display(GDK.gdk_display_get_default(), shape); - } - + if (handle != 0) break; } if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); init(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java index ea42beca1d..b5269e28a1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java @@ -147,17 +147,15 @@ void createHandle (int index) { GTK.gtk_widget_set_can_focus (handle, true); if ((style & SWT.VERTICAL) != 0) { if (GTK.GTK4) { - byte [] name = Converter.wcsToMbcs("w-resize", true); - defaultCursor = GDK.gdk_cursor_new_from_name(name, 0); + defaultCursor = GDK.gdk_cursor_new_from_name("sb_h_double_arrow", 0); } else { - defaultCursor = GDK.gdk_cursor_new_for_display (GDK.gdk_display_get_default(), GDK.GDK_SB_H_DOUBLE_ARROW); + defaultCursor = GDK.gdk_cursor_new_from_name (GDK.gdk_display_get_default(), "sb_h_double_arrow"); } } else { if (GTK.GTK4) { - byte [] name = Converter.wcsToMbcs("ns-resize", true); - defaultCursor = GDK.gdk_cursor_new_from_name(name, 0); + defaultCursor = GDK.gdk_cursor_new_from_name("sb_v_double_arrow", 0); } else { - defaultCursor = GDK.gdk_cursor_new_for_display (GDK.gdk_display_get_default(), GDK.GDK_SB_V_DOUBLE_ARROW); + defaultCursor = GDK.gdk_cursor_new_from_name (GDK.gdk_display_get_default(), "sb_v_double_arrow"); } } } 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 93c290689e..7ed32393bb 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 @@ -1175,21 +1175,21 @@ int getResizeMode (double x, double y) { int border = gtk_container_get_border_width_or_margin (shellHandle); int mode = 0; if (y >= height - border) { - mode = GDK.GDK_BOTTOM_SIDE ; - if (x >= width - border - 16) mode = GDK.GDK_BOTTOM_RIGHT_CORNER; - else if (x <= border + 16) mode = GDK.GDK_BOTTOM_LEFT_CORNER; + mode = SWT.CURSOR_SIZES; + if (x >= width - border - 16) mode = SWT.CURSOR_SIZESE; + else if (x <= border + 16) mode = SWT.CURSOR_SIZESW; } else if (x >= width - border) { - mode = GDK.GDK_RIGHT_SIDE; - if (y >= height - border - 16) mode = GDK.GDK_BOTTOM_RIGHT_CORNER; - else if (y <= border + 16) mode = GDK.GDK_TOP_RIGHT_CORNER; + mode = SWT.CURSOR_SIZEE; + if (y >= height - border - 16) mode = SWT.CURSOR_SIZESE; + else if (y <= border + 16) mode = SWT.CURSOR_SIZENE; } else if (y <= border) { - mode = GDK.GDK_TOP_SIDE; - if (x <= border + 16) mode = GDK.GDK_TOP_LEFT_CORNER; - else if (x >= width - border - 16) mode = GDK.GDK_TOP_RIGHT_CORNER; + mode = SWT.CURSOR_SIZEN; + if (x <= border + 16) mode = SWT.CURSOR_SIZENW; + else if (x >= width - border - 16) mode = SWT.CURSOR_SIZENE; } else if (x <= border) { - mode = GDK.GDK_LEFT_SIDE; - if (y <= border + 16) mode = GDK.GDK_TOP_LEFT_CORNER; - else if (y >= height - border - 16) mode = GDK.GDK_BOTTOM_LEFT_CORNER; + mode = SWT.CURSOR_SIZEW; + if (y <= border + 16) mode = SWT.CURSOR_SIZENW; + else if (y >= height - border - 16) mode = SWT.CURSOR_SIZESW; } return mode; } @@ -1644,36 +1644,36 @@ long gtk_motion_notify_event (long widget, long event) { int newWidth = Math.max(width - dx, Math.max(minWidth, border + border)); int newHeight = Math.max(height - dy, Math.max(minHeight, border + border)); switch (display.resizeMode) { - case GDK.GDK_LEFT_SIDE: + case SWT.CURSOR_SIZEW: x += width - newWidth; width = newWidth; break; - case GDK.GDK_TOP_LEFT_CORNER: + case SWT.CURSOR_SIZENW: x += width - newWidth; width = newWidth; y += height - newHeight; height = newHeight; break; - case GDK.GDK_TOP_SIDE: + case SWT.CURSOR_SIZEN: y += height - newHeight; height = newHeight; break; - case GDK.GDK_TOP_RIGHT_CORNER: + case SWT.CURSOR_SIZENE: width = Math.max(width + dx, Math.max(minWidth, border + border)); y += height - newHeight; height = newHeight; break; - case GDK.GDK_RIGHT_SIDE: + case SWT.CURSOR_SIZEE: width = Math.max(width + dx, Math.max(minWidth, border + border)); break; - case GDK.GDK_BOTTOM_RIGHT_CORNER: + case SWT.CURSOR_SIZESE: width = Math.max(width + dx, Math.max(minWidth, border + border)); height = Math.max(height + dy, Math.max(minHeight, border + border)); break; - case GDK.GDK_BOTTOM_SIDE: + case SWT.CURSOR_SIZES: height = Math.max(height + dy, Math.max(minHeight, border + border)); break; - case GDK.GDK_BOTTOM_LEFT_CORNER: + case SWT.CURSOR_SIZESW: x += width - newWidth; width = newWidth; height = Math.max(height + dy, Math.max(minHeight, border + border)); @@ -1694,28 +1694,13 @@ long gtk_motion_notify_event (long widget, long event) { GDK.gdk_event_get_coords(event, eventX, eventY); int mode = getResizeMode (eventX[0], eventY[0]); if (mode != display.resizeMode) { - long cursor; + long cursor = display.getSystemCursor(mode).handle; if (GTK.GTK4) { - byte [] name; - switch (mode) { - case GDK.GDK_BOTTOM_RIGHT_CORNER: name = Converter.wcsToMbcs("se-resize", true); break; - case GDK.GDK_BOTTOM_LEFT_CORNER: name = Converter.wcsToMbcs("sw-resize", true); break; - case GDK.GDK_TOP_LEFT_CORNER: name = Converter.wcsToMbcs("nw-resize", true); break; - case GDK.GDK_TOP_RIGHT_CORNER: name = Converter.wcsToMbcs("ne-resize", true); break; - case GDK.GDK_BOTTOM_SIDE: name = Converter.wcsToMbcs("s-resize", true); break; - case GDK.GDK_TOP_SIDE: name = Converter.wcsToMbcs("n-resize", true); break; - case GDK.GDK_LEFT_SIDE: name = Converter.wcsToMbcs("w-resize", true); break; - case GDK.GDK_RIGHT_SIDE: name = Converter.wcsToMbcs("e-resize", true); break; - default: name = Converter.wcsToMbcs("none", true); break; - } - cursor = GDK.gdk_cursor_new_from_name(name, 0); 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); GDK.gdk_window_set_cursor (window, cursor); } - OS.g_object_unref (cursor); display.resizeMode = mode; } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java index 9638dc8773..78bfbc7853 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java @@ -954,10 +954,9 @@ void setCursor (long cursor) { long defaultCursor = 0; if (cursor == 0) { if (GTK.GTK4) { - byte [] name = Converter.wcsToMbcs("text", true); - defaultCursor = GDK.gdk_cursor_new_from_name(name, 0); + defaultCursor = GDK.gdk_cursor_new_from_name ("xterm", 0); } else { - defaultCursor = GDK.gdk_cursor_new_for_display (GDK.gdk_display_get_default(), GDK.GDK_XTERM); + defaultCursor = GDK.gdk_cursor_new_from_name (GDK.gdk_display_get_default(), "xterm"); } } super.setCursor (cursor != 0 ? cursor : defaultCursor); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index c32ad27bf6..38cd1e5f28 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -2249,10 +2249,9 @@ void setCursor (long cursor) { long defaultCursor = 0; if (cursor == 0) { if (GTK.GTK4) { - byte [] name = Converter.wcsToMbcs("text", true); - defaultCursor = GDK.gdk_cursor_new_from_name(name, 0); + defaultCursor = GDK.gdk_cursor_new_from_name("xterm", 0); } else { - defaultCursor = GDK.gdk_cursor_new_for_display (GDK.gdk_display_get_default(), GDK.GDK_XTERM); + defaultCursor = GDK.gdk_cursor_new_from_name (GDK.gdk_display_get_default(), "xterm"); } } super.setCursor (cursor != 0 ? cursor : defaultCursor); |
