[Spice-commits] 3 commits - gtk/spice-widget.c gtk/spice-widget-priv.h spice-common
Marc-André Lureau
elmarco at kemper.freedesktop.org
Tue Oct 23 02:41:40 PDT 2012
gtk/spice-widget-priv.h | 7 +++++
gtk/spice-widget.c | 67 +++++++++++++++++++++++++++---------------------
spice-common | 2 -
3 files changed, 47 insertions(+), 29 deletions(-)
New commits:
commit 7b6dbf4b3ea6c5b8cb9acbfe333dfaaebf7385dc
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Fri Oct 19 18:14:53 2012 +0200
win32: implement disabling mouse accel
https://bugzilla.redhat.com/show_bug.cgi?id=867885
diff --git a/gtk/spice-widget-priv.h b/gtk/spice-widget-priv.h
index 4ee0e59..597ce10 100644
--- a/gtk/spice-widget-priv.h
+++ b/gtk/spice-widget-priv.h
@@ -114,6 +114,8 @@ struct _SpiceDisplayPrivate {
gint mark;
#ifdef WIN32
HHOOK keyboard_hook;
+ int win_mouse[3];
+ int win_mouse_speed;
#endif
guint keypress_delay;
gint zoom_level;
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 5fab420..cdcff03 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -709,6 +709,17 @@ static void set_mouse_accel(SpiceDisplay *display, gboolean enabled)
SPICE_DEBUG("disabled X11 mouse motion %d %d %d",
d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
}
+#elif defined GDK_WINDOWING_WIN32
+ if (enabled) {
+ g_return_if_fail(SystemParametersInfo(SPI_SETMOUSE, 0, &d->win_mouse, 0));
+ g_return_if_fail(SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)d->win_mouse_speed, 0));
+ } else {
+ int accel[3] = { 0, 0, 0 }; // disabled
+ g_return_if_fail(SystemParametersInfo(SPI_GETMOUSE, 0, &d->win_mouse, 0));
+ g_return_if_fail(SystemParametersInfo(SPI_GETMOUSESPEED, 0, &d->win_mouse_speed, 0));
+ g_return_if_fail(SystemParametersInfo(SPI_SETMOUSE, 0, &accel, SPIF_SENDCHANGE));
+ g_return_if_fail(SystemParametersInfo(SPI_SETMOUSESPEED, 0, (PVOID)10, SPIF_SENDCHANGE)); // default
+ }
#else
g_warning("Mouse acceleration code missing for your platform");
#endif
commit fef1d486a8f3e3125b0d5f4eccc9a2e8a3dd100a
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Oct 18 21:14:55 2012 +0200
move mouse acceleration code in a seperate function
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index a2691f7..5fab420 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -689,6 +689,31 @@ static void update_keyboard_grab(SpiceDisplay *display)
try_keyboard_ungrab(display);
}
+static void set_mouse_accel(SpiceDisplay *display, gboolean enabled)
+{
+ SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+
+#if defined GDK_WINDOWING_X11
+ GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
+ Display *x_display = GDK_WINDOW_XDISPLAY(w);
+
+ if (enabled) {
+ /* restore mouse acceleration */
+ XChangePointerControl(x_display, True, True,
+ d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
+ } else {
+ 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("disabled X11 mouse motion %d %d %d",
+ d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
+ }
+#else
+ g_warning("Mouse acceleration code missing for your platform");
+#endif
+}
+
static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
{
SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
@@ -738,19 +763,8 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
}
#endif
-#ifdef GDK_WINDOWING_X11
- if (status == GDK_GRAB_SUCCESS) {
- GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
- Display *x_display = GDK_WINDOW_XDISPLAY(w);
-
- 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
+ if (status == GDK_GRAB_SUCCESS)
+ set_mouse_accel(display, FALSE);
gdk_cursor_unref(blank);
return status;
@@ -838,16 +852,7 @@ static void try_mouse_ungrab(SpiceDisplay *display)
#ifdef WIN32
ClipCursor(NULL);
#endif
-#ifdef GDK_WINDOWING_X11
- {
- GdkWindow *w = GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
- Display *x_display = GDK_WINDOW_XDISPLAY(w);
-
- /* restore mouse acceleration */
- XChangePointerControl(x_display, True, True,
- d->x11_accel_numerator, d->x11_accel_denominator, d->x11_threshold);
- }
-#endif
+ set_mouse_accel(display, TRUE);
d->mouse_grab_active = false;
diff --git a/spice-common b/spice-common
index 2226078..8543d04 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 222607814fde8d42bd1b08ad4aaf8439e729c593
+Subproject commit 8543d04cd238638ac54912f29a0990915ff51b6d
commit 6ab3688e51a59254c29d95c07626742e2b276ef8
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Thu Oct 18 20:45:03 2012 +0200
Fix disabling mouse acceleration on X11
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
changes, and restore settings when un-inhibiting.
https://bugzilla.redhat.com/show_bug.cgi?id=867885
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-commits
mailing list