[Spice-commits] 3 commits - gtk/spice-widget.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Fri Dec 9 07:11:17 PST 2011


 gtk/spice-widget.c |   36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

New commits:
commit 3fabb6464bf4860b758f44cf02faf386d3b5d95f
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Dec 9 15:56:16 2011 +0100

    Don't leak cursor shape objects

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 9868947..9e45979 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -280,6 +280,21 @@ static void spice_display_finalize(GObject *obj)
     g_free(d->activeseq);
     d->activeseq = NULL;
 
+    if (d->show_cursor) {
+        gdk_cursor_unref(d->show_cursor);
+        d->show_cursor = NULL;
+    }
+
+    if (d->mouse_cursor) {
+        gdk_cursor_unref(d->mouse_cursor);
+        d->mouse_cursor = NULL;
+    }
+
+    if (d->mouse_pixbuf) {
+        g_object_unref(d->mouse_pixbuf);
+        d->mouse_pixbuf = NULL;
+    }
+
     G_OBJECT_CLASS(spice_display_parent_class)->finalize(obj);
 }
 
@@ -1486,6 +1501,11 @@ static void cursor_set(SpiceCursorChannel *channel,
 
     cursor_invalidate(display);
 
+    if (d->show_cursor) {
+        gdk_cursor_unref(d->show_cursor);
+        d->show_cursor = NULL;
+    }
+
     if (d->mouse_cursor) {
         gdk_cursor_unref(d->mouse_cursor);
         d->mouse_cursor = NULL;
commit 1485ecc67b7377ec3abc4c3367690dcad963a751
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Dec 9 15:33:25 2011 +0100

    Refresh mouse shape/visibility when changing mouse mode
    
    This fixes the dynamic mode changing when running/quitting the agent.

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index b9b8e8a..9868947 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -1400,12 +1400,11 @@ static void mouse_update(SpiceChannel *channel, gpointer data)
     g_object_get(channel, "mouse-mode", &d->mouse_mode, NULL);
     SPICE_DEBUG("mouse mode %d", d->mouse_mode);
 
-    d->mouse_guest_x = -1;
-    d->mouse_guest_y = -1;
-    if (d->mouse_mode == SPICE_MOUSE_MODE_CLIENT) {
+    if (d->mouse_mode == SPICE_MOUSE_MODE_CLIENT)
         try_mouse_ungrab(display);
-    }
+
     update_mouse_pointer(display);
+    cursor_invalidate(display);
 }
 
 static void primary_create(SpiceChannel *channel, gint format,
commit 68d4393d4a0c9874bb1e57148ab0b8009bdeabcc
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Sat Dec 3 15:27:49 2011 +0100

    Correctly hide client pointer (in server mode)
    
    The hide cursor event happen when the widget is not yet
    realized. Forcing realize may fail if the widget is not yet embedded
    for example. Instead, let's update the cursor whenever there is a
    draw().
    
    v2: do not call gdk_window_set_cursor() with the same cursor

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index d6a8602..b9b8e8a 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -556,11 +556,13 @@ static void update_mouse_pointer(SpiceDisplay *display)
 
     switch (d->mouse_mode) {
     case SPICE_MOUSE_MODE_CLIENT:
-        gdk_window_set_cursor(window, d->mouse_cursor);
+        if (gdk_window_get_cursor(window) != d->mouse_cursor)
+            gdk_window_set_cursor(window, d->mouse_cursor);
         break;
     case SPICE_MOUSE_MODE_SERVER:
         if (!d->mouse_grab_active) {
-            gdk_window_set_cursor(window, NULL);
+            if (gdk_window_get_cursor(window) != NULL)
+                gdk_window_set_cursor(window, NULL);
         } else {
             try_mouse_grab(display);
         }
@@ -751,6 +753,7 @@ static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
     }
 
     spicex_draw_event(display, cr);
+    update_mouse_pointer(display);
 
     return true;
 }
@@ -769,6 +772,8 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
     }
 
     spicex_expose_event(display, expose);
+    update_mouse_pointer(display);
+
     return true;
 }
 #endif


More information about the Spice-commits mailing list