diff --git a/src/core/display.c b/src/core/display.c index 722fddd78..617ca50d0 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -51,7 +51,6 @@ #include #include #include -#include #include "mutter-enum-types.h" #include "meta-idle-monitor-private.h" @@ -3859,85 +3858,6 @@ meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display, return is_a_no_focus_window; } -Cursor -meta_display_create_x_cursor (MetaDisplay *display, - MetaCursor cursor) -{ - Cursor xcursor; - guint glyph = XC_num_glyphs; - const char *name = NULL; - - switch (cursor) - { - case META_CURSOR_DEFAULT: - glyph = XC_left_ptr; - break; - case META_CURSOR_NORTH_RESIZE: - glyph = XC_top_side; - break; - case META_CURSOR_SOUTH_RESIZE: - glyph = XC_bottom_side; - break; - case META_CURSOR_WEST_RESIZE: - glyph = XC_left_side; - break; - case META_CURSOR_EAST_RESIZE: - glyph = XC_right_side; - break; - case META_CURSOR_SE_RESIZE: - glyph = XC_bottom_right_corner; - break; - case META_CURSOR_SW_RESIZE: - glyph = XC_bottom_left_corner; - break; - case META_CURSOR_NE_RESIZE: - glyph = XC_top_right_corner; - break; - case META_CURSOR_NW_RESIZE: - glyph = XC_top_left_corner; - break; - case META_CURSOR_MOVE_OR_RESIZE_WINDOW: - glyph = XC_fleur; - break; - case META_CURSOR_BUSY: - glyph = XC_watch; - break; - case META_CURSOR_DND_IN_DRAG: - name = "dnd-none"; - break; - case META_CURSOR_DND_MOVE: - name = "dnd-move"; - break; - case META_CURSOR_DND_COPY: - name = "dnd-copy"; - break; - case META_CURSOR_DND_UNSUPPORTED_TARGET: - name = "dnd-none"; - break; - case META_CURSOR_POINTING_HAND: - glyph = XC_hand2; - break; - case META_CURSOR_CROSSHAIR: - glyph = XC_crosshair; - break; - case META_CURSOR_IBEAM: - glyph = XC_xterm; - break; - - default: - g_assert_not_reached (); - glyph = 0; /* silence compiler */ - break; - } - - if (name != NULL) - xcursor = XcursorLibraryLoadCursor (display->xdisplay, name); - else - xcursor = XCreateFontCursor (display->xdisplay, glyph); - - return xcursor; -} - static Cursor xcursor_for_op (MetaDisplay *display, MetaGrabOp op) diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c index 77a9898e4..03fb440be 100644 --- a/src/core/meta-cursor-tracker.c +++ b/src/core/meta-cursor-tracker.c @@ -37,6 +37,7 @@ #include +#include #include #include "meta-cursor-tracker-private.h" @@ -69,6 +70,106 @@ enum { static guint signals[LAST_SIGNAL]; +static void +translate_meta_cursor (MetaCursor cursor, + guint *glyph_out, + const char **name_out) +{ + guint glyph = XC_num_glyphs; + const char *name = NULL; + + switch (cursor) + { + case META_CURSOR_DEFAULT: + glyph = XC_left_ptr; + break; + case META_CURSOR_NORTH_RESIZE: + glyph = XC_top_side; + break; + case META_CURSOR_SOUTH_RESIZE: + glyph = XC_bottom_side; + break; + case META_CURSOR_WEST_RESIZE: + glyph = XC_left_side; + break; + case META_CURSOR_EAST_RESIZE: + glyph = XC_right_side; + break; + case META_CURSOR_SE_RESIZE: + glyph = XC_bottom_right_corner; + break; + case META_CURSOR_SW_RESIZE: + glyph = XC_bottom_left_corner; + break; + case META_CURSOR_NE_RESIZE: + glyph = XC_top_right_corner; + break; + case META_CURSOR_NW_RESIZE: + glyph = XC_top_left_corner; + break; + case META_CURSOR_MOVE_OR_RESIZE_WINDOW: + glyph = XC_fleur; + break; + case META_CURSOR_BUSY: + glyph = XC_watch; + break; + case META_CURSOR_DND_IN_DRAG: + name = "dnd-none"; + break; + case META_CURSOR_DND_MOVE: + name = "dnd-move"; + break; + case META_CURSOR_DND_COPY: + name = "dnd-copy"; + break; + case META_CURSOR_DND_UNSUPPORTED_TARGET: + name = "dnd-none"; + break; + case META_CURSOR_POINTING_HAND: + glyph = XC_hand2; + break; + case META_CURSOR_CROSSHAIR: + glyph = XC_crosshair; + break; + case META_CURSOR_IBEAM: + glyph = XC_xterm; + break; + + default: + g_assert_not_reached (); + glyph = 0; /* silence compiler */ + break; + } + + *glyph_out = glyph; + *name_out = name; +} + +static Cursor +load_cursor_on_server (MetaDisplay *display, + MetaCursor cursor) +{ + Cursor xcursor; + 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 +meta_display_create_x_cursor (MetaDisplay *display, + MetaCursor cursor) +{ + return load_cursor_on_server (display, cursor); +} + static void meta_cursor_tracker_init (MetaCursorTracker *self) {