Re: [PATCH spice-gtk v2 1/5] gtk: Use gdk_cursor_new_for_display

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 19, 2016 at 05:26:32PM +0100, Pavel Grunt wrote:
> Create the cursor when the widget is realized
> ---
>  src/spice-widget.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index 72fbbc8..a27f5a2 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -460,12 +460,12 @@ static void spice_display_finalize(GObject *obj)
>      G_OBJECT_CLASS(spice_display_parent_class)->finalize(obj);
>  }
>  
> -static GdkCursor* get_blank_cursor(void)
> +static GdkCursor* spice_display_get_blank_cursor(SpiceDisplay *display)
>  {
> -    if (g_getenv("SPICE_DEBUG_CURSOR"))
> -        return gdk_cursor_new(GDK_DOT);
> +    GdkDisplay *gdk_display = gdk_window_get_display(GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display))));
> +    GdkCursorType cursor_type = g_getenv("SPICE_DEBUG_CURSOR") ? GDK_DOT : GDK_BLANK_CURSOR;
>  
> -    return gdk_cursor_new(GDK_BLANK_CURSOR);
> +    return gdk_cursor_new_for_display(gdk_display, cursor_type);
>  }

As noted in GdkCursorType documentation, « Note that these IDs are directly
taken from the X cursor font, and many of these cursors are either not useful,
or are not available on other platforms », and on Wayland, GDK_DOT is indeed
not available. When we try to use this, we get the regular mouse pointer
instead, which imo is good enough.
If we want a different cursor to be shown when using SPICE_DEBUG_CURSOR (which
also makes sense!), then I'd use the patch below:

diff --git a/src/spice-widget.c b/src/spice-widget.c
index cf18fa6..2ea2ce5 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -467,9 +467,9 @@ static void spice_display_finalize(GObject *obj)
 static GdkCursor* spice_display_get_blank_cursor(SpiceDisplay *display)
 {
     GdkDisplay *gdk_display = gdk_window_get_display(GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display))));
-    GdkCursorType cursor_type = g_getenv("SPICE_DEBUG_CURSOR") ? GDK_DOT : GDK_BLANK_CURSOR;
+    const char *cursor_name = g_getenv("SPICE_DEBUG_CURSOR") ? "crosshair" : "none";

-    return gdk_cursor_new_for_display(gdk_display, cursor_type);
+    return gdk_cursor_new_from_name(gdk_display, cursor_name);
 }

 static gboolean grab_broken(SpiceDisplay *self, GdkEventGrabBroken *event,


Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]