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

Hans de Goede hdegoede at redhat.com
Fri Oct 19 02:49:51 PDT 2012


Hi,

On 10/18/2012 08:45 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.

Hmm, interesting. I'm pretty sure I tested the original patch, and back
in the days I tested it, it worked as advertised. But maybe a newer version
of Xorg has changed its behavior. Or maybe my testing was wrong...

 From the XChangePointerControl man-page:

        do_accel  Specifies a Boolean value that controls whether the values
                  for the accel_numerator or accel_denominator are used.

        do_threshold
                  Specifies a Boolean value that controls whether the value for
                  the threshold is used.

I interpreted setting these 2 to false as meaning disable accel, but one
could argue they mean don't change accel / threshold, which is an interpretation
which would explain your patch. I assume you've tested this, so:

ACK.

Regards,

Hans



>
> 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