[Spice-devel] [PATCH spice-gtk] Fix disabling mouse acceleration on X11

Christophe Fergeau cfergeau at redhat.com
Fri Oct 19 02:08:16 PDT 2012


On Thu, Oct 18, 2012 at 08:45:55PM +0200, Marc-André Lureau wrote:
> It turns out the acceleration code didn't work, because we didn't set
> it to the default values. Then we need to restore it back. Eventually,
> it would be nicer to inhibit gnome-settings-daemon to apply devices
> ghanges, and restore settings when un-inhibiting.

ghanges -> changes ?
The patch makes sense to me, though it would be nice to get confirmation
from Hans that it's good.

Christophe

> 
> https://bugzilla.redhat.com/show_bug.cgi?id=867885
> ---
>  gtk/spice-widget-priv.h |  5 +++++
>  gtk/spice-widget.c      | 23 +++++++++--------------
>  2 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/gtk/spice-widget-priv.h b/gtk/spice-widget-priv.h
> index 4ed5fbc..4ee0e59 100644
> --- a/gtk/spice-widget-priv.h
> +++ b/gtk/spice-widget-priv.h
> @@ -117,6 +117,11 @@ struct _SpiceDisplayPrivate {
>  #endif
>      guint                   keypress_delay;
>      gint                    zoom_level;
> +#ifdef GDK_WINDOWING_X11
> +    int                     x11_accel_numerator;
> +    int                     x11_accel_denominator;
> +    int                     x11_threshold;
> +#endif
>  };
>  
>  int      spicex_image_create                 (SpiceDisplay *display);
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index 779341b..a2691f7 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -740,16 +740,15 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
>  
>  #ifdef GDK_WINDOWING_X11
>      if (status == GDK_GRAB_SUCCESS) {
> -        int accel_numerator;
> -        int accel_denominator;
> -        int threshold;
>          GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
>          Display *x_display = GDK_WINDOW_XDISPLAY(w);
>  
> -        XGetPointerControl(x_display, &accel_numerator, &accel_denominator,
> -                           &threshold);
> -        XChangePointerControl(x_display, False, False, accel_numerator,
> -                              accel_denominator, threshold);
> +        XGetPointerControl(x_display,
> +                           &d->x11_accel_numerator, &d->x11_accel_denominator, &d->x11_threshold);
> +        /* set mouse acceleration to default */
> +        XChangePointerControl(x_display, True, True, -1, -1, -1);
> +        SPICE_DEBUG("updated mouse motion %d %d %d",
> +                    d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
>      }
>  #endif
>  
> @@ -841,16 +840,12 @@ static void try_mouse_ungrab(SpiceDisplay *display)
>  #endif
>  #ifdef GDK_WINDOWING_X11
>      {
> -        int accel_numerator;
> -        int accel_denominator;
> -        int threshold;
>          GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
>          Display *x_display = GDK_WINDOW_XDISPLAY(w);
>  
> -        XGetPointerControl(x_display, &accel_numerator, &accel_denominator,
> -                           &threshold);
> -        XChangePointerControl(x_display, True, True, accel_numerator,
> -                              accel_denominator, threshold);
> +        /* restore mouse acceleration */
> +        XChangePointerControl(x_display, True, True,
> +                              d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
>      }
>  #endif
>  
> -- 
> 1.7.11.7
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20121019/c37dd142/attachment-0001.pgp>


More information about the Spice-devel mailing list