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

Mouse release event not sent when dragging item outside window

    XMLWordPrintable

Details

    • Windows
    • 00cfb4d7801ec9b5d9b070879ef4a962390628b7 (qt/qtbase/5.12)

    Description

      Drag and drop inside the same window works as expected. But when I drag the item outside the window (like onto the desktop, console, etc), the mouse release event is not sent. The item sticks to the mouse cursor if the mouse is moved back into the window. Probably because of the missing release event.

      I have looked into the source code and found this line:

      http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/windows/qwindowsdrag.cpp?h=5.12#n406

      Commenting it out resolved the issue, but is probably not the cause. I have looked further and found QWindowsOleDropTarget::DragLeave which is more likely to be the root cause:

      http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/windows/qwindowsdrag.cpp?h=5.12#n575

      It resets QGuiApplicationPrivate::mouse_buttons to Qt::NoButton. I have changed the line to this:

      QWindowSystemInterface::handleDrag(m_window, 0, QPoint(), Qt::IgnoreAction,
                                             QGuiApplicationPrivate::mouse_buttons,
                                             QGuiApplicationPrivate::modifier_buttons);
      

      And it works as expected. I am no expert, so I am not sure if this should be the default.

      Attachments

        1. DragDropSample.diff
          0.8 kB
        2. DragDropSample.gif
          DragDropSample.gif
          109 kB
        3. DragDropSample.qml
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            anrocha André De La Rocha (Inactive)
            shinryo Shinryo Yusako
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes