[Spice-devel] [PATCH spice-gtk] Fix disabling mouse acceleration on X11
Marc-André Lureau
marcandre.lureau at gmail.com
Thu Oct 18 11:45:55 PDT 2012
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
--
1.7.11.7
More information about the Spice-devel
mailing list