[PATCH 14/18] spice_server_kbd_leds: don't use global 'reds'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

Store a reference to the RedsState server in the keyboard state struct
---
 server/inputs-channel.c | 14 +++++++++++---
 server/inputs-channel.h |  1 +
 server/reds.c           |  1 +
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 5e884f4..38b23df 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -61,11 +61,19 @@ struct SpiceKbdState {
     /* track key press state */
     bool key[0x7f];
     bool key_ext[0x7f];
+    RedsState *reds;
 };
 
-static SpiceKbdState* spice_kbd_state_new(void)
+static SpiceKbdState* spice_kbd_state_new(RedsState *reds)
+{
+    SpiceKbdState *st = spice_new0(SpiceKbdState, 1);
+    st->reds = reds;
+    return st;
+}
+
+RedsState* spice_kbd_state_get_server(SpiceKbdState *dev)
 {
-    return spice_new0(SpiceKbdState, 1);
+    return dev->reds;
 }
 
 struct SpiceMouseState {
@@ -666,7 +674,7 @@ int inputs_channel_set_keyboard(InputsChannel *inputs, SpiceKbdInstance *keyboar
         return -1;
     }
     inputs->keyboard = keyboard;
-    inputs->keyboard->st = spice_kbd_state_new();
+    inputs->keyboard->st = spice_kbd_state_new(reds);
     return 0;
 }
 
diff --git a/server/inputs-channel.h b/server/inputs-channel.h
index 31574b5..4070a23 100644
--- a/server/inputs-channel.h
+++ b/server/inputs-channel.h
@@ -40,5 +40,6 @@ int inputs_channel_set_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet
 int inputs_channel_has_tablet(InputsChannel *inputs);
 void inputs_channel_detach_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet);
 RedsState* spice_tablet_state_get_server(SpiceTabletState *dev);
+RedsState* spice_kbd_state_get_server(SpiceKbdState *dev);
 
 #endif
diff --git a/server/reds.c b/server/reds.c
index 012c0f3..91711a1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3773,6 +3773,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_renderer(SpiceServer *s, const char *nam
 
 SPICE_GNUC_VISIBLE int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds)
 {
+    RedsState *reds = spice_kbd_state_get_server(sin->st);
     inputs_channel_on_keyboard_leds_change(reds->inputs_channel, leds);
     return 0;
 }
-- 
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]