mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 13:24:09 +00:00
ClutterSeatEvdev: Keep track of button count
libinput does it for us, but only for physical devices. When we add virtual devices to the same seat, we need to track button press count ourself. https://bugzilla.gnome.org/show_bug.cgi?id=765009
This commit is contained in:
parent
d2b05f0305
commit
e928370bf0
@ -205,6 +205,25 @@ queue_event (ClutterEvent *event)
|
||||
_clutter_event_push (event, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
update_button_count (ClutterSeatEvdev *seat,
|
||||
uint32_t button,
|
||||
uint32_t state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
return ++seat->button_count[button];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle cases where we newer saw the initial pressed event. */
|
||||
if (seat->button_count[button] == 0)
|
||||
return 0;
|
||||
|
||||
return --seat->button_count[button];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
|
||||
ClutterInputDevice *device,
|
||||
@ -217,6 +236,16 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
|
||||
ClutterEvent *event = NULL;
|
||||
enum xkb_state_component changed_state;
|
||||
|
||||
if (state != AUTOREPEAT_VALUE)
|
||||
{
|
||||
/* Drop any repeated button press (for example from virtual devices. */
|
||||
int count = update_button_count (seat, key, state);
|
||||
if (state && count > 1)
|
||||
return;
|
||||
if (!state && count != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* We can drop the event on the floor if no stage has been
|
||||
* associated with the device yet. */
|
||||
stage = _clutter_input_device_get_stage (device);
|
||||
@ -410,6 +439,14 @@ clutter_seat_evdev_notify_button (ClutterSeatEvdev *seat,
|
||||
CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON3_MASK, CLUTTER_BUTTON2_MASK,
|
||||
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK, 0, 0, 0
|
||||
};
|
||||
int button_count;
|
||||
|
||||
/* Drop any repeated button press (for example from virtual devices. */
|
||||
button_count = update_button_count (seat, button, state);
|
||||
if (state && button_count > 1)
|
||||
return;
|
||||
if (!state && button_count != 0)
|
||||
return;
|
||||
|
||||
/* We can drop the event on the floor if no stage has been
|
||||
* associated with the device yet. */
|
||||
|
@ -28,6 +28,7 @@
|
||||
#define __CLUTTER_SEAT_EVDEV_H__
|
||||
|
||||
#include <libinput.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
#include "clutter-input-device.h"
|
||||
#include "clutter-device-manager-evdev.h"
|
||||
@ -58,6 +59,7 @@ struct _ClutterSeatEvdev
|
||||
xkb_led_index_t num_lock_led;
|
||||
xkb_led_index_t scroll_lock_led;
|
||||
uint32_t button_state;
|
||||
int button_count[KEY_CNT];
|
||||
|
||||
/* keyboard repeat */
|
||||
gboolean repeat;
|
||||
|
Loading…
x
Reference in New Issue
Block a user