Re: [PATCH spice-gtk 1/2] gtk: keep cursor in the same place on ungrab

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

 



Hey,

On Fri, Oct 24, 2014 at 06:34:16PM +0200, Marc-André Lureau wrote:
> On ungrab, the transition from remote (server-side) cursor to host
> cursor makes it jump somewhere else rather than staying at the same
> place. Restore cursor position on ungrab to match with guest position.
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=85117
> ---
>  gtk/spice-widget.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index 1220030..85757cb 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -992,6 +992,8 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
>  static void try_mouse_ungrab(SpiceDisplay *display)
>  {
>      SpiceDisplayPrivate *d = display->priv;
> +    double s;
> +    int x, y;
>  
>      if (!d->mouse_grab_active)
>          return;
> @@ -1005,6 +1007,17 @@ static void try_mouse_ungrab(SpiceDisplay *display)
>  
>      d->mouse_grab_active = false;
>  
> +    spice_display_get_scaling(display, &s, &x, &y, NULL, NULL);
> +
> +    gdk_window_get_root_coords(gtk_widget_get_window(GTK_WIDGET(display)),
> +                               x + d->mouse_guest_x * s,
> +                               y + d->mouse_guest_y * s,
> +                               &x, &y);
> +
> +    GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(display));
> +    gdk_display_warp_pointer(gtk_widget_get_display(GTK_WIDGET(display)),
> +                             screen, x, y);

A bit inconsistent to have a local 'screen' variable, but not a local
'gdk_display' at the same time. GdkScreen *screen should be declared at
the beginning of a block, so I'd just get rid of it:

   gdk_display_warp_pointer(gtk_widget_get_display(GTK_WIDGET(display)),
                            gtk_widget_get_screen(GTK_WIDGET(display));
                            x, y);

gdk_display_warp_pointer is documented as being deprecated in favour of
gdk_device_warp but I did not get a warning when trying to compile this.

ACK.

Christophe

Attachment: pgpVCtrjAffpC.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]