mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-24 03:10:37 +01:00
pad: honor send-events mode
The custom implementation of the send-events mode for tablet pads does not actually suspend and resume the device, so events continue to be sent despite the device being theoretically disabled. Fix this by removing the custom send-events implementation in favor of evdev_dispatch's implementation. Also add a simple test to ensure the send-events mode works. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1238>
This commit is contained in:
parent
fca5154d1d
commit
84085edc04
3 changed files with 37 additions and 57 deletions
|
|
@ -836,52 +836,6 @@ pad_init(struct pad_dispatch *pad, struct evdev_device *device)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
pad_sendevents_get_modes(struct libinput_device *device)
|
||||
{
|
||||
return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
|
||||
}
|
||||
|
||||
static enum libinput_config_status
|
||||
pad_sendevents_set_mode(struct libinput_device *device,
|
||||
enum libinput_config_send_events_mode mode)
|
||||
{
|
||||
struct evdev_device *evdev = evdev_device(device);
|
||||
struct pad_dispatch *pad = (struct pad_dispatch*)evdev->dispatch;
|
||||
|
||||
if (mode == pad->sendevents.current_mode)
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
|
||||
switch(mode) {
|
||||
case LIBINPUT_CONFIG_SEND_EVENTS_ENABLED:
|
||||
break;
|
||||
case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
|
||||
pad_suspend(evdev->dispatch, evdev);
|
||||
break;
|
||||
default:
|
||||
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
pad->sendevents.current_mode = mode;
|
||||
|
||||
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum libinput_config_send_events_mode
|
||||
pad_sendevents_get_mode(struct libinput_device *device)
|
||||
{
|
||||
struct evdev_device *evdev = evdev_device(device);
|
||||
struct pad_dispatch *dispatch = (struct pad_dispatch*)evdev->dispatch;
|
||||
|
||||
return dispatch->sendevents.current_mode;
|
||||
}
|
||||
|
||||
static enum libinput_config_send_events_mode
|
||||
pad_sendevents_get_default_mode(struct libinput_device *device)
|
||||
{
|
||||
return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
||||
}
|
||||
|
||||
struct evdev_dispatch *
|
||||
evdev_tablet_pad_create(struct evdev_device *device)
|
||||
{
|
||||
|
|
@ -894,12 +848,7 @@ evdev_tablet_pad_create(struct evdev_device *device)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
device->base.config.sendevents = &pad->sendevents.config;
|
||||
pad->sendevents.current_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
||||
pad->sendevents.config.get_modes = pad_sendevents_get_modes;
|
||||
pad->sendevents.config.set_mode = pad_sendevents_set_mode;
|
||||
pad->sendevents.config.get_mode = pad_sendevents_get_mode;
|
||||
pad->sendevents.config.get_default_mode = pad_sendevents_get_default_mode;
|
||||
evdev_init_sendevents(device, &pad->base);
|
||||
|
||||
return &pad->base;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,11 +85,6 @@ struct pad_dispatch {
|
|||
double dial2;
|
||||
} dials;
|
||||
|
||||
struct {
|
||||
struct libinput_device_config_send_events config;
|
||||
enum libinput_config_send_events_mode current_mode;
|
||||
} sendevents;
|
||||
|
||||
struct {
|
||||
struct list mode_group_list;
|
||||
} modes;
|
||||
|
|
|
|||
|
|
@ -1145,6 +1145,40 @@ START_TEST(pad_keys)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(pad_send_events_disabled)
|
||||
{
|
||||
struct litest_device *dev = litest_current_device();
|
||||
struct libinput *li = dev->libinput;
|
||||
enum libinput_config_status status;
|
||||
|
||||
litest_drain_events(li);
|
||||
|
||||
status = libinput_device_config_send_events_set_mode(
|
||||
dev->libinput_device,
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED);
|
||||
litest_assert_enum_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
|
||||
litest_pad_strip_start(dev, 10);
|
||||
litest_assert_empty_queue(li);
|
||||
litest_pad_strip_change(dev, 100);
|
||||
litest_assert_empty_queue(li);
|
||||
litest_pad_strip_end(dev);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_pad_ring_start(dev, 10);
|
||||
litest_assert_empty_queue(li);
|
||||
litest_pad_ring_change(dev, 100);
|
||||
litest_assert_empty_queue(li);
|
||||
litest_pad_ring_end(dev);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
pad_key_down(dev, KEY_BUTTONCONFIG);
|
||||
litest_assert_empty_queue(li);
|
||||
pad_key_up(dev, KEY_BUTTONCONFIG);
|
||||
litest_assert_empty_queue(li);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
TEST_COLLECTION(pad)
|
||||
{
|
||||
litest_add(pad_cap, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
|
|
@ -1187,4 +1221,6 @@ TEST_COLLECTION(pad)
|
|||
litest_add(pad_mode_group_has_no_toggle, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
|
||||
litest_add(pad_keys, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
|
||||
litest_add(pad_send_events_disabled, LITEST_TABLET_PAD, LITEST_ANY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue