MetaWaylandSeat: don't use use events to count pressed buttons

Use the modifier mask instead, as events can get lost if there
is a clutter grab or if some other actor is capturing events.

https://bugzilla.gnome.org/show_bug.cgi?id=706124
This commit is contained in:
Giovanni Campagna 2013-08-16 12:13:26 +02:00
parent 9f64f2cf4f
commit 28708e4317

View File

@ -357,9 +357,8 @@ handle_button_event (MetaWaylandSeat *seat,
break; break;
} }
if (state) /* FIXME: synth a XI2 event and handle in display.c */
{ if (state && pointer->button_count == 1)
if (pointer->button_count == 0)
{ {
MetaWaylandSurface *surface = pointer->current; MetaWaylandSurface *surface = pointer->current;
@ -377,11 +376,6 @@ handle_button_event (MetaWaylandSeat *seat,
} }
} }
pointer->button_count++;
}
else
pointer->button_count--;
pointer->grab->interface->button (pointer->grab, event->time, button, state); pointer->grab->interface->button (pointer->grab, event->time, button, state);
if (pointer->button_count == 1) if (pointer->button_count == 1)
@ -430,10 +424,34 @@ handle_scroll_event (MetaWaylandSeat *seat,
value); value);
} }
static int
count_buttons (const ClutterEvent *event)
{
static gint maskmap[5] =
{
CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK
};
ClutterModifierType mod_mask;
int i, count;
mod_mask = clutter_event_get_state (event);
count = 0;
for (i = 0; i < 5; i++)
{
if (mod_mask & maskmap[i])
count++;
}
return count;
}
void void
meta_wayland_seat_handle_event (MetaWaylandSeat *seat, meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
const ClutterEvent *event) const ClutterEvent *event)
{ {
seat->pointer.button_count = count_buttons (event);
switch (event->type) switch (event->type)
{ {
case CLUTTER_MOTION: case CLUTTER_MOTION: