Fix TouchEvent::id() returning -1, fixes a crash
ClosedPublic

Authored by jessep on Sep 16 2017, 7:34 PM.

Details

Summary

Libinput returns -1 when calling libinput_event_touch_get_slot on an event
from a single-touch touchscreen. The returned value is used in
DecorationEventFilter to determine the touch which is acting on it. The value -1
is used to signify that the decoration is not being acted on. Thus when
releasing the touch, it checks whether it was being dragged, and as it thinks
it isn't, it doesn't handle it and the decoration is still being dragged.
Clicking on the decoration then crashes kwin.

Test Plan

Move a window by dragging the decoration with a single-touch touchscreen.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
jessep created this revision.Sep 16 2017, 7:34 PM
Restricted Application added a project: KWin. · View Herald TranscriptSep 16 2017, 7:34 PM
Restricted Application added subscribers: KWin, kwin. · View Herald Transcript
jessep added a reviewer: KWin.Sep 17 2017, 8:59 AM

If you want you could add another testcase in autotests/libinput/touch_event_test.cpp to cover the special condition.

Otherwise looks good and is quite straight forward. Thanks for this fix.

libinput/events.cpp
229

I suggest to const this.

jessep updated this revision to Diff 19608.Sep 17 2017, 11:48 AM
  • Add a test for slotless touch event id
  • Make variable const
jessep marked an inline comment as done.Sep 17 2017, 11:49 AM
graesslin accepted this revision.Sep 18 2017, 7:13 PM

Do you have commit rights or should one of us push for you?

This revision is now accepted and ready to land.Sep 18 2017, 7:13 PM
This revision was automatically updated to reflect the committed changes.