spice_server_kbd_leds: don't use global 'reds'

Store a reference to the RedsState server in the keyboard state struct

Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Jonathon Jongsma 2015-01-29 16:56:43 -06:00 committed by Frediano Ziglio
parent 2dfcf9c6e3
commit cca32779f5
3 changed files with 13 additions and 3 deletions

View File

@ -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)
{
return spice_new0(SpiceKbdState, 1);
SpiceKbdState *st = spice_new0(SpiceKbdState, 1);
st->reds = reds;
return st;
}
RedsState* spice_kbd_state_get_server(SpiceKbdState *dev)
{
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;
}

View File

@ -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

View File

@ -3780,6 +3780,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;
}