mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-04 05:00:14 +01:00
touchpad: check for a switch type before handling the event
Don't call get_switch_event immediately, doing so for non-switch events is documented as a bug. Check the event type instead, if that one is correct then we can assume the rest works. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
9b4f587390
commit
87f3ea760c
1 changed files with 12 additions and 12 deletions
|
|
@ -1562,19 +1562,19 @@ tp_lid_switch_event(uint64_t time, struct libinput_event *event, void *data)
|
|||
struct tp_dispatch *tp = data;
|
||||
struct libinput_event_switch *swev;
|
||||
|
||||
swev = libinput_event_get_switch_event(event);
|
||||
if (libinput_event_get_type(event) != LIBINPUT_EVENT_SWITCH_TOGGLE)
|
||||
return;
|
||||
|
||||
if (swev) {
|
||||
switch (libinput_event_switch_get_switch_state(swev)) {
|
||||
case LIBINPUT_SWITCH_STATE_OFF:
|
||||
tp_resume(tp, tp->device);
|
||||
log_debug(tp_libinput_context(tp), "lid: resume touchpad\n");
|
||||
break;
|
||||
case LIBINPUT_SWITCH_STATE_ON:
|
||||
tp_suspend(tp, tp->device);
|
||||
log_debug(tp_libinput_context(tp), "lid: suspend touchpad\n");
|
||||
break;
|
||||
}
|
||||
swev = libinput_event_get_switch_event(event);
|
||||
switch (libinput_event_switch_get_switch_state(swev)) {
|
||||
case LIBINPUT_SWITCH_STATE_OFF:
|
||||
tp_resume(tp, tp->device);
|
||||
log_debug(tp_libinput_context(tp), "lid: resume touchpad\n");
|
||||
break;
|
||||
case LIBINPUT_SWITCH_STATE_ON:
|
||||
tp_suspend(tp, tp->device);
|
||||
log_debug(tp_libinput_context(tp), "lid: suspend touchpad\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue