[Spice-commits] 2 commits - doc/reference src/channel-display.c src/channel-display.h src/map-file src/spice-glib-sym-file src/spicy.c

Pavel Grunt pgrunt at kemper.freedesktop.org
Tue Nov 17 23:34:38 PST 2015


 doc/reference/spice-gtk-sections.txt |    1 
 src/channel-display.c                |   41 ++++++++++++++++++----
 src/channel-display.h                |    1 
 src/map-file                         |    1 
 src/spice-glib-sym-file              |    1 
 src/spicy.c                          |   63 +++++++++++++++++++++++++++++++++++
 6 files changed, 101 insertions(+), 7 deletions(-)

New commits:
commit d734a62e2f38166c88eb8565f8c4309db7a9e714
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Tue Nov 10 14:13:55 2015 +0100

    spicy: Add support for changing compression

diff --git a/src/spicy.c b/src/spicy.c
index 4de56d9..67873ed 100644
--- a/src/spicy.c
+++ b/src/spicy.c
@@ -633,6 +633,9 @@ static const GtkActionEntry entries[] = {
         .name        = "OptionMenu",
         .label       = "_Options",
     },{
+        .name        = "CompressionMenu",
+        .label       = "_Preferred image compression",
+    },{
         .name        = "HelpMenu",
         .label       = "_Help",
     },{
@@ -753,6 +756,40 @@ static const GtkToggleActionEntry tentries[] = {
     }
 };
 
+static const GtkRadioActionEntry compression_entries[] = {
+    {
+        .name  = "auto-glz",
+        .label = "auto-glz",
+        .value = SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
+    },{
+        .name  = "auto-lz",
+        .label = "auto-lz",
+        .value = SPICE_IMAGE_COMPRESSION_AUTO_LZ,
+    },{
+        .name  = "quic",
+        .label = "quic",
+        .value = SPICE_IMAGE_COMPRESSION_QUIC,
+    },{
+        .name  = "glz",
+        .label = "glz",
+        .value = SPICE_IMAGE_COMPRESSION_GLZ,
+    },{
+        .name  = "lz",
+        .label = "lz",
+        .value = SPICE_IMAGE_COMPRESSION_LZ,
+    },{
+#ifdef USE_LZ4
+        .name  = "lz4",
+        .label = "lz4",
+        .value = SPICE_IMAGE_COMPRESSION_LZ4,
+    },{
+#endif
+        .name  = "off",
+        .label = "off",
+        .value = SPICE_IMAGE_COMPRESSION_OFF,
+    }
+};
+
 static char ui_xml[] =
 "<ui>\n"
 "  <menubar action='MainMenu'>\n"
@@ -788,6 +825,17 @@ static char ui_xml[] =
 "      <menuitem action='disable-inputs'/>\n"
 "      <menuitem action='auto-clipboard'/>\n"
 "      <menuitem action='auto-usbredir'/>\n"
+"      <menu action='CompressionMenu'>\n"
+"        <menuitem action='auto-glz'/>\n"
+"        <menuitem action='auto-lz'/>\n"
+"        <menuitem action='quic'/>\n"
+"        <menuitem action='glz'/>\n"
+"        <menuitem action='lz'/>\n"
+#ifdef USE_LZ4
+"        <menuitem action='lz4'/>\n"
+#endif
+"        <menuitem action='off'/>\n"
+"      </menu>\n"
 "    </menu>\n"
 "    <menu action='HelpMenu'>\n"
 "      <menuitem action='About'/>\n"
@@ -849,6 +897,14 @@ static gboolean configure_event_cb(GtkWidget         *widget,
     return FALSE;
 }
 
+static void compression_cb(GtkRadioAction *action G_GNUC_UNUSED,
+                           GtkRadioAction *current,
+                           gpointer user_data)
+{
+    spice_display_change_preferred_compression(SPICE_CHANNEL(user_data),
+                                               gtk_radio_action_get_current_value(current));
+}
+
 static void
 spice_window_class_init (SpiceWindowClass *klass)
 {
@@ -896,6 +952,13 @@ static SpiceWindow *create_spice_window(spice_connection *conn, SpiceChannel *ch
     gtk_action_group_add_actions(win->ag, entries, G_N_ELEMENTS(entries), win);
     gtk_action_group_add_toggle_actions(win->ag, tentries,
                                         G_N_ELEMENTS(tentries), win);
+    gtk_action_group_add_radio_actions(win->ag, compression_entries,
+                                       G_N_ELEMENTS(compression_entries), -1,
+                                       G_CALLBACK(compression_cb), win->display_channel);
+    if (!spice_channel_test_capability(win->display_channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION)) {
+        GtkAction *compression_menu_action = gtk_action_group_get_action(win->ag, "CompressionMenu");
+        gtk_action_set_sensitive(compression_menu_action, FALSE);
+    }
     gtk_ui_manager_insert_action_group(win->ui, win->ag, 0);
     gtk_window_add_accel_group(GTK_WINDOW(win->toplevel),
                                gtk_ui_manager_get_accel_group(win->ui));
commit 471cf4226444351e2477640885952613f9bd8856
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Tue Nov 10 13:33:21 2015 +0100

    channel-display: Add spice_display_change_preferred_compression

diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index d8c4c79..f156a3f 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -159,6 +159,7 @@ SpiceDisplayChannel
 SpiceDisplayChannelClass
 <SUBSECTION>
 spice_display_get_primary
+spice_display_change_preferred_compression
 <SUBSECTION Standard>
 SPICE_DISPLAY_CHANNEL
 SPICE_IS_DISPLAY_CHANNEL
diff --git a/src/channel-display.c b/src/channel-display.c
index 9e42dd9..dc73235 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -427,6 +427,38 @@ gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
     return TRUE;
 }
 
+/**
+ * spice_display_change_preferred_compression:
+ * @channel: a #SpiceDisplayChannel
+ * @compression: a #SpiceImageCompression
+ *
+ * Tells the spice server to change the preferred image compression
+ * for the @channel.
+ *
+ * Since: 0.31
+ */
+void spice_display_change_preferred_compression(SpiceChannel *channel, gint compression)
+{
+    SpiceMsgOut *out;
+    SpiceMsgcDisplayPreferredCompression pref_comp_msg;
+
+    g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));
+    g_return_if_fail(compression > SPICE_IMAGE_COMPRESSION_INVALID &&
+                     compression < SPICE_IMAGE_COMPRESSION_ENUM_END);
+
+    if (!spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION)) {
+        CHANNEL_DEBUG(channel, "does not have capability to change the preferred compression");
+        return;
+    }
+
+    CHANNEL_DEBUG(channel, "changing preferred compression to %d", compression);
+
+    pref_comp_msg.image_compression = compression;
+    out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION);
+    out->marshallers->msgc_display_preferred_compression(out->marshaller, &pref_comp_msg);
+    spice_msg_out_send_internal(out);
+}
+
 /* ------------------------------------------------------------------ */
 
 static void image_put(SpiceImageCache *cache, uint64_t id, pixman_image_t *image)
@@ -789,7 +821,6 @@ static void spice_display_channel_up(SpiceChannel *channel)
     SpiceMsgOut *out;
     SpiceSession *s = spice_channel_get_session(channel);
     SpiceMsgcDisplayInit init;
-    SpiceMsgcDisplayPreferredCompression pref_comp_msg;
     int cache_size;
     int glz_window_size;
     SpiceImageCompression preferred_compression = SPICE_IMAGE_COMPRESSION_INVALID;
@@ -812,12 +843,8 @@ static void spice_display_channel_up(SpiceChannel *channel)
     /* notify of existence of this monitor */
     g_coroutine_object_notify(G_OBJECT(channel), "monitors");
 
-    if (spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION) &&
-            preferred_compression > SPICE_IMAGE_COMPRESSION_INVALID) {
-        pref_comp_msg.image_compression = preferred_compression;
-        out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION);
-        out->marshallers->msgc_display_preferred_compression(out->marshaller, &pref_comp_msg);
-        spice_msg_out_send_internal(out);
+    if (preferred_compression != SPICE_IMAGE_COMPRESSION_INVALID) {
+        spice_display_change_preferred_compression(channel, preferred_compression);
     }
 }
 
diff --git a/src/channel-display.h b/src/channel-display.h
index 8e68b60..52d76f7 100644
--- a/src/channel-display.h
+++ b/src/channel-display.h
@@ -100,6 +100,7 @@ struct _SpiceDisplayChannelClass {
 GType	        spice_display_channel_get_type(void);
 gboolean        spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
                                           SpiceDisplayPrimary *primary);
+void spice_display_change_preferred_compression(SpiceChannel *channel, gint compression);
 
 G_END_DECLS
 
diff --git a/src/map-file b/src/map-file
index 786bbbf..62cdb51 100644
--- a/src/map-file
+++ b/src/map-file
@@ -20,6 +20,7 @@ spice_channel_test_common_capability;
 spice_channel_type_to_string;
 spice_client_error_quark;
 spice_cursor_channel_get_type;
+spice_display_change_preferred_compression;
 spice_display_channel_get_type;
 spice_display_copy_to_guest;
 spice_display_get_grab_keys;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index 7d20a07..ae365cd 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -18,6 +18,7 @@ spice_channel_test_common_capability
 spice_channel_type_to_string
 spice_client_error_quark
 spice_cursor_channel_get_type
+spice_display_change_preferred_compression
 spice_display_channel_get_type
 spice_display_get_primary
 spice_file_transfer_task_cancel


More information about the Spice-commits mailing list