Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-49525

Subtle focus bug in qt5 xembed client

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.2.1, 5.6.0 Alpha
    • QPA: X11/XCB
    • 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.

      http://sourceforge.net/p/djvu/djview-git/ci/58a15bf9d142891c421b784b38464f54180499f7/tree/src/qdjvuwidget.cpp?diff=ce97c52fdef0d6d4defb81b6e3dbe9893e28e4a6

      === 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.
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            liaqi Liang Qi
            leonb Leon Bottou
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes