cursor: Always use names for cursors

Rather than sometimes using names and sometimes using glyphs.
This commit is contained in:
Jasper St. Pierre 2014-04-22 11:53:31 -04:00
parent e80c37f857
commit d9450c46b9

View File

@ -70,97 +70,59 @@ meta_cursor_reference_unref (MetaCursorReference *self)
meta_cursor_reference_free (self); meta_cursor_reference_free (self);
} }
static void static const char *
translate_meta_cursor (MetaCursor cursor, translate_meta_cursor (MetaCursor cursor)
guint *glyph_out,
const char **name_out)
{ {
guint glyph = XC_num_glyphs;
const char *name = NULL;
switch (cursor) switch (cursor)
{ {
case META_CURSOR_DEFAULT: case META_CURSOR_DEFAULT:
glyph = XC_left_ptr; return "left_ptr";
break;
case META_CURSOR_NORTH_RESIZE: case META_CURSOR_NORTH_RESIZE:
glyph = XC_top_side; return "top_side";
break;
case META_CURSOR_SOUTH_RESIZE: case META_CURSOR_SOUTH_RESIZE:
glyph = XC_bottom_side; return "bottom_side";
break;
case META_CURSOR_WEST_RESIZE: case META_CURSOR_WEST_RESIZE:
glyph = XC_left_side; return "left_side";
break;
case META_CURSOR_EAST_RESIZE: case META_CURSOR_EAST_RESIZE:
glyph = XC_right_side; return "right_side";
break;
case META_CURSOR_SE_RESIZE: case META_CURSOR_SE_RESIZE:
glyph = XC_bottom_right_corner; return "bottom_right_corner";
break;
case META_CURSOR_SW_RESIZE: case META_CURSOR_SW_RESIZE:
glyph = XC_bottom_left_corner; return "bottom_left_corner";
break;
case META_CURSOR_NE_RESIZE: case META_CURSOR_NE_RESIZE:
glyph = XC_top_right_corner; return "top_right_corner";
break;
case META_CURSOR_NW_RESIZE: case META_CURSOR_NW_RESIZE:
glyph = XC_top_left_corner; return "top_left_corner";
break;
case META_CURSOR_MOVE_OR_RESIZE_WINDOW: case META_CURSOR_MOVE_OR_RESIZE_WINDOW:
glyph = XC_fleur; return "fleur";
break;
case META_CURSOR_BUSY: case META_CURSOR_BUSY:
glyph = XC_watch; return "watch";
break;
case META_CURSOR_DND_IN_DRAG: case META_CURSOR_DND_IN_DRAG:
name = "dnd-none"; return "dnd-none";
break;
case META_CURSOR_DND_MOVE: case META_CURSOR_DND_MOVE:
name = "dnd-move"; return "dnd-move";
break;
case META_CURSOR_DND_COPY: case META_CURSOR_DND_COPY:
name = "dnd-copy"; return "dnd-copy";
break;
case META_CURSOR_DND_UNSUPPORTED_TARGET: case META_CURSOR_DND_UNSUPPORTED_TARGET:
name = "dnd-none"; return "dnd-none";
break;
case META_CURSOR_POINTING_HAND: case META_CURSOR_POINTING_HAND:
glyph = XC_hand2; return "hand2";
break;
case META_CURSOR_CROSSHAIR: case META_CURSOR_CROSSHAIR:
glyph = XC_crosshair; return "crosshair";
break;
case META_CURSOR_IBEAM: case META_CURSOR_IBEAM:
glyph = XC_xterm; return "xterm";
break;
default: default:
g_assert_not_reached ();
glyph = 0; /* silence compiler */
break; break;
} }
*glyph_out = glyph; g_assert_not_reached ();
*name_out = name;
} }
static Cursor static Cursor
load_cursor_on_server (MetaDisplay *display, load_cursor_on_server (MetaDisplay *display,
MetaCursor cursor) MetaCursor cursor)
{ {
Cursor xcursor; return XcursorLibraryLoadCursor (display->xdisplay, translate_meta_cursor (cursor));
guint glyph;
const char *name;
translate_meta_cursor (cursor, &glyph, &name);
if (name != NULL)
xcursor = XcursorLibraryLoadCursor (display->xdisplay, name);
else
xcursor = XCreateFontCursor (display->xdisplay, glyph);
return xcursor;
} }
Cursor Cursor
@ -174,20 +136,9 @@ static XcursorImage *
load_cursor_on_client (MetaDisplay *display, load_cursor_on_client (MetaDisplay *display,
MetaCursor cursor) MetaCursor cursor)
{ {
XcursorImage *image; return XcursorLibraryLoadImage (translate_meta_cursor (cursor),
guint glyph; meta_prefs_get_cursor_theme (),
const char *name; meta_prefs_get_cursor_size ());
const char *theme = meta_prefs_get_cursor_theme ();
int size = meta_prefs_get_cursor_size ();
translate_meta_cursor (cursor, &glyph, &name);
if (name != NULL)
image = XcursorLibraryLoadImage (name, theme, size);
else
image = XcursorShapeLoadImage (glyph, theme, size);
return image;
} }
static void static void