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

Hans de Goede hdegoede at redhat.com
Sun Oct 21 10:36:20 PDT 2012


Looks good,

ACK series

On 10/19/2012 07:28 PM, 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.
>
> 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
>
>


More information about the Spice-devel mailing list