[Spice-devel] [PATCH 4/7] Add InputsChannelPrivate struct
Jonathon Jongsma
jjongsma at redhat.com
Tue Oct 11 22:29:00 UTC 2016
Prepare for GObject port
---
server/inputs-channel.c | 68 ++++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 32 deletions(-)
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 85ca155..dfb7ba6 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -105,8 +105,7 @@ RedsState* spice_tablet_state_get_server(SpiceTabletState *st)
return st->reds;
}
-struct InputsChannel {
- RedChannel base;
+typedef struct {
uint8_t recv_buf[RECEIVE_BUF_SIZE];
VDAgentMouseState mouse_state;
int src_during_migrate;
@@ -115,6 +114,11 @@ struct InputsChannel {
SpiceKbdInstance *keyboard;
SpiceMouseInstance *mouse;
SpiceTabletInstance *tablet;
+} InputsChannelPrivate;
+
+struct InputsChannel {
+ RedChannel base;
+ InputsChannelPrivate priv[1];
};
typedef struct RedKeyModifiersPipeItem {
@@ -138,13 +142,13 @@ void inputs_channel_set_tablet_logical_size(InputsChannel *inputs, int x_res, in
{
SpiceTabletInterface *sif;
- sif = SPICE_UPCAST(SpiceTabletInterface, inputs->tablet->base.sif);
- sif->set_logical_size(inputs->tablet, x_res, y_res);
+ sif = SPICE_UPCAST(SpiceTabletInterface, inputs->priv->tablet->base.sif);
+ sif->set_logical_size(inputs->priv->tablet, x_res, y_res);
}
const VDAgentMouseState *inputs_channel_get_mouse_state(InputsChannel *inputs)
{
- return &inputs->mouse_state;
+ return &inputs->priv->mouse_state;
}
static uint8_t *inputs_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
@@ -157,7 +161,7 @@ static uint8_t *inputs_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
spice_printerr("error: too large incoming message");
return NULL;
}
- return inputs_channel->recv_buf;
+ return inputs_channel->priv->recv_buf;
}
static void inputs_channel_release_msg_rcv_buf(RedChannelClient *rcc,
@@ -183,7 +187,7 @@ static void inputs_channel_release_msg_rcv_buf(RedChannelClient *rcc,
static void activate_modifiers_watch(InputsChannel *inputs, RedsState *reds)
{
- reds_core_timer_start(reds, inputs->key_modifiers_timer, KEY_MODIFIERS_TTL);
+ reds_core_timer_start(reds, inputs->priv->key_modifiers_timer, KEY_MODIFIERS_TTL);
}
static void kbd_push_scan(SpiceKbdInstance *sin, uint8_t scan)
@@ -259,7 +263,7 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK, base);
break;
case RED_PIPE_ITEM_MIGRATE_DATA:
- INPUTS_CHANNEL(red_channel_client_get_channel(rcc))->src_during_migrate = FALSE;
+ INPUTS_CHANNEL(red_channel_client_get_channel(rcc))->priv->src_during_migrate = FALSE;
inputs_channel_client_send_migrate_data(rcc, m, base);
break;
default:
@@ -333,7 +337,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
sif->position(tablet, pos->x, pos->y, RED_MOUSE_STATE_TO_LOCAL(pos->buttons_state));
break;
}
- VDAgentMouseState *mouse_state = &inputs_channel->mouse_state;
+ VDAgentMouseState *mouse_state = &inputs_channel->priv->mouse_state;
mouse_state->x = pos->x;
mouse_state->y = pos->y;
mouse_state->buttons = RED_MOUSE_BUTTON_STATE_TO_AGENT(pos->buttons_state);
@@ -351,11 +355,11 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
}
if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
if (reds_config_get_agent_mouse(reds) && reds_has_vdagent(reds)) {
- inputs_channel->mouse_state.buttons =
+ inputs_channel->priv->mouse_state.buttons =
RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_press->buttons_state) |
(dz == -1 ? VD_AGENT_UBUTTON_MASK : 0) |
(dz == 1 ? VD_AGENT_DBUTTON_MASK : 0);
- reds_handle_agent_mouse_event(reds, &inputs_channel->mouse_state);
+ reds_handle_agent_mouse_event(reds, &inputs_channel->priv->mouse_state);
} else if (inputs_channel_get_tablet(inputs_channel)) {
SpiceTabletInterface *sif;
sif = SPICE_CONTAINEROF(inputs_channel_get_tablet(inputs_channel)->base.sif, SpiceTabletInterface, base);
@@ -373,9 +377,9 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
SpiceMsgcMouseRelease *mouse_release = message;
if (reds_get_mouse_mode(reds) == SPICE_MOUSE_MODE_CLIENT) {
if (reds_config_get_agent_mouse(reds) && reds_has_vdagent(reds)) {
- inputs_channel->mouse_state.buttons =
+ inputs_channel->priv->mouse_state.buttons =
RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_release->buttons_state);
- reds_handle_agent_mouse_event(reds, &inputs_channel->mouse_state);
+ reds_handle_agent_mouse_event(reds, &inputs_channel->priv->mouse_state);
} else if (inputs_channel_get_tablet(inputs_channel)) {
SpiceTabletInterface *sif;
sif = SPICE_CONTAINEROF(inputs_channel_get_tablet(inputs_channel)->base.sif, SpiceTabletInterface, base);
@@ -512,14 +516,14 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
static void inputs_migrate(RedChannelClient *rcc)
{
InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
- inputs->src_during_migrate = TRUE;
+ inputs->priv->src_during_migrate = TRUE;
red_channel_client_default_migrate(rcc);
}
static void inputs_channel_push_keyboard_modifiers(InputsChannel *inputs, uint8_t modifiers)
{
if (!inputs || !red_channel_is_connected(&inputs->base) ||
- inputs->src_during_migrate) {
+ inputs->priv->src_during_migrate) {
return;
}
red_channel_pipes_new_add_push(&inputs->base,
@@ -602,7 +606,7 @@ InputsChannel* inputs_channel_new(RedsState *reds)
red_channel_set_cap(&inputs->base, SPICE_INPUTS_CAP_KEY_SCANCODE);
reds_register_channel(reds, &inputs->base);
- if (!(inputs->key_modifiers_timer = reds_core_timer_add(reds, key_modifiers_sender, inputs))) {
+ if (!(inputs->priv->key_modifiers_timer = reds_core_timer_add(reds, key_modifiers_sender, inputs))) {
spice_error("key modifiers timer create failed");
}
return inputs;
@@ -610,65 +614,65 @@ InputsChannel* inputs_channel_new(RedsState *reds)
static SpiceKbdInstance* inputs_channel_get_keyboard(InputsChannel *inputs)
{
- return inputs->keyboard;
+ return inputs->priv->keyboard;
}
int inputs_channel_set_keyboard(InputsChannel *inputs, SpiceKbdInstance *keyboard)
{
- if (inputs->keyboard) {
+ if (inputs->priv->keyboard) {
spice_printerr("already have keyboard");
return -1;
}
- inputs->keyboard = keyboard;
- inputs->keyboard->st = spice_kbd_state_new(red_channel_get_server(&inputs->base));
+ inputs->priv->keyboard = keyboard;
+ inputs->priv->keyboard->st = spice_kbd_state_new(red_channel_get_server(&inputs->base));
return 0;
}
static SpiceMouseInstance* inputs_channel_get_mouse(InputsChannel *inputs)
{
- return inputs->mouse;
+ return inputs->priv->mouse;
}
int inputs_channel_set_mouse(InputsChannel *inputs, SpiceMouseInstance *mouse)
{
- if (inputs->mouse) {
+ if (inputs->priv->mouse) {
spice_printerr("already have mouse");
return -1;
}
- inputs->mouse = mouse;
- inputs->mouse->st = spice_mouse_state_new();
+ inputs->priv->mouse = mouse;
+ inputs->priv->mouse->st = spice_mouse_state_new();
return 0;
}
static SpiceTabletInstance* inputs_channel_get_tablet(InputsChannel *inputs)
{
- return inputs->tablet;
+ return inputs->priv->tablet;
}
int inputs_channel_set_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet, RedsState *reds)
{
- if (inputs->tablet) {
+ if (inputs->priv->tablet) {
spice_printerr("already have tablet");
return -1;
}
- inputs->tablet = tablet;
- inputs->tablet->st = spice_tablet_state_new();
- inputs->tablet->st->reds = reds;
+ inputs->priv->tablet = tablet;
+ inputs->priv->tablet->st = spice_tablet_state_new();
+ inputs->priv->tablet->st->reds = reds;
return 0;
}
int inputs_channel_has_tablet(InputsChannel *inputs)
{
- return inputs != NULL && inputs->tablet != NULL;
+ return inputs != NULL && inputs->priv->tablet != NULL;
}
void inputs_channel_detach_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet)
{
spice_printerr("");
- inputs->tablet = NULL;
+ inputs->priv->tablet = NULL;
}
gboolean inputs_channel_is_src_during_migrate(InputsChannel *inputs)
{
- return inputs->src_during_migrate;
+ return inputs->priv->src_during_migrate;
}
--
2.7.4
More information about the Spice-devel
mailing list