Re: [Spice-devel] [Qemu-devel] paravirtual mouse/tablet

2011-01-15 Thread Alon Levy
On Fri, Jan 14, 2011 at 04:13:29PM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> >So it'd end up being (x,y,pressure) N times (I think 16 is fine for
> >the foreseeable future).
> 
> I'd tend to extend MOVE to (x,y,pressure,index) and send N events
> with the same timestamp.  Needs to send only as many events as it
> finds fingers on the touchpad, i.e. usually just one or two, even if
> the protocol can easily handle alot more than 16 ;)

Doesn't that lose the coincidence? I expect mostly presses happen
sequentially (milliseconds apart maybe, but still), so probably not
an issue at all.

> 
> For a simple tablet pressure and index would just be 0.
> 
> >The details of what exactly that means
> >should be figured out by the guest driver.
> 
> Agree.
> 
> >I'm not familiar with the hardware interface, but in order to support
> >that the background interface must be a lot more complex than a
> >simple button press.
> 
> Buttons events are for buttons.  Real ones, which apple lost ;)
> 
> Of course a tap on the trackpad is usually interpreted as mouse
> click. But that is the job of the guest OS, our virtual hardware
> doesn't care.
> 
> >But then again - how would we forward fine-grained scrolling to the
> >guest if we only know that it's scrolling, but not what the actual
> >presses on the touchpad looked like? Ugh.
> 
> There must be an interface to get (more or less) the raw touchpad
> data, for apps which want implement their own multitouch gestures?
> 
> cheers,
>   Gerd
> 
> 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [Qemu-devel] paravirtual mouse/tablet

2011-01-15 Thread Peter Maydell
On 14 January 2011 09:37, Anthony Liguori  wrote:
[multitouch]
> Surely, evdev has an interface to support this already.  Let's just do what
> it does instead of inventing something that none of us can validate actually
> works.
>
> Or better yet, delay implementing it until someone actually knows how to
> support it.

I was just talking to Chase Douglas here at the ubuntu sprint about this, and
he pointed me at https://launchpad.net/rinput which is a program which
can forward remote events including multitouch over the network (including
forwarding from both Linux and MacOS X clients). Maybe that would be
worth looking at since it's a working implementation of forwarding
multitouch events between systems?

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


[Spice-devel] [PATCH 0/2] redo of nacked patch from main channel split + segfault fix

2011-01-15 Thread Alon Levy
Redid the marshaller reuse patch to read kbd state during push, not during
marshalling (and in general, like Hans pointed out, marshalling code should be
sideeffect free).

Also spotted a segfault that happened occasionally when disconnecting a client,
including the fix as second patch.

Alon Levy (2):
  server/inputs_channel: use outgoing marshaller in
red_channel/RedChannel
  server/red_channel: fix segfault on red_channel_destroy if peer
already removed

 server/inputs_channel.c |  135 +++
 server/red_channel.c|2 +-
 2 files changed, 78 insertions(+), 59 deletions(-)

-- 
1.7.3.4

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


[Spice-devel] [PATCH 1/2] server/inputs_channel: use outgoing marshaller in red_channel/RedChannel

2011-01-15 Thread Alon Levy
---
 server/inputs_channel.c |  135 +++
 1 files changed, 77 insertions(+), 58 deletions(-)

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index e53a634..b230866 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -72,10 +72,18 @@ enum {
 
 typedef struct InputsPipeItem {
 PipeItem base;
-SpiceMarshaller *m;
-uint8_t *data;  /* If the marshaller malloced, pointer is here */
 } InputsPipeItem;
 
+typedef struct KeyModifiersPipeItem {
+PipeItem base;
+uint8_t modifiers;
+} KeyModifiersPipeItem;
+
+typedef struct InputsInitPipeItem {
+PipeItem base;
+uint8_t modifiers;
+} InputsInitPipeItem;
+
 static SpiceKbdInstance *keyboard = NULL;
 static SpiceMouseInstance *mouse = NULL;
 static SpiceTabletInstance *tablet = NULL;
@@ -210,13 +218,22 @@ static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
 return sif->get_leds(sin);
 }
 
-static InputsPipeItem *inputs_pipe_item_new(InputsChannel *channel, int type)
+static InputsPipeItem *inputs_pipe_item_new(InputsChannel *inputs_channel, int 
type)
 {
 InputsPipeItem *item = spice_malloc(sizeof(InputsPipeItem));
 
-red_channel_pipe_item_init(&channel->base, &item->base, type);
-item->m = spice_marshaller_new();
-item->data = NULL;
+red_channel_pipe_item_init(&inputs_channel->base, &item->base, type);
+return item;
+}
+
+static KeyModifiersPipeItem *inputs_key_modifiers_item_new(
+InputsChannel *inputs_channel, uint8_t modifiers)
+{
+KeyModifiersPipeItem *item = spice_malloc(sizeof(KeyModifiersPipeItem));
+
+red_channel_pipe_item_init(&inputs_channel->base, &item->base,
+   PIPE_ITEM_KEY_MODIFIERS);
+item->modifiers = modifiers;
 return item;
 }
 
@@ -232,33 +249,43 @@ static void inputs_pipe_add_type(InputsChannel *channel, 
int type)
 static void inputs_channel_release_pipe_item(RedChannel *channel,
 PipeItem *base, int item_pushed)
 {
-// All PipeItems we push are InputsPipeItem
-InputsPipeItem *item = (InputsPipeItem*)base;
-
-if (item->data) {
-free(item->data);
-}
-spice_marshaller_destroy(item->m);
-free(item);
+free(base);
 }
 
 static void inputs_channel_send_item(RedChannel *channel, PipeItem *base)
 {
-InputsPipeItem *item = SPICE_CONTAINEROF(base, InputsPipeItem, base);
-SpiceMarshaller *m = item->m;
-uint8_t *data;
-size_t len;
-int free_data;
+InputsChannel *inputs_channel = (InputsChannel *)channel;
+SpiceMarshaller *m = inputs_channel->base.send_data.marshaller;
 
 red_channel_reset_send_data(channel);
 red_channel_init_send_data(channel, base->type, base);
-spice_marshaller_flush(m);
-// TODO: use spice_marshaller_fill_iovec. Right now we are doing something 
stupid,
-// namely copying twice. See reds.c.
-data = spice_marshaller_linearize(m, 0, &len, &free_data);
-item->data = (free_data && len > 0) ? data : NULL;
-if (len > 0) {
-red_channel_add_buf(channel, data, len);
+switch (base->type) {
+case PIPE_ITEM_KEY_MODIFIERS:
+{
+SpiceMsgInputsKeyModifiers key_modifiers;
+
+key_modifiers.modifiers =
+SPICE_CONTAINEROF(base, KeyModifiersPipeItem, base)->modifiers;
+spice_marshall_msg_inputs_key_modifiers(m, &key_modifiers);
+}
+case PIPE_ITEM_INIT:
+{
+SpiceMsgInputsInit inputs_init;
+
+inputs_init.keyboard_modifiers =
+SPICE_CONTAINEROF(base, InputsInitPipeItem, base)->modifiers;
+spice_marshall_msg_inputs_init(m, &inputs_init);
+}
+case PIPE_ITEM_MIGRATE:
+{
+SpiceMsgMigrate migrate;
+
+migrate.flags = 0;
+spice_marshall_msg_migrate(m, &migrate);
+break;
+}
+default:
+break;
 }
 red_channel_begin_send_message(channel);
 }
@@ -431,10 +458,12 @@ static void inputs_channel_on_outgoing_error(RedChannel 
*channel)
 
 static void inputs_shutdown(Channel *channel)
 {
-ASSERT(g_inputs_channel == (InputsChannel *)channel->data);
-if (g_inputs_channel) {
-red_channel_shutdown(&g_inputs_channel->base);
-g_inputs_channel->base.incoming.shut = TRUE;
+InputsChannel *inputs_channel = (InputsChannel *)channel->data;
+ASSERT(g_inputs_channel == inputs_channel);
+
+if (inputs_channel) {
+red_channel_shutdown(&inputs_channel->base);
+inputs_channel->base.incoming.shut = TRUE;
 channel->data = NULL;
 g_inputs_channel = NULL;
 }
@@ -442,28 +471,23 @@ static void inputs_shutdown(Channel *channel)
 
 static void inputs_migrate(Channel *channel)
 {
-InputsChannel *inputs_channel = (InputsChannel *)channel->data;
-InputsPipeItem *pipe_item;
-SpiceMarshaller *m;
-SpiceMsgMigrate migrate;
+InputsChannel *inputs_channel = channel->data;
+InputsPipeI

[Spice-devel] [PATCH 2/2] server/red_channel: fix segfault on red_channel_destroy if peer already removed

2011-01-15 Thread Alon Levy
---
 server/red_channel.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index 40f3a1f..a13ef0e 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -365,7 +365,7 @@ void red_channel_destroy(RedChannel *channel)
 void red_channel_shutdown(RedChannel *channel)
 {
 red_printf("");
-if (!channel->peer->shutdown) {
+if (channel->peer && !channel->peer->shutdown) {
 channel->core->watch_update_mask(channel->peer->watch,
  SPICE_WATCH_EVENT_READ);
 red_channel_pipe_clear(channel);
-- 
1.7.3.4

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


Re: [Spice-devel] [PATCH 1/2] server/inputs_channel: use outgoing marshaller in red_channel/RedChannel

2011-01-15 Thread Hans de Goede

Hi,

On 01/15/2011 07:57 PM, Alon Levy wrote:

---
  server/inputs_channel.c |  135 +++
  1 files changed, 77 insertions(+), 58 deletions(-)

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index e53a634..b230866 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -72,10 +72,18 @@ enum {

  typedef struct InputsPipeItem {
  PipeItem base;
-SpiceMarshaller *m;
-uint8_t *data;  /* If the marshaller malloced, pointer is here */
  } InputsPipeItem;

+typedef struct KeyModifiersPipeItem {
+PipeItem base;
+uint8_t modifiers;
+} KeyModifiersPipeItem;
+
+typedef struct InputsInitPipeItem {
+PipeItem base;
+uint8_t modifiers;
+} InputsInitPipeItem;
+
  static SpiceKbdInstance *keyboard = NULL;
  static SpiceMouseInstance *mouse = NULL;
  static SpiceTabletInstance *tablet = NULL;
@@ -210,13 +218,22 @@ static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
  return sif->get_leds(sin);
  }

-static InputsPipeItem *inputs_pipe_item_new(InputsChannel *channel, int type)
+static InputsPipeItem *inputs_pipe_item_new(InputsChannel *inputs_channel, int 
type)
  {
  InputsPipeItem *item = spice_malloc(sizeof(InputsPipeItem));

-red_channel_pipe_item_init(&channel->base,&item->base, type);
-item->m = spice_marshaller_new();
-item->data = NULL;
+red_channel_pipe_item_init(&inputs_channel->base,&item->base, type);
+return item;
+}
+
+static KeyModifiersPipeItem *inputs_key_modifiers_item_new(
+InputsChannel *inputs_channel, uint8_t modifiers)
+{
+KeyModifiersPipeItem *item = spice_malloc(sizeof(KeyModifiersPipeItem));
+
+red_channel_pipe_item_init(&inputs_channel->base,&item->base,
+   PIPE_ITEM_KEY_MODIFIERS);
+item->modifiers = modifiers;
  return item;
  }

@@ -232,33 +249,43 @@ static void inputs_pipe_add_type(InputsChannel *channel, 
int type)
  static void inputs_channel_release_pipe_item(RedChannel *channel,
  PipeItem *base, int item_pushed)
  {
-// All PipeItems we push are InputsPipeItem
-InputsPipeItem *item = (InputsPipeItem*)base;
-
-if (item->data) {
-free(item->data);
-}
-spice_marshaller_destroy(item->m);
-free(item);
+free(base);
  }

  static void inputs_channel_send_item(RedChannel *channel, PipeItem *base)
  {
-InputsPipeItem *item = SPICE_CONTAINEROF(base, InputsPipeItem, base);
-SpiceMarshaller *m = item->m;
-uint8_t *data;
-size_t len;
-int free_data;
+InputsChannel *inputs_channel = (InputsChannel *)channel;
+SpiceMarshaller *m = inputs_channel->base.send_data.marshaller;

  red_channel_reset_send_data(channel);
  red_channel_init_send_data(channel, base->type, base);
-spice_marshaller_flush(m);
-// TODO: use spice_marshaller_fill_iovec. Right now we are doing something 
stupid,
-// namely copying twice. See reds.c.
-data = spice_marshaller_linearize(m, 0,&len,&free_data);
-item->data = (free_data&&  len>  0) ? data : NULL;
-if (len>  0) {
-red_channel_add_buf(channel, data, len);
+switch (base->type) {
+case PIPE_ITEM_KEY_MODIFIERS:
+{
+SpiceMsgInputsKeyModifiers key_modifiers;
+
+key_modifiers.modifiers =
+SPICE_CONTAINEROF(base, KeyModifiersPipeItem, base)->modifiers;
+spice_marshall_msg_inputs_key_modifiers(m,&key_modifiers);
+}
+case PIPE_ITEM_INIT:
+{
+SpiceMsgInputsInit inputs_init;
+
+inputs_init.keyboard_modifiers =
+SPICE_CONTAINEROF(base, InputsInitPipeItem, base)->modifiers;
+spice_marshall_msg_inputs_init(m,&inputs_init);
+}
+case PIPE_ITEM_MIGRATE:
+{
+SpiceMsgMigrate migrate;
+
+migrate.flags = 0;
+spice_marshall_msg_migrate(m,&migrate);
+break;
+}
+default:
+break;
  }
  red_channel_begin_send_message(channel);
  }
@@ -431,10 +458,12 @@ static void inputs_channel_on_outgoing_error(RedChannel 
*channel)

  static void inputs_shutdown(Channel *channel)
  {
-ASSERT(g_inputs_channel == (InputsChannel *)channel->data);
-if (g_inputs_channel) {
-red_channel_shutdown(&g_inputs_channel->base);
-g_inputs_channel->base.incoming.shut = TRUE;
+InputsChannel *inputs_channel = (InputsChannel *)channel->data;
+ASSERT(g_inputs_channel == inputs_channel);
+
+if (inputs_channel) {
+red_channel_shutdown(&inputs_channel->base);
+inputs_channel->base.incoming.shut = TRUE;
  channel->data = NULL;
  g_inputs_channel = NULL;
  }
@@ -442,28 +471,23 @@ static void inputs_shutdown(Channel *channel)

  static void inputs_migrate(Channel *channel)
  {
-InputsChannel *inputs_channel = (InputsChannel *)channel->data;
-InputsPipeItem *pipe_item;
-SpiceMarshaller *m;
-SpiceMsgMigrate migrate;
+

Re: [Spice-devel] [PATCH 1/2] server/inputs_channel: use outgoing marshaller in red_channel/RedChannel

2011-01-15 Thread Alon Levy
On Sat, Jan 15, 2011 at 08:16:49PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 01/15/2011 07:57 PM, Alon Levy wrote:
> >---
> >  server/inputs_channel.c |  135 
> > +++
> >  1 files changed, 77 insertions(+), 58 deletions(-)
> >
> >diff --git a/server/inputs_channel.c b/server/inputs_channel.c
> >index e53a634..b230866 100644
> >--- a/server/inputs_channel.c
> >+++ b/server/inputs_channel.c
> >@@ -72,10 +72,18 @@ enum {
> >
> >  typedef struct InputsPipeItem {
> >  PipeItem base;
> >-SpiceMarshaller *m;
> >-uint8_t *data;  /* If the marshaller malloced, pointer is here */
> >  } InputsPipeItem;
> >
> >+typedef struct KeyModifiersPipeItem {
> >+PipeItem base;
> >+uint8_t modifiers;
> >+} KeyModifiersPipeItem;
> >+
> >+typedef struct InputsInitPipeItem {
> >+PipeItem base;
> >+uint8_t modifiers;
> >+} InputsInitPipeItem;
> >+
> >  static SpiceKbdInstance *keyboard = NULL;
> >  static SpiceMouseInstance *mouse = NULL;
> >  static SpiceTabletInstance *tablet = NULL;
> >@@ -210,13 +218,22 @@ static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
> >  return sif->get_leds(sin);
> >  }
> >
> >-static InputsPipeItem *inputs_pipe_item_new(InputsChannel *channel, int 
> >type)
> >+static InputsPipeItem *inputs_pipe_item_new(InputsChannel *inputs_channel, 
> >int type)
> >  {
> >  InputsPipeItem *item = spice_malloc(sizeof(InputsPipeItem));
> >
> >-red_channel_pipe_item_init(&channel->base,&item->base, type);
> >-item->m = spice_marshaller_new();
> >-item->data = NULL;
> >+red_channel_pipe_item_init(&inputs_channel->base,&item->base, type);
> >+return item;
> >+}
> >+
> >+static KeyModifiersPipeItem *inputs_key_modifiers_item_new(
> >+InputsChannel *inputs_channel, uint8_t modifiers)
> >+{
> >+KeyModifiersPipeItem *item = spice_malloc(sizeof(KeyModifiersPipeItem));
> >+
> >+red_channel_pipe_item_init(&inputs_channel->base,&item->base,
> >+   PIPE_ITEM_KEY_MODIFIERS);
> >+item->modifiers = modifiers;
> >  return item;
> >  }
> >
> >@@ -232,33 +249,43 @@ static void inputs_pipe_add_type(InputsChannel 
> >*channel, int type)
> >  static void inputs_channel_release_pipe_item(RedChannel *channel,
> >  PipeItem *base, int item_pushed)
> >  {
> >-// All PipeItems we push are InputsPipeItem
> >-InputsPipeItem *item = (InputsPipeItem*)base;
> >-
> >-if (item->data) {
> >-free(item->data);
> >-}
> >-spice_marshaller_destroy(item->m);
> >-free(item);
> >+free(base);
> >  }
> >
> >  static void inputs_channel_send_item(RedChannel *channel, PipeItem *base)
> >  {
> >-InputsPipeItem *item = SPICE_CONTAINEROF(base, InputsPipeItem, base);
> >-SpiceMarshaller *m = item->m;
> >-uint8_t *data;
> >-size_t len;
> >-int free_data;
> >+InputsChannel *inputs_channel = (InputsChannel *)channel;
> >+SpiceMarshaller *m = inputs_channel->base.send_data.marshaller;
> >
> >  red_channel_reset_send_data(channel);
> >  red_channel_init_send_data(channel, base->type, base);
> >-spice_marshaller_flush(m);
> >-// TODO: use spice_marshaller_fill_iovec. Right now we are doing 
> >something stupid,
> >-// namely copying twice. See reds.c.
> >-data = spice_marshaller_linearize(m, 0,&len,&free_data);
> >-item->data = (free_data&&  len>  0) ? data : NULL;
> >-if (len>  0) {
> >-red_channel_add_buf(channel, data, len);
> >+switch (base->type) {
> >+case PIPE_ITEM_KEY_MODIFIERS:
> >+{
> >+SpiceMsgInputsKeyModifiers key_modifiers;
> >+
> >+key_modifiers.modifiers =
> >+SPICE_CONTAINEROF(base, KeyModifiersPipeItem, 
> >base)->modifiers;
> >+spice_marshall_msg_inputs_key_modifiers(m,&key_modifiers);
> >+}
> >+case PIPE_ITEM_INIT:
> >+{
> >+SpiceMsgInputsInit inputs_init;
> >+
> >+inputs_init.keyboard_modifiers =
> >+SPICE_CONTAINEROF(base, InputsInitPipeItem, 
> >base)->modifiers;
> >+spice_marshall_msg_inputs_init(m,&inputs_init);
> >+}
> >+case PIPE_ITEM_MIGRATE:
> >+{
> >+SpiceMsgMigrate migrate;
> >+
> >+migrate.flags = 0;
> >+spice_marshall_msg_migrate(m,&migrate);
> >+break;
> >+}
> >+default:
> >+break;
> >  }
> >  red_channel_begin_send_message(channel);
> >  }
> >@@ -431,10 +458,12 @@ static void 
> >inputs_channel_on_outgoing_error(RedChannel *channel)
> >
> >  static void inputs_shutdown(Channel *channel)
> >  {
> >-ASSERT(g_inputs_channel == (InputsChannel *)channel->data);
> >-if (g_inputs_channel) {
> >-red_channel_shutdown(&g_inputs_channel->base);
> >-g_inputs_channel->base.incoming.shut = TRUE;
> >+InputsChannel *inputs_channel = (InputsChannel *)channel->data;
> >+ASSERT(g_inputs_channel == inputs_channel);
> >+