[Interest] Has X event handling changed from Qt 4 to 5?

Scott Kostyshak skostysh at lyx.org
Mon Jun 16 09:23:02 CEST 2014


On Sun, Jun 15, 2014 at 11:45 AM, Thiago Macieira
<thiago.macieira at intel.com> wrote:
> Em dom 15 jun 2014, às 03:05:29, Scott Kostyshak escreveu:
>> Hi,
>>
>> At LyX we use xvkbd to send key presses for the purposes of testing.
>> When building LyX with Qt 5 [1], our scripts no longer send capital
>> letters as capital letters. They are instead sent as lower case
>> letters. With Qt 4.8.5 they are sent correctly as upper case letters.
>> Another LyX developer has independently confirmed the above behavior.
>>
>> The problem only occurs when using XSendEvent(). The following results
>> in "hello world" (on LyX built with Qt 5):
>> xvkbd -no_root -wait_idle 18844 -xsendevent -window 0x05400008 -delay
>> 100 -text "Hello World"
>> while this results in "Hello World" (also with Qt 5):
>> xvkbd -no_root -wait_idle 18844 -window 0x05400008 -delay 100 -text
>> "Hello World"
>>
>> I've contacted the xvkbd author and he suspects a change in how X
>> events are handled by Qt.
>
> Yes, the event handling changed completely. The entire code dealing with X was
> rewritten from scratch and now uses XCB instead of libX11.

Good to know.

> The question we have here is: what events are received by the application?

Below I will give different outputs from sending "H" between Qt 4 and
Qt 5 generated by the following code, where ev is a QKeyEvent*:

(from the file src/frontends/qt4/GuiWorkArea.cpp)
        LYXERR(Debug::KEY, " count: " << ev->count() << " text: " << ev->text()
                << " isAutoRepeat: " << ev->isAutoRepeat() << " key: "
<< ev->key()
                << " keyState: " << str);

I don't think it's relevant because it is the same in both cases, but
if you would like to know how str is created, you can see it at
http://www.lyx.org/trac/browser/lyxgit/src/frontends/qt4/GuiWorkArea.cpp
lines 1060 to 1070, which in turn relies on q_key_state which is defined at
http://www.lyx.org/trac/browser/lyxgit/src/frontends/qt4/GuiKeySymbol.cpp
lines 744 to 761.

In both cases, Shift_L is detected in the same way:
count: 1 text:  isAutoRepeat: 0 key: 16777248 keyState: Shift-

Then there is a difference for the next event.
Good:
count: 1 text: H isAutoRepeat: 0 key: 72 keyState: Shift-
Bad:
count: 1 text: h isAutoRepeat: 0 key: 72 keyState: Shift-

"Good" is from Qt 4.8.5 when using xvkbd, or from manually typing in
"H" (by pressing shift and "h") in Qt 4.8.5 or Qt 5.
"Bad" is from Qt 5 when using xvkbd.

Note that I know little about Qt so I'm not sure if this is enough to
show the raw key events being received. If the output of other
QKeyEvent methods would be useful, let me know.

Thanks for your help,

Scott



More information about the Interest mailing list