[Spice-devel] [PATCH spice-gtk] Disable mouse accelleration when grabbing the mouse (in server mode)
Alon Levy
alevy at redhat.com
Wed Dec 14 07:00:34 PST 2011
On Wed, Dec 14, 2011 at 02:17:15PM +0100, Hans de Goede wrote:
> Otherwise accel will be applied twice, once by the client and then once
> more by the guest. Unfortunately there seems to be no gdk / gtk API for this
> so this patch uses direct libX11 calls.
>
ACK.
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
> gtk/spice-widget.c | 33 +++++++++++++++++++++++++++++++++
> 1 files changed, 33 insertions(+), 0 deletions(-)
>
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index d2d09af..5ed2e10 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -25,6 +25,10 @@
> #include <X11/XKBlib.h>
> #include <gdk/gdkx.h>
> #endif
> +#ifdef GDK_WINDOWING_X11
> +#include <X11/Xlib.h>
> +#include <gdk/gdkx.h>
> +#endif
> #ifdef WIN32
> #include <windows.h>
> #include <gdk/gdkwin32.h>
> @@ -568,6 +572,21 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
> #endif
> gtk_grab_add(GTK_WIDGET(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);
> + }
> +#endif
> +
> gdk_cursor_unref(blank);
> return status;
> }
> @@ -670,6 +689,20 @@ static void try_mouse_ungrab(SpiceDisplay *display)
> #ifdef WIN32
> ClipCursor(NULL);
> #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);
> + }
> +#endif
>
> d->mouse_grab_active = false;
>
> --
> 1.7.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list