inputs-channel: Move spice_server_kbd_leds to InputsChannel

This avoids to expose some detail about the channel.
Like other APIs implement it move close to the part that handle
it instead of have everything in reds.c.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-12-12 17:20:39 +00:00
parent a793655a86
commit 52d8dd6898
3 changed files with 7 additions and 20 deletions

View File

@ -68,25 +68,20 @@ struct SpiceKbdState {
/* track key press state */
bool key[0x80];
bool key_ext[0x80];
RedsState *reds;
InputsChannel *inputs;
};
static SpiceKbdInstance* inputs_channel_get_keyboard(InputsChannel *inputs);
static SpiceMouseInstance* inputs_channel_get_mouse(InputsChannel *inputs);
static SpiceTabletInstance* inputs_channel_get_tablet(InputsChannel *inputs);
static SpiceKbdState* spice_kbd_state_new(RedsState *reds)
static SpiceKbdState* spice_kbd_state_new(InputsChannel *inputs)
{
SpiceKbdState *st = g_new0(SpiceKbdState, 1);
st->reds = reds;
st->inputs = inputs;
return st;
}
RedsState* spice_kbd_state_get_server(SpiceKbdState *dev)
{
return dev->reds;
}
struct SpiceMouseState {
int dummy;
};
@ -485,9 +480,10 @@ static void inputs_channel_push_keyboard_modifiers(InputsChannel *inputs, uint8_
red_inputs_key_modifiers_item_new(modifiers));
}
void inputs_channel_on_keyboard_leds_change(InputsChannel *inputs, uint8_t leds)
SPICE_GNUC_VISIBLE int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds)
{
inputs_channel_push_keyboard_modifiers(inputs, leds);
inputs_channel_push_keyboard_modifiers(sin->st->inputs, leds);
return 0;
}
static void key_modifiers_sender(void *opaque)
@ -615,7 +611,7 @@ int inputs_channel_set_keyboard(InputsChannel *inputs, SpiceKbdInstance *keyboar
return -1;
}
inputs->keyboard = keyboard;
inputs->keyboard->st = spice_kbd_state_new(red_channel_get_server(RED_CHANNEL(inputs)));
inputs->keyboard->st = spice_kbd_state_new(inputs);
return 0;
}

View File

@ -47,7 +47,6 @@ GType inputs_channel_get_type(void) G_GNUC_CONST;
InputsChannel* inputs_channel_new(RedsState *reds);
const VDAgentMouseState *inputs_channel_get_mouse_state(InputsChannel *inputs);
void inputs_channel_on_keyboard_leds_change(InputsChannel *inputs, uint8_t leds);
void inputs_channel_set_tablet_logical_size(InputsChannel *inputs, int x_res, int y_res);
int inputs_channel_set_keyboard(InputsChannel *inputs, SpiceKbdInstance *keyboard);
@ -56,7 +55,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);
gboolean inputs_channel_is_src_during_migrate(InputsChannel *inputs);
void inputs_release_keys(InputsChannel *inputs);

View File

@ -4002,13 +4002,6 @@ SPICE_GNUC_VISIBLE int spice_server_add_renderer(SpiceServer *reds, const char *
return 0;
}
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;
}
SPICE_GNUC_VISIBLE int spice_server_set_streaming_video(SpiceServer *reds, int value)
{
if (value != SPICE_STREAM_VIDEO_OFF &&