x11: Only do cursor name fallback for standard names

Always returning a left_ptr if we can't find anything better
broke firefox application-specific fallback for missing cursors.
Keep that working by only doing the fallback for the CSS cursor
names, not for things like hashes.

https://bugzilla.gnome.org/show_bug.cgi?id=760141
This commit is contained in:
Matthias Clasen
2016-01-06 14:54:33 -05:00
parent b6e11d087c
commit d9befb9086

View File

@ -611,17 +611,23 @@ static const struct {
const gchar *css_name, *traditional_name; const gchar *css_name, *traditional_name;
} name_map[] = { } name_map[] = {
{ "default", "left_ptr" }, { "default", "left_ptr" },
{ "help", "left_ptr" },
{ "context-menu", "left_ptr" },
{ "pointer", "hand" }, { "pointer", "hand" },
{ "progress", "left_ptr_watch" }, { "progress", "left_ptr_watch" },
{ "wait", "watch" }, { "wait", "watch" },
{ "cell", "crosshair" }, { "cell", "crosshair" },
{ "crosshair", "cross" }, { "crosshair", "cross" },
{ "text", "xterm" }, { "text", "xterm" },
{ "vertical-text","xterm" },
{ "alias", "dnd-link" }, { "alias", "dnd-link" },
{ "copy", "dnd-copy" }, { "copy", "dnd-copy" },
{ "move", "dnd-move" },
{ "no-drop", "dnd-none" }, { "no-drop", "dnd-none" },
{ "not-allowed", "crossed_circle" }, { "not-allowed", "crossed_circle" },
{ "grab", "hand2" }, { "grab", "hand2" },
{ "grabbing", "hand2" },
{ "all-scroll", "left_ptr" },
{ "col-resize", "h_double_arrow" }, { "col-resize", "h_double_arrow" },
{ "row-resize", "v_double_arrow" }, { "row-resize", "v_double_arrow" },
{ "n-resize", "top_side" }, { "n-resize", "top_side" },
@ -636,6 +642,8 @@ static const struct {
{ "ns-resize", "v_double_arrow" }, { "ns-resize", "v_double_arrow" },
{ "nesw-resize", "fd_double_arrow" }, { "nesw-resize", "fd_double_arrow" },
{ "nwse-resize", "bd_double_arrow" }, { "nwse-resize", "bd_double_arrow" },
{ "zoom-in", "left_ptr" },
{ "zoom-out", "left_ptr" },
{ NULL, NULL } { NULL, NULL }
}; };
@ -650,7 +658,7 @@ name_fallback (const gchar *name)
return name_map[i].traditional_name; return name_map[i].traditional_name;
} }
return "left_ptr"; return NULL;
} }
GdkCursor* GdkCursor*
@ -683,9 +691,17 @@ _gdk_x11_display_get_cursor_for_name (GdkDisplay *display,
xdisplay = GDK_DISPLAY_XDISPLAY (display); xdisplay = GDK_DISPLAY_XDISPLAY (display);
xcursor = XcursorLibraryLoadCursor (xdisplay, name); xcursor = XcursorLibraryLoadCursor (xdisplay, name);
if (xcursor == None) if (xcursor == None)
xcursor = XcursorLibraryLoadCursor (xdisplay, name_fallback (name)); {
if (xcursor == None) const char *fallback;
xcursor = XcursorLibraryLoadCursor (xdisplay, "left_ptr");
fallback = name_fallback (name);
if (fallback)
{
xcursor = XcursorLibraryLoadCursor (xdisplay, fallback);
if (xcursor == None)
xcursor = XcursorLibraryLoadCursor (xdisplay, "left_ptr");
}
}
if (xcursor == None) if (xcursor == None)
return NULL; return NULL;
} }