[Development] Question about modifiers in key events
Oliver Wolff
oliver.wolff at digia.com
Tue Jan 14 08:26:34 CET 2014
Hi,
I am trying to fix https://bugreports.qt-project.org/browse/QTBUG-35632
and while
doing so I noticed that this use case is broken on Linux, Windows and
Mac. Running
the code from my last comment I get different results depending on the
platform. When
it is run on Linux or Windows I get:
Event: true false false
Application: false false false
while Mac gives:
Event: false false false
Application: false false false
At least on Windows and Linux (xcb) there seems to be logic involved
which removes
the modifier if the key pressed was a modifier key itself (so if
Qt::Key_Control is pressed
Qt::ControlModifier is removed from the modifiers). This is done in
qwindowskeymapper
line 863ff on Windows. I could not find the place where it is done in
xcb but checking the
code from the bug gives the same result as on Windows. The event's
modifiers are then
assigned to QGuiApplication's modifier_buttons (which is used for
QApplication::keyboardModifiers() from the bugreport), which is why that
shows wrong results.
QEvent::modifiers (qevent.cpp line 1026ff) readds the modifier so that
this gives correct results
at least on Linux and Windows.
My question is which would be the "right way" to fix this behaviour. My
initial idea was to remove
the logic that removes the modifier from Windows and XCB and adapt
QEvent::modifiers accordingly
so that the modifiers are not removed and added in various places.
Unfortunately I do not know, which
behaviour/use case would be broken by that as auto test coverage seems
to be not existent in that area
(which I would like to change as well, but...). Another option would be
to add the logic that readds the
modifier (the one from QEvent::modifers) to QGuiApplicationPrivate, but
that would be another place
that "plays around with the modifiers". Also this logic would have to be
put in use in several places there
(processKeyEvent, processMouseEvent, processTabletEvent, etc).
Does anyone have an idea, why modifiers are removed/added in various
places and which use case might
be broken when I touch something there? Thiscode seems to be fragile, as
changes seem to cause regressions
as we have seen over the last few patches to the windows implementation.
Any preferred way of fixing this?
Cheers,
Olli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140114/2a695aa8/attachment.html>
More information about the Development
mailing list