[gtk+] Wayland: Make css cursor names work
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Wayland: Make css cursor names work
- Date: Fri, 8 May 2015 17:34:43 +0000 (UTC)
commit 5434609b2167c5a4e33f494af0c0a82cd3f2639e
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 8 09:38:56 2015 -0400
Wayland: Make css cursor names work
Map css cursor names to traditional X cursor names to increase
our chance of finding a good cursor in the cursor theme.
gdk/wayland/gdkcursor-wayland.c | 51 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c
index cdb799c..13263cd 100644
--- a/gdk/wayland/gdkcursor-wayland.c
+++ b/gdk/wayland/gdkcursor-wayland.c
@@ -83,6 +83,52 @@ _gdk_wayland_display_finalize_cursors (GdkWaylandDisplay *display)
g_hash_table_destroy (display->cursor_cache);
}
+static const struct {
+ const gchar *css_name, *traditional_name;
+} name_map[] = {
+ { "default", "left_ptr" },
+ { "pointer", "hand" },
+ { "progress", "left_ptr_watch" },
+ { "wait", "watch" },
+ { "cell", "crosshair" },
+ { "crosshair", "cross" },
+ { "text", "xterm" },
+ { "alias", "dnd-link" },
+ { "copy", "dnd-copy" },
+ { "no-drop", "dnd-none" },
+ { "not-allowed", "crossed_circle" },
+ { "grab", "hand2" },
+ { "col-resize", "h_double_arrow" },
+ { "row-resize", "v_double_arrow" },
+ { "n-resize", "top_side" },
+ { "e-resize", "right_side" },
+ { "s-resize", "bottom_side" },
+ { "w-resize", "left_side" },
+ { "ne-resize", "top_right_corner" },
+ { "nw-resize", "top_left_corner" },
+ { "se-resize", "bottom_right_corner" },
+ { "sw-resize", "bottom_left_corner" },
+ { "ew-resize", "h_double_arrow" },
+ { "ns-resize", "v_double_arrow" },
+ { "nesw-resize", "fd_double_arrow" },
+ { "nwse-resize", "bd_double_arrow" },
+ { NULL, NULL }
+};
+
+static const gchar *
+name_fallback (const gchar *name)
+{
+ gint i;
+
+ for (i = 0; name_map[i].css_name; i++)
+ {
+ if (g_str_equal (name_map[i].css_name, name))
+ return name_map[i].traditional_name;
+ }
+
+ return "left_ptr";
+}
+
static gboolean
_gdk_wayland_cursor_update (GdkWaylandDisplay *wayland_display,
GdkWaylandCursor *cursor)
@@ -98,6 +144,9 @@ _gdk_wayland_cursor_update (GdkWaylandDisplay *wayland_display,
cursor->scale);
c = wl_cursor_theme_get_cursor (theme, cursor->name);
if (!c)
+ c = wl_cursor_theme_get_cursor (theme, name_fallback (cursor->name));
+
+ if (!c)
{
g_warning (G_STRLOC ": Unable to load %s from the cursor theme", cursor->name);
@@ -284,7 +333,7 @@ _gdk_wayland_display_get_cursor_for_name_with_scale (GdkDisplay *display,
private->scale = scale;
/* Blank cursor case */
- if (!name || g_str_equal (name, "blank_cursor"))
+ if (!name || g_str_equal (name, "none") || g_str_equal (name, "blank_cursor"))
return GDK_CURSOR (private);
if (!_gdk_wayland_cursor_update (wayland_display, private))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]