diff --git a/gdk/mir/gdkmir-private.h b/gdk/mir/gdkmir-private.h index 268295b0ad..78e3ed3415 100644 --- a/gdk/mir/gdkmir-private.h +++ b/gdk/mir/gdkmir-private.h @@ -51,7 +51,11 @@ GdkDevice *_gdk_mir_pointer_new (GdkDeviceManager *device_manager, const gchar * void _gdk_mir_pointer_set_location (GdkDevice *pointer, gdouble x, gdouble y, GdkWindow *window, GdkModifierType mask); -GdkCursor *_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type); +GdkCursor *_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type); + +GdkCursor *_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name); + +const gchar *_gdk_mir_cursor_get_name (GdkCursor *cursor); GdkWindowImpl *_gdk_mir_window_impl_new (void); diff --git a/gdk/mir/gdkmircursor.c b/gdk/mir/gdkmircursor.c index bdbce5ea95..7ce158a3ad 100644 --- a/gdk/mir/gdkmircursor.c +++ b/gdk/mir/gdkmircursor.c @@ -35,6 +35,8 @@ typedef struct GdkMirCursorClass GdkMirCursorClass; struct GdkMirCursor { GdkCursor parent_instance; + + gchar *name; }; struct GdkMirCursorClass @@ -44,10 +46,100 @@ struct GdkMirCursorClass G_DEFINE_TYPE (GdkMirCursor, gdk_mir_cursor, GDK_TYPE_CURSOR) -GdkCursor * -_gdk_mir_cursor_new (GdkDisplay *display, GdkCursorType type) +static const gchar * +get_cursor_name_for_cursor_type (GdkCursorType cursor_type) { - return g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL); + switch (cursor_type) + { + case GDK_BLANK_CURSOR: + return mir_disabled_cursor_name; + case GDK_X_CURSOR: + case GDK_ARROW: + case GDK_CENTER_PTR: + case GDK_DRAFT_LARGE: + case GDK_DRAFT_SMALL: + case GDK_LEFT_PTR: + case GDK_RIGHT_PTR: + case GDK_TOP_LEFT_ARROW: + return mir_arrow_cursor_name; + case GDK_CLOCK: + case GDK_WATCH: + return mir_busy_cursor_name; + case GDK_XTERM: + return mir_caret_cursor_name; + case GDK_HAND1: + case GDK_HAND2: + return mir_pointing_hand_cursor_name; + return mir_open_hand_cursor_name; + case GDK_FLEUR: + return mir_closed_hand_cursor_name; + case GDK_LEFT_SIDE: + case GDK_LEFT_TEE: + case GDK_RIGHT_SIDE: + case GDK_RIGHT_TEE: + case GDK_SB_LEFT_ARROW: + case GDK_SB_RIGHT_ARROW: + return mir_horizontal_resize_cursor_name; + case GDK_BASED_ARROW_DOWN: + case GDK_BASED_ARROW_UP: + case GDK_BOTTOM_SIDE: + case GDK_BOTTOM_TEE: + case GDK_DOUBLE_ARROW: + case GDK_SB_DOWN_ARROW: + case GDK_SB_UP_ARROW: + case GDK_TOP_SIDE: + case GDK_TOP_TEE: + return mir_vertical_resize_cursor_name; + case GDK_BOTTOM_LEFT_CORNER: + case GDK_LL_ANGLE: + case GDK_TOP_RIGHT_CORNER: + case GDK_UR_ANGLE: + return mir_diagonal_resize_bottom_to_top_cursor_name; + case GDK_BOTTOM_RIGHT_CORNER: + case GDK_LR_ANGLE: + case GDK_SIZING: + case GDK_TOP_LEFT_CORNER: + case GDK_UL_ANGLE: + return mir_diagonal_resize_top_to_bottom_cursor_name; + return mir_omnidirectional_resize_cursor_name; + case GDK_SB_V_DOUBLE_ARROW: + return mir_vsplit_resize_cursor_name; + case GDK_SB_H_DOUBLE_ARROW: + return mir_hsplit_resize_cursor_name; + default: + return mir_default_cursor_name; + } +} + + +GdkCursor * +_gdk_mir_cursor_new_for_name (GdkDisplay *display, const gchar *name) +{ + GdkMirCursor *cursor; + + cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", GDK_CURSOR_IS_PIXMAP, NULL); + cursor->name = g_strdup (name); + + return GDK_CURSOR (cursor); +} + +GdkCursor * +_gdk_mir_cursor_new_for_type (GdkDisplay *display, GdkCursorType type) +{ + GdkMirCursor *cursor; + + cursor = g_object_new (GDK_TYPE_MIR_CURSOR, "display", display, "cursor-type", type, NULL); + cursor->name = g_strdup (get_cursor_name_for_cursor_type (type)); + + return GDK_CURSOR (cursor); +} + +const gchar * +_gdk_mir_cursor_get_name (GdkCursor *cursor) +{ + GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (cursor); + + return mir_cursor->name; } cairo_surface_t * @@ -64,10 +156,22 @@ gdk_mir_cursor_init (GdkMirCursor *cursor) { } +static void +gdk_mir_cursor_finalize (GObject *object) +{ + GdkMirCursor *mir_cursor = GDK_MIR_CURSOR (object); + + g_free (mir_cursor->name); + + G_OBJECT_CLASS (gdk_mir_cursor_parent_class)->finalize (object); +} + static void gdk_mir_cursor_class_init (GdkMirCursorClass *klass) { GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); cursor_class->get_surface = gdk_mir_cursor_get_surface; + object_class->finalize = gdk_mir_cursor_finalize; } diff --git a/gdk/mir/gdkmirdisplay.c b/gdk/mir/gdkmirdisplay.c index b38cc98796..b44cc79789 100644 --- a/gdk/mir/gdkmirdisplay.c +++ b/gdk/mir/gdkmirdisplay.c @@ -45,8 +45,6 @@ typedef struct GdkMirDisplay /* Screen information */ GdkScreen *screen; - GdkCursor *cursor; - GdkKeymap *keymap; } GdkMirDisplay; @@ -317,16 +315,14 @@ static GdkCursor * gdk_mir_display_get_cursor_for_type (GdkDisplay *display, GdkCursorType cursor_type) { - return _gdk_mir_cursor_new (display, cursor_type); + return _gdk_mir_cursor_new_for_type (display, cursor_type); } static GdkCursor * gdk_mir_display_get_cursor_for_name (GdkDisplay *display, const gchar *name) { - g_printerr ("gdk_mir_display_get_cursor_for_name (\"%s\")\n", name); - /* We don't support configurable cursors */ - return g_object_ref (GDK_MIR_DISPLAY (display)->cursor); + return _gdk_mir_cursor_new_for_name (display, name); } static GdkCursor * @@ -495,7 +491,6 @@ static void gdk_mir_display_init (GdkMirDisplay *display) { display->event_source = _gdk_mir_event_source_new (GDK_DISPLAY (display)); - display->cursor = _gdk_mir_cursor_new (GDK_DISPLAY (display), GDK_ARROW); display->keymap = _gdk_mir_keymap_new (); } diff --git a/gdk/mir/gdkmirwindowimpl.c b/gdk/mir/gdkmirwindowimpl.c index e3d21eb497..526e7d4b55 100644 --- a/gdk/mir/gdkmirwindowimpl.c +++ b/gdk/mir/gdkmirwindowimpl.c @@ -552,71 +552,6 @@ gdk_mir_window_impl_reparent (GdkWindow *window, return FALSE; } -static const gchar * -get_cursor_name_for_cursor_type (GdkCursorType cursor_type) -{ - switch (cursor_type) - { - case GDK_BLANK_CURSOR: - return mir_disabled_cursor_name; - case GDK_X_CURSOR: - case GDK_ARROW: - case GDK_CENTER_PTR: - case GDK_DRAFT_LARGE: - case GDK_DRAFT_SMALL: - case GDK_LEFT_PTR: - case GDK_RIGHT_PTR: - case GDK_TOP_LEFT_ARROW: - return mir_arrow_cursor_name; - case GDK_CLOCK: - case GDK_WATCH: - return mir_busy_cursor_name; - case GDK_XTERM: - return mir_caret_cursor_name; - case GDK_HAND1: - case GDK_HAND2: - return mir_pointing_hand_cursor_name; - return mir_open_hand_cursor_name; - case GDK_FLEUR: - return mir_closed_hand_cursor_name; - case GDK_LEFT_SIDE: - case GDK_LEFT_TEE: - case GDK_RIGHT_SIDE: - case GDK_RIGHT_TEE: - case GDK_SB_LEFT_ARROW: - case GDK_SB_RIGHT_ARROW: - return mir_horizontal_resize_cursor_name; - case GDK_BASED_ARROW_DOWN: - case GDK_BASED_ARROW_UP: - case GDK_BOTTOM_SIDE: - case GDK_BOTTOM_TEE: - case GDK_DOUBLE_ARROW: - case GDK_SB_DOWN_ARROW: - case GDK_SB_UP_ARROW: - case GDK_TOP_SIDE: - case GDK_TOP_TEE: - return mir_vertical_resize_cursor_name; - case GDK_BOTTOM_LEFT_CORNER: - case GDK_LL_ANGLE: - case GDK_TOP_RIGHT_CORNER: - case GDK_UR_ANGLE: - return mir_diagonal_resize_bottom_to_top_cursor_name; - case GDK_BOTTOM_RIGHT_CORNER: - case GDK_LR_ANGLE: - case GDK_SIZING: - case GDK_TOP_LEFT_CORNER: - case GDK_UL_ANGLE: - return mir_diagonal_resize_top_to_bottom_cursor_name; - return mir_omnidirectional_resize_cursor_name; - case GDK_SB_V_DOUBLE_ARROW: - return mir_vsplit_resize_cursor_name; - case GDK_SB_H_DOUBLE_ARROW: - return mir_hsplit_resize_cursor_name; - default: - return mir_default_cursor_name; - } -} - static void gdk_mir_window_impl_set_device_cursor (GdkWindow *window, GdkDevice *device, @@ -626,7 +561,7 @@ gdk_mir_window_impl_set_device_cursor (GdkWindow *window, MirCursorConfiguration *configuration; if (cursor) - cursor_name = get_cursor_name_for_cursor_type (gdk_cursor_get_cursor_type (cursor)); + cursor_name = _gdk_mir_cursor_get_name (cursor); else cursor_name = mir_default_cursor_name;