[Spice-commits] 3 commits - doc/reference gtk/channel-display.c gtk/channel-display.h gtk/channel-main.c gtk/gio-coroutine.c gtk/map-file gtk/spice-gtk-sym-file gtk/spice-session.c gtk/spice-widget.c gtk/spice-widget.h

Jonathon Jongsma jjongsma at kemper.freedesktop.org
Thu Nov 7 12:21:05 PST 2013


 doc/reference/spice-gtk-sections.txt |    2 -
 gtk/channel-display.c                |    2 -
 gtk/channel-display.h                |    9 -------
 gtk/channel-main.c                   |    5 +++
 gtk/gio-coroutine.c                  |   37 +++++++++++++++-------------
 gtk/map-file                         |    1 
 gtk/spice-gtk-sym-file               |    1 
 gtk/spice-session.c                  |    8 +++---
 gtk/spice-widget.c                   |   45 +++++++++--------------------------
 gtk/spice-widget.h                   |    2 -
 10 files changed, 42 insertions(+), 70 deletions(-)

New commits:
commit a1ae578bc1fb514fac2ac8a887fb89c09f10ecde
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Nov 6 17:27:39 2013 -0600

    Guarantee that 'uuid' property is notified after connection
    
    This creates a synchronization point and allows API users to rely on the fact
    that they'll always get a UUID notification before all of the channels are
    created.

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 5c33e67..24f7428 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1524,6 +1524,11 @@ static void main_handle_channels_list(SpiceChannel *channel, SpiceMsgIn *in)
     int i;
 
     session = spice_channel_get_session(channel);
+
+    /* guarantee that uuid is notified before setting up the channels, even if
+     * the server is older and doesn't actually send the uuid */
+    g_object_notify_main_context(G_OBJECT(session), "uuid");
+
     for (i = 0; i < msg->num_of_channels; i++) {
         channel_new_t *c;
 
commit 71ec4960a9db8d19dfb83be5c1041128b8673707
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Nov 6 17:25:47 2013 -0600

    Make sure property notifications are done in the main context
    
    Modify g_object_notify_main_conetxt() to work whether it's called from the main
    context or a coroutine context.  Change object notify calls in SpiceSession to
    use g_object_notify_main_context() instead of g_object_notify().

diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c
index 355c75c..dd2b9fc 100644
--- a/gtk/gio-coroutine.c
+++ b/gtk/gio-coroutine.c
@@ -252,21 +252,24 @@ void g_object_notify_main_context(GObject *object,
 {
     struct signal_data data;
 
-    g_return_if_fail(coroutine_self()->caller);
-
-    data.object = object;
-    data.caller = coroutine_self();
-    data.params = (gpointer)property_name;
-    data.notified = FALSE;
-
-    g_idle_add(notify_main_context, &data);
-
-    /* This switches to the system coroutine context, lets
-     * the idle function run to dispatch the signal, and
-     * finally returns once complete. ie this is synchronous
-     * from the POV of the coroutine despite there being
-     * an idle function involved
-     */
-    coroutine_yield(NULL);
-    g_warn_if_fail(data.notified);
+    if (IN_MAIN_CONTEXT) {
+        g_object_notify(object, property_name);
+    } else {
+
+        data.object = object;
+        data.caller = coroutine_self();
+        data.params = (gpointer)property_name;
+        data.notified = FALSE;
+
+        g_idle_add(notify_main_context, &data);
+
+        /* This switches to the system coroutine context, lets
+         * the idle function run to dispatch the signal, and
+         * finally returns once complete. ie this is synchronous
+         * from the POV of the coroutine despite there being
+         * an idle function involved
+         */
+        coroutine_yield(NULL);
+        g_warn_if_fail(data.notified);
+    }
 }
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 79a13de..bcbba27 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -608,7 +608,7 @@ static void spice_session_set_property(GObject      *gobject,
         break;
     case PROP_READ_ONLY:
         s->read_only = g_value_get_boolean(value);
-        g_object_notify(gobject, "read-only");
+        g_object_notify_main_context(gobject, "read-only");
         break;
     case PROP_CACHE_SIZE:
         s->images_cache_size = g_value_get_int(value);
@@ -2033,7 +2033,7 @@ void spice_session_set_migration_state(SpiceSession *session, SpiceSessionMigrat
 
     g_return_if_fail(s != NULL);
     s->migration_state = state;
-    g_object_notify(G_OBJECT(session), "migration-state");
+    g_object_notify_main_context(G_OBJECT(session), "migration-state");
 }
 
 G_GNUC_INTERNAL
@@ -2128,7 +2128,7 @@ void spice_session_set_uuid(SpiceSession *session, guint8 uuid[16])
     g_return_if_fail(s != NULL);
     memcpy(s->uuid, uuid, sizeof(s->uuid));
 
-    g_object_notify(G_OBJECT(session), "uuid");
+    g_object_notify_main_context(G_OBJECT(session), "uuid");
 }
 
 G_GNUC_INTERNAL
@@ -2140,7 +2140,7 @@ void spice_session_set_name(SpiceSession *session, const gchar *name)
     g_free(s->name);
     s->name = g_strdup(name);
 
-    g_object_notify(G_OBJECT(session), "name");
+    g_object_notify_main_context(G_OBJECT(session), "name");
 }
 
 G_GNUC_INTERNAL
commit 2ef5ef5932a4ab572026e313593825927ad1efd2
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Thu Nov 7 11:46:44 2013 -0600

    Revert "Add ability to get SpiceDisplay resolution"
    
    This reverts commit a285e0187d15ad650f6524f3811072fa55b20617.
    
    This API was not actually needed for what I intended to use it for.  So revert
    for now.  We can always add it back if necessary in the future.
    
    Conflicts:
    	gtk/spice-widget.c

diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 9d8551b..8d61aa9 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -146,7 +146,6 @@ SpiceAudioPrivate
 <TITLE>SpiceDisplayChannel</TITLE>
 SpiceDisplayChannel
 SpiceDisplayChannelClass
-SpiceDisplayMonitorConfig
 <SUBSECTION Standard>
 SPICE_DISPLAY_CHANNEL
 SPICE_IS_DISPLAY_CHANNEL
@@ -353,7 +352,6 @@ spice_display_set_grab_keys
 spice_display_get_grab_keys
 spice_display_send_keys
 spice_display_get_pixbuf
-spice_display_get_monitor_config
 <SUBSECTION>
 SpiceGrabSequence
 spice_grab_sequence_new
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 4d55337..93521da 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -262,7 +262,7 @@ static void spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
     /**
      * SpiceDisplayChannel:monitors:
      *
-     * Current monitors configuration. An array of #SpiceDisplayMonitorConfig
+     * Current monitors configuration.
      *
      * Since: 0.13
      */
diff --git a/gtk/channel-display.h b/gtk/channel-display.h
index 4a5428e..88e60d9 100644
--- a/gtk/channel-display.h
+++ b/gtk/channel-display.h
@@ -33,15 +33,6 @@ typedef struct _SpiceDisplayChannel SpiceDisplayChannel;
 typedef struct _SpiceDisplayChannelClass SpiceDisplayChannelClass;
 typedef struct _SpiceDisplayChannelPrivate SpiceDisplayChannelPrivate;
 
-/**
- * SpiceDisplayMonitorConfig:
- * @id: the id of the monitor
- * @surface_id: the surface id of the monitor
- * @x: the position of the monitor on the x axis
- * @y: the position of the monitor on the y axis
- * @width: the width of the monitor
- * @height: the height of the monitor
- */
 typedef struct _SpiceDisplayMonitorConfig SpiceDisplayMonitorConfig;
 struct _SpiceDisplayMonitorConfig {
     guint id;
diff --git a/gtk/map-file b/gtk/map-file
index d093f7c..368b44f 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -32,7 +32,6 @@ spice_display_new_with_monitor;
 spice_display_paste_from_guest;
 spice_display_send_keys;
 spice_display_set_grab_keys;
-spice_display_get_monitor_config;
 spice_error_get_type;
 spice_get_option_group;
 spice_grab_sequence_as_string;
diff --git a/gtk/spice-gtk-sym-file b/gtk/spice-gtk-sym-file
index 8d3c9a0..1574e07 100644
--- a/gtk/spice-gtk-sym-file
+++ b/gtk/spice-gtk-sym-file
@@ -9,7 +9,6 @@ spice_display_new_with_monitor
 spice_display_paste_from_guest
 spice_display_send_keys
 spice_display_set_grab_keys
-spice_display_get_monitor_config
 spice_grab_sequence_as_string
 spice_grab_sequence_copy
 spice_grab_sequence_free
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index d5661d1..0447dda 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -278,48 +278,25 @@ static gint get_display_id(SpiceDisplay *display)
     return d->channel_id;
 }
 
-/**
- * spice_display_get_monitor_config:
- * @display: the display widget
- *
- * Gets the monitor configuration for the display, from which you can determine
- * the current position and resolution of the monitor
- *
- * Returns (transfer none): the monitor configuration for the display
- * Since: 0.22
- **/
-const SpiceDisplayMonitorConfig* spice_display_get_monitor_config(SpiceDisplay *display)
+static void update_monitor_area(SpiceDisplay *display)
 {
-    int i;
+    SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+    SpiceDisplayMonitorConfig *cfg, *c = NULL;
     GArray *monitors = NULL;
-    SpiceDisplayPrivate *d = NULL;
-    SpiceDisplayMonitorConfig* c = NULL;
-
-    g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
+    int i;
 
-    d = display->priv;
-    g_return_val_if_fail(d->monitor_id >= 0, NULL);
+    SPICE_DEBUG("update monitor area %d:%d", d->channel_id, d->monitor_id);
+    if (d->monitor_id < 0)
+        goto whole;
 
     g_object_get(d->display, "monitors", &monitors, NULL);
     for (i = 0; monitors != NULL && i < monitors->len; i++) {
-        SpiceDisplayMonitorConfig *cfg = &g_array_index(monitors,
-                                                        SpiceDisplayMonitorConfig,
-                                                        i);
+        cfg = &g_array_index(monitors, SpiceDisplayMonitorConfig, i);
         if (cfg->id == d->monitor_id) {
-            c = cfg;
-            break;
+           c = cfg;
+           break;
         }
     }
-
-    g_clear_pointer(&monitors, g_array_unref);
-    return c;
-}
-
-static void update_monitor_area(SpiceDisplay *display)
-{
-    SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
-    const SpiceDisplayMonitorConfig *c = spice_display_get_monitor_config(display);
-
     if (c == NULL) {
         SPICE_DEBUG("update monitor: no monitor %d", d->monitor_id);
         set_monitor_ready(display, false);
@@ -341,9 +318,11 @@ static void update_monitor_area(SpiceDisplay *display)
                                   c->x, c->y, c->width, c->height, FALSE);
 
     update_area(display, c->x, c->y, c->width, c->height);
+    g_clear_pointer(&monitors, g_array_unref);
     return;
 
 whole:
+    g_clear_pointer(&monitors, g_array_unref);
     /* by display whole surface */
     update_area(display, 0, 0, d->width, d->height);
     set_monitor_ready(display, true);
diff --git a/gtk/spice-widget.h b/gtk/spice-widget.h
index f7cfbf1..d239ed2 100644
--- a/gtk/spice-widget.h
+++ b/gtk/spice-widget.h
@@ -80,8 +80,6 @@ void spice_display_send_keys(SpiceDisplay *display, const guint *keyvals,
                              int nkeyvals, SpiceDisplayKeyEvent kind);
 GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay *display);
 
-const SpiceDisplayMonitorConfig* spice_display_get_monitor_config(SpiceDisplay *display);
-
 #ifndef SPICE_DISABLE_DEPRECATED
 SPICE_DEPRECATED_FOR(spice_gtk_session_copy_to_guest)
 void spice_display_copy_to_guest(SpiceDisplay *display);


More information about the Spice-commits mailing list