diff options
author | Thomas Wood <thomas.wood@intel.com> | 2013-02-05 19:10:25 +0000 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2013-02-06 16:56:44 +0000 |
commit | 4f6d535626c441dbe063ee63344556f4ec68c81e (patch) | |
tree | dcbc41b04d0dfbfac86ad864d5085f089cd4a684 | |
parent | 69ac91b4b3b035f92b6d10944fb125e16ca3b062 (diff) | |
download | gtk+-4f6d535626c441dbe063ee63344556f4ec68c81e.tar.gz |
wayland: use the GdkCursorType enum information to lookup the cursor name
Use the enum information to generate the cursor name rather than using a
lookup table.
https://bugzilla.gnome.org/show_bug.cgi?id=693256
-rw-r--r-- | gdk/wayland/gdkcursor-wayland.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c index 7cc5f92735..4f87164c32 100644 --- a/gdk/wayland/gdkcursor-wayland.c +++ b/gdk/wayland/gdkcursor-wayland.c @@ -249,42 +249,26 @@ create_cursor(GdkWaylandDisplay *display, GdkPixbuf *pixbuf, int x, int y) } #endif -/* TODO: Extend this table */ -static const struct { - GdkCursorType type; - const gchar *cursor_name; -} cursor_mapping[] = { - { GDK_BLANK_CURSOR, NULL }, - { GDK_HAND1, "hand1" }, - { GDK_HAND2, "hand2" }, - { GDK_LEFT_PTR, "left_ptr" }, - { GDK_SB_H_DOUBLE_ARROW, "sb_h_double_arrow" }, - { GDK_SB_V_DOUBLE_ARROW, "sb_v_double_arrow" }, - { GDK_XTERM, "xterm" }, - { GDK_BOTTOM_RIGHT_CORNER, "bottom_right_corner" } -}; - GdkCursor * _gdk_wayland_display_get_cursor_for_type (GdkDisplay *display, GdkCursorType cursor_type) { - int i; + GEnumClass *enum_class; + GEnumValue *enum_value; + gchar *cursor_name; + GdkCursor *result; - for (i = 0; i < G_N_ELEMENTS (cursor_mapping); i++) - { - if (cursor_mapping[i].type == cursor_type) - break; - } + enum_class = g_type_class_ref (GDK_TYPE_CURSOR_TYPE); + enum_value = g_enum_get_value (enum_class, cursor_type); + cursor_name = g_strdup (enum_value->value_nick); + g_strdelimit (cursor_name, "-", '_'); + g_type_class_unref (enum_class); - if (i == G_N_ELEMENTS (cursor_mapping)) - { - g_warning ("Unhandled cursor type %d, falling back to blank\n", - cursor_type); - i = 0; - } + result = _gdk_wayland_display_get_cursor_for_name (display, cursor_name); + + g_free (cursor_name); - return _gdk_wayland_display_get_cursor_for_name (display, - cursor_mapping[i].cursor_name); + return result; } GdkCursor * @@ -305,7 +289,7 @@ _gdk_wayland_display_get_cursor_for_name (GdkDisplay *display, private->serial = theme_serial; /* Blank cursor case */ - if (!name) + if (!name || g_str_equal (name, "blank_cursor")) return GDK_CURSOR (private); cursor = wl_cursor_theme_get_cursor (wayland_display->cursor_theme, |