Send QKeyEvent with Qt::Key as expected by Qt to internal windows

Authored by graesslin on Jul 22 2017, 10:56 AM.



KWin passes the current keysym converted to a Qt::Key in the QKeyEvent.
The current keysym does not always change when a key gets released, so
when pressing a shortcut the release carry a Qt::Key which could be
considered as wrong.

QtWayland transforms the actual pressed/released key into a keysym and
passes that through the QKeyEvent. This change does the same for the
internal windows. A new QKeyEvent is created and adjusted in a way that
it matches what Qt expects.

Why not change everything to how Qt expects it? The key is used at
various places and in KWin internally we expect the behavior how it is
currently implemented. So it's better to use Qt's expectation only when
interacting with Qt.

Also the change carries a workaround for a bug in QKeySequenceEdit
(see QTBUG-62102) and transforms Super to Meta. As this adjustment only
makes sense for the internal windows we need to send in an adjusted
QKeyEvent anyway, so another argument for using the Qt behavior only in
this place.

Test Plan

Can set a shortcut on Wayland and it can be used to activate
the window.

Diff Detail

R108 KWin
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Jul 22 2017, 10:56 AM
Restricted Application added a project: Plasma. · View Herald TranscriptJul 22 2017, 10:56 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson accepted this revision.Aug 18 2017, 12:24 AM
This revision is now accepted and ready to land.Aug 18 2017, 12:24 AM
This revision was automatically updated to reflect the committed changes.