[Spice-commits] 2 commits - server/inputs-channel.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Fri Dec 1 22:53:47 UTC 2017


 server/inputs-channel.c |   32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

New commits:
commit 0b9e5e87e157100ba4a2703fb1703d7fb2efa1c1
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Sep 4 10:42:01 2017 +0100

    inputs-channel: Prefer channel core over global core interface
    
    Potentially a channel can run with a different core interface
    than the global one attached to RedsState so instead of calling
    reds_core_* functions use the code interface attached to the
    channel.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 464ac21e..15256ba4 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -162,9 +162,10 @@ const VDAgentMouseState *inputs_channel_get_mouse_state(InputsChannel *inputs)
      ((state & SPICE_MOUSE_BUTTON_MASK_MIDDLE) ? VD_AGENT_MBUTTON_MASK : 0) |    \
      ((state & SPICE_MOUSE_BUTTON_MASK_RIGHT) ? VD_AGENT_RBUTTON_MASK : 0))
 
-static void activate_modifiers_watch(InputsChannel *inputs, RedsState *reds)
+static void activate_modifiers_watch(InputsChannel *inputs)
 {
-    reds_core_timer_start(reds, inputs->key_modifiers_timer, KEY_MODIFIERS_TTL);
+    SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(RED_CHANNEL(inputs));
+    core->timer_start(core, inputs->key_modifiers_timer, KEY_MODIFIERS_TTL);
 }
 
 static void kbd_push_scan(SpiceKbdInstance *sin, uint8_t scan)
@@ -263,7 +264,7 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
         if (key_down->code == CAPS_LOCK_SCAN_CODE ||
             key_down->code == NUM_LOCK_SCAN_CODE ||
             key_down->code == SCROLL_LOCK_SCAN_CODE) {
-            activate_modifiers_watch(inputs_channel, reds);
+            activate_modifiers_watch(inputs_channel);
         }
     }
         /* fallthrough */
@@ -400,7 +401,7 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
             kbd_push_scan(keyboard, CAPS_LOCK_SCAN_CODE);
             kbd_push_scan(keyboard, CAPS_LOCK_SCAN_CODE | SCAN_CODE_RELEASE);
         }
-        activate_modifiers_watch(inputs_channel, reds);
+        activate_modifiers_watch(inputs_channel);
         break;
     }
     case SPICE_MSGC_DISCONNECTING:
@@ -551,6 +552,7 @@ inputs_channel_constructed(GObject *object)
     ClientCbs client_cbs = { NULL, };
     InputsChannel *self = INPUTS_CHANNEL(object);
     RedsState *reds = red_channel_get_server(RED_CHANNEL(self));
+    SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(RED_CHANNEL(self));
 
     G_OBJECT_CLASS(inputs_channel_parent_class)->constructed(object);
 
@@ -561,7 +563,7 @@ inputs_channel_constructed(GObject *object)
     red_channel_set_cap(RED_CHANNEL(self), SPICE_INPUTS_CAP_KEY_SCANCODE);
     reds_register_channel(reds, RED_CHANNEL(self));
 
-    self->key_modifiers_timer = reds_core_timer_add(reds, key_modifiers_sender, self);
+    self->key_modifiers_timer = core->timer_add(core, key_modifiers_sender, self);
     if (!self->key_modifiers_timer) {
         spice_error("key modifiers timer create failed");
     }
@@ -571,10 +573,10 @@ static void
 inputs_channel_finalize(GObject *object)
 {
     InputsChannel *self = INPUTS_CHANNEL(object);
-    RedsState *reds = red_channel_get_server(RED_CHANNEL(self));
+    SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(RED_CHANNEL(self));
 
     inputs_channel_detach_tablet(self, self->tablet);
-    reds_core_timer_remove(reds, self->key_modifiers_timer);
+    core->timer_remove(core, self->key_modifiers_timer);
 
     G_OBJECT_CLASS(inputs_channel_parent_class)->finalize(object);
 }
commit a73357f33e7bbb17fd69249af717e4e77523898c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Nov 23 13:09:02 2017 +0000

    inputs-channel: Encapsulate SpiceTabletState
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index ac598424..464ac21e 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -100,9 +100,16 @@ struct SpiceTabletState {
     RedsState *reds;
 };
 
-static SpiceTabletState* spice_tablet_state_new(void)
+static SpiceTabletState* spice_tablet_state_new(RedsState* reds)
 {
-    return g_new0(SpiceTabletState, 1);
+    SpiceTabletState *st = g_new0(SpiceTabletState, 1);
+    st->reds = reds;
+    return st;
+}
+
+static void spice_tablet_state_free(SpiceTabletState* st)
+{
+    g_free(st);
 }
 
 RedsState* spice_tablet_state_get_server(SpiceTabletState *st)
@@ -640,8 +647,7 @@ int inputs_channel_set_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet
         return -1;
     }
     inputs->tablet = tablet;
-    inputs->tablet->st = spice_tablet_state_new();
-    inputs->tablet->st->reds = red_channel_get_server(RED_CHANNEL(inputs));
+    inputs->tablet->st = spice_tablet_state_new(red_channel_get_server(RED_CHANNEL(inputs)));
     return 0;
 }
 
@@ -654,7 +660,7 @@ void inputs_channel_detach_tablet(InputsChannel *inputs, SpiceTabletInstance *ta
 {
     spice_printerr("");
     if (tablet != NULL && tablet == inputs->tablet) {
-        g_free(tablet->st);
+        spice_tablet_state_free(tablet->st);
         tablet->st = NULL;
     }
     inputs->tablet = NULL;


More information about the Spice-commits mailing list