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

Touch events are not correctly handled when QWindow is reparented onto native Window, resulting in touch offset

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.10
    • QPA: Windows
    • None
    • mapFromGlobal: 58f46077015fc5dd71543ca25f762ff34fc12621 (qtbase/5.10, 3.11.2017, 5.10.0)

    Description

      My application requires to be embbeded on a native Windows window to be used as a plugin on a software host. To embeb it I do the following:

      window = new QWindow();
      window->setFlags(Qt::Tool | Qt::FramelessWindowHint);
      window->setGeometry(0, 0, 800, 600);
      
      quickView = new QQuickView();
      quickView->setSource(QUrl("qrc:/main.qml"));
      quickView->setFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
      
      SetParent((HWND)window->winId(), nativeWindowPointer);
      
      quickView->setParent(window);
      quickView->show();
      
      window->show();
      

      Everything works perfectly with a mouse but not with a touchscreen. On a standalone Qt app, the touch is correctly handled, but when the program runs inside the host, with the QWindow reparented to the provided window, the touch screen suffers an offset. The offset varies when the windows is moved. Mouse events are processed correctly in both situations. This only affects touch events.

      I have been able to create a Qt based example by instanciating two windows. One window that will have the second window embed as I need in my real case scenario.

      In attached example, a first window is created and then the secondd window is embbeded onto the first window. If you try to interact with the red rectangle with the mouse you will succeed to have console output whatever the window position is. 

      With touch input, it will work unless the window position is changed. The touch mapping is wrong if the parent window position is changed as it seems to rely on the initial window position.

      Attachments

        1. qtbug64116_diag.diff
          2 kB
          Friedemann Kleint
        2. qtbug64116.zip
          5 kB
          Friedemann Kleint
        3. qtbug-reparented-window-touch-offset.zip
          5 kB
          Nuno Santos

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              sinosoidal Nuno Santos
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes