[Spice-commits] 3 commits - src/spice-channel.c src/spice-widget.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Fri Aug 26 15:32:19 UTC 2016


 src/spice-channel.c |   23 +++++++++++++++++++++++
 src/spice-widget.c  |   51 +++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 64 insertions(+), 10 deletions(-)

New commits:
commit 3fa2e5ab3de942063a353cd05226ee9e94e95b59
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Aug 26 18:44:08 2016 +0400

    widget: set keypress-delay to 0 on unix socket
    
    There is no strong need for keypress-delay on local connection (not
    verified: unless the system is heavily loaded, in which case the VM will
    probably be stuck too and may or not repeat the key when running).
    
    The benefit of removing keypress-delay is that games or interfaces that
    require "realtime" responses, such as FPS, are slightly better without
    the 100ms input delay.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 46e0e49..67e66b7 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -97,6 +97,8 @@ enum {
     SPICE_DISPLAY_LAST_SIGNAL,
 };
 
+#define DEFAULT_KEYPRESS_DELAY 100
+
 static guint signals[SPICE_DISPLAY_LAST_SIGNAL];
 
 #ifdef G_OS_WIN32
@@ -2181,7 +2183,7 @@ static void spice_display_class_init(SpiceDisplayClass *klass)
         (gobject_class, PROP_KEYPRESS_DELAY,
          g_param_spec_uint("keypress-delay", "Keypress delay",
                            "Keypress delay",
-                           0, G_MAXUINT, 100,
+                           0, G_MAXUINT, DEFAULT_KEYPRESS_DELAY,
                            G_PARAM_READWRITE |
                            G_PARAM_CONSTRUCT |
                            G_PARAM_STATIC_STRINGS));
@@ -2658,6 +2660,25 @@ static void cursor_reset(SpiceCursorChannel *channel, gpointer data)
     gdk_window_set_cursor(window, NULL);
 }
 
+static void inputs_channel_event(SpiceChannel *channel, SpiceChannelEvent event,
+                                 gpointer data)
+{
+    SpiceDisplay *display = data;
+    guint delay = DEFAULT_KEYPRESS_DELAY;
+    GSocket *sock;
+
+    if (event != SPICE_CHANNEL_OPENED)
+        return;
+
+    g_object_get(channel, "socket", &sock, NULL);
+    if (g_socket_get_family(sock) == G_SOCKET_FAMILY_UNIX) {
+        delay = 0;
+    }
+    g_object_unref(sock);
+
+    spice_display_set_keypress_delay(display, delay);
+}
+
 #ifndef G_OS_WIN32
 G_GNUC_INTERNAL
 void spice_display_widget_gl_scanout(SpiceDisplay *display)
@@ -2795,6 +2816,8 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
     if (SPICE_IS_INPUTS_CHANNEL(channel)) {
         d->inputs = SPICE_INPUTS_CHANNEL(channel);
         spice_channel_connect(channel);
+        spice_g_signal_connect_object(channel, "channel-event",
+                                      G_CALLBACK(inputs_channel_event), display, 0);
         return;
     }
 
commit 16d0bcf898cb77f2d6ab67dd45b7dc55ce2803f2
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Aug 26 18:19:10 2016 +0400

    widget: make set_keypress_delay a function
    
    So the widget can call it without going through g_object_set().
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index f288c28..46e0e49 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -329,6 +329,22 @@ whole:
     set_monitor_ready(display, true);
 }
 
+static void
+spice_display_set_keypress_delay(SpiceDisplay *display, guint delay)
+{
+    SpiceDisplayPrivate *d = display->priv;
+    const gchar *env = g_getenv("SPICE_KEYPRESS_DELAY");
+
+    if (env != NULL)
+        delay = strtoul(env, NULL, 10);
+
+    if (d->keypress_delay != delay) {
+        SPICE_DEBUG("keypress-delay is set to %u ms", delay);
+        d->keypress_delay = delay;
+        g_object_notify(G_OBJECT(display), "keypress-delay");
+    }
+}
+
 static void spice_display_set_property(GObject      *object,
                                        guint         prop_id,
                                        const GValue *value,
@@ -386,15 +402,7 @@ static void spice_display_set_property(GObject      *object,
         scaling_updated(display);
         break;
     case PROP_KEYPRESS_DELAY:
-        {
-            const gchar *env = g_getenv("SPICE_KEYPRESS_DELAY");
-            guint delay = g_value_get_uint(value);
-            if (env != NULL)
-                delay = strtoul(env, NULL, 10);
-
-            SPICE_DEBUG("keypress-delay is set to %u ms", delay);
-            d->keypress_delay = delay;
-        }
+        spice_display_set_keypress_delay(display, g_value_get_uint(value));
         break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
commit b576e3a8df111aa73b9ee20381b2425a14bd3823
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Aug 26 18:17:21 2016 +0400

    channel: add read-only socket property
    
    Channel users (such as spice widget) may want to know some connection
    details. Instead of exposing various connection properties, we may as
    well just have a GSocket property, with a strong warning on usage.
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-channel.c b/src/spice-channel.c
index 4e792a2..95662f3 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -85,6 +85,7 @@ enum {
     PROP_CHANNEL_TYPE,
     PROP_CHANNEL_ID,
     PROP_TOTAL_READ_BYTES,
+    PROP_SOCKET,
 };
 
 /* Signals */
@@ -215,6 +216,9 @@ static void spice_channel_get_property(GObject    *gobject,
     case PROP_TOTAL_READ_BYTES:
         g_value_set_ulong(value, c->total_read_bytes);
         break;
+    case PROP_SOCKET:
+        g_value_set_object(value, c->sock);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -318,6 +322,25 @@ static void spice_channel_class_init(SpiceChannelClass *klass)
                             G_PARAM_STATIC_STRINGS));
 
     /**
+     * SpiceChannel:socket:
+     *
+     * Get the underlying #GSocket. Note that you should not read or
+     * write any data to it directly since this will likely corrupt
+     * the channel stream.  This property is mainly useful to get some
+     * connections details.
+     *
+     * Since: 0.33
+     */
+    g_object_class_install_property
+        (gobject_class, PROP_SOCKET,
+         g_param_spec_object("socket",
+                             "Socket",
+                             "Underlying GSocket",
+                             G_TYPE_SOCKET,
+                             G_PARAM_READABLE |
+                             G_PARAM_STATIC_STRINGS));
+
+    /**
      * SpiceChannel::channel-event:
      * @channel: the channel that emitted the signal
      * @event: a #SpiceChannelEvent


More information about the Spice-commits mailing list