[Spice-commits] 2 commits - gtk/spice-widget-cairo.c gtk/spice-widget.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Mon Oct 27 02:26:47 PDT 2014
gtk/spice-widget-cairo.c | 2 +-
gtk/spice-widget.c | 21 +++++++++++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
New commits:
commit d9959f6f5a43fef55d6b8a4eaec2be9fcc853fe7
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Fri Oct 24 18:33:14 2014 +0200
gtk: hide cursor when ungrabbed
Let's avoid confusion of multiple pointers visible on the client
desktop: hide the guest pointer if the spice client doesn't have the
grab, display it again when the grab is taken back.
diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c
index 1c7b358..05d708f 100644
--- a/gtk/spice-widget-cairo.c
+++ b/gtk/spice-widget-cairo.c
@@ -118,7 +118,7 @@ void spicex_draw_event(SpiceDisplay *display, cairo_t *cr)
if (d->mouse_mode == SPICE_MOUSE_MODE_SERVER &&
d->mouse_guest_x != -1 && d->mouse_guest_y != -1 &&
- !d->show_cursor) {
+ !d->show_cursor && d->mouse_grab_active) {
GdkPixbuf *image = d->mouse_pixbuf;
if (image != NULL) {
gdk_cairo_set_source_pixbuf(cr, image,
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 98b8adf..62a98dc 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -896,10 +896,9 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
} else {
d->mouse_grab_active = true;
g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, true);
- }
-
- if (status == GDK_GRAB_SUCCESS)
set_mouse_accel(display, FALSE);
+ gtk_widget_queue_draw(GTK_WIDGET(display));
+ }
end:
gdk_cursor_unref(blank);
@@ -1018,6 +1017,8 @@ static void try_mouse_ungrab(SpiceDisplay *display)
gtk_widget_get_screen(GTK_WIDGET(display)),
x, y);
+ gtk_widget_queue_draw(GTK_WIDGET(display));
+
g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
}
commit 7630c0dda9121978f76bdac621319d9ad96f1395
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Fri Oct 24 18:31:25 2014 +0200
gtk: keep cursor in the same place on ungrab
On ungrab, the transition from remote (server-side) cursor to host
cursor makes it jump somewhere else rather than staying at the same
place. Restore cursor position on ungrab to match with guest position.
https://bugs.freedesktop.org/show_bug.cgi?id=85117
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 1220030..98b8adf 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -992,6 +992,8 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
static void try_mouse_ungrab(SpiceDisplay *display)
{
SpiceDisplayPrivate *d = display->priv;
+ double s;
+ int x, y;
if (!d->mouse_grab_active)
return;
@@ -1005,6 +1007,17 @@ static void try_mouse_ungrab(SpiceDisplay *display)
d->mouse_grab_active = false;
+ spice_display_get_scaling(display, &s, &x, &y, NULL, NULL);
+
+ gdk_window_get_root_coords(gtk_widget_get_window(GTK_WIDGET(display)),
+ x + d->mouse_guest_x * s,
+ y + d->mouse_guest_y * s,
+ &x, &y);
+
+ gdk_display_warp_pointer(gtk_widget_get_display(GTK_WIDGET(display)),
+ gtk_widget_get_screen(GTK_WIDGET(display)),
+ x, y);
+
g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, false);
}
@@ -2581,4 +2594,3 @@ GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay *display)
(GdkPixbufDestroyNotify)g_free, NULL);
return pixbuf;
}
-
More information about the Spice-commits
mailing list