[Spice-devel] [PATCH 13/18] new watch api: switch inputs
Gerd Hoffmann
kraxel at redhat.com
Mon Mar 29 08:08:49 PDT 2010
---
server/reds.c | 50 +++++++++++++++++++++++++-------------------------
1 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index b9d2dea..108c9b3 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2295,31 +2295,31 @@ static void inputs_relase_keys(void)
push_key_scan(0x38 | 0x80); //LALT
}
-static void inputs_read(void *data)
-{
- InputsState *inputs_state = (InputsState *)data;
- if (handle_incoming(inputs_state->peer, &inputs_state->in_handler)) {
- inputs_relase_keys();
- core->set_file_handlers(core, inputs_state->peer->socket, NULL, NULL, NULL);
- if (inputs_state->channel) {
- inputs_state->channel->data = NULL;
- reds->inputs_state = NULL;
- }
- inputs_state->peer->cb_free(inputs_state->peer);
- free(inputs_state);
- }
-}
-
-static void inputs_write(void *data)
+static void inputs_event(int fd, int event, void *data)
{
- InputsState *inputs_state = (InputsState *)data;
+ InputsState *inputs_state = data;
- red_printf("");
- if (handle_outgoing(inputs_state->peer, &inputs_state->out_handler)) {
- reds_disconnect();
+ if (event & SPICE_WATCH_EVENT_READ) {
+ if (handle_incoming(inputs_state->peer, &inputs_state->in_handler)) {
+ inputs_relase_keys();
+ core->watch_remove(inputs_state->peer->watch);
+ inputs_state->peer->watch = NULL;
+ if (inputs_state->channel) {
+ inputs_state->channel->data = NULL;
+ reds->inputs_state = NULL;
+ }
+ inputs_state->peer->cb_free(inputs_state->peer);
+ free(inputs_state);
+ }
+ }
+ if (event & SPICE_WATCH_EVENT_WRITE) {
+ if (handle_outgoing(inputs_state->peer, &inputs_state->out_handler)) {
+ reds_disconnect();
+ }
}
}
+
static void inputs_shutdown(Channel *channel)
{
InputsState *state = (InputsState *)channel->data;
@@ -2355,15 +2355,14 @@ static void inputs_migrate(Channel *channel)
static void inputs_select(void *opaque, int select)
{
InputsState *inputs_state;
+ int eventmask = SPICE_WATCH_EVENT_READ;
red_printf("");
inputs_state = (InputsState *)opaque;
if (select) {
- core->set_file_handlers(core, inputs_state->peer->socket, inputs_read, inputs_write,
- inputs_state);
- } else {
- core->set_file_handlers(core, inputs_state->peer->socket, inputs_read, NULL, inputs_state);
+ eventmask |= SPICE_WATCH_EVENT_WRITE;
}
+ core->watch_update_mask(inputs_state->peer->watch, eventmask);
}
static void inputs_may_write(void *opaque)
@@ -2406,7 +2405,8 @@ static void inputs_link(Channel *channel, RedsStreamContext *peer, int migration
inputs_state->pending_mouse_event = FALSE;
channel->data = inputs_state;
reds->inputs_state = inputs_state;
- core->set_file_handlers(core, peer->socket, inputs_read, NULL, inputs_state);
+ peer->watch = core->watch_add(peer->socket, SPICE_WATCH_EVENT_READ,
+ inputs_event, inputs_state);
SpiceDataHeader header;
SpiceMsgInputsInit inputs_init;
--
1.6.6.1
More information about the Spice-devel
mailing list