Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.2.1, 5.6.0 Alpha
-
Ubuntu Trusty
Description
This was found by tracking issues with the djvu plugin.
The xembed host is firefox 42 running a gtksocket.
Before the workaround, clicking in the embedded djview window would not cause it to send the XEMBED_REQUEST_FOCUS message to the xembed host. As a result djview used to never get the keyboard focus.
After debugging the issue, I found that this was caused by the fact that the central subwidget of the djview application is marked with WA_NativeWindow. Therefore when a buttonpress event reaches QXcbWindow::handleButtonPressEvent, it does so in the native subwidget which does not have flag m_embedded set (because the embedded one is the main window of the djview program).
The workaround was to remove WA_NativeWindow under Qt5.
=== Steps to reproduce ===:
$ git clone git clone git://git.code.sf.net/p/djvu/djview-git djvu-djview-git
$ git checkout ce97c52f
$ cd djview
$ DJVIEW=`pwd`
$ ./autogen.sh;
$ make
$ cd /usr/lib/mozilla/plugins
$ ln -s $DJVIEW/nsdejavu/src/.libs/nsdejavu.so
$ cd $DJVIEW/nsdejavu
$ killall firefox
$ cp somedjvufile.djvu test.djvu
$ NPX_DJVIEW=$DJVIEW/src/djview firefox test.html
Try to obtain focus by clicking in the djvu window. Then remove WA_NativeWindow line 2053 of $DJVIEW/src/qdjvuwidget.cpp, recompile, restart firefox, and it works.
=== Analysis and suggested fix.===
See line 2127 in http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/xcb/qxcbwindow.cpp#n2127
When the button press event arrives here, the m_embedded flag is not set because the corresponding QXcbWindow is the native window corresponding to the djview central subwidget. On the other hand, the m_embedded flag is set in the main widget, The fix is to instead do something like testing
if (this->toplevelQXcbWindow(?)->m_embedded) { // send XEMBED_REQUEST_FOCUS.