Bug 380354

Summary: Drag select does not stop on releasing left mouse button in Folder View Widget
Product: [Plasma] plasmashell Reporter: geetam chawla <geetam.chawla>
Component: FolderAssignee: Eike Hein <hein>
Status: RESOLVED FIXED    
Severity: normal CC: bugseforuns, plasma-bugs, playnamegaming
Priority: NOR    
Version: 5.9.5   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description geetam chawla 2017-05-30 14:02:28 UTC
How to reproduce this bug:

1) Click the left mouse button inside folder view widget and drag through an area.
2) Release the left mouse button, but drag-select does not stop.
3) Click the left mouse button elsewhere in the folder view widget, drag-select still does not stop.
Comment 1 geetam chawla 2017-05-30 14:21:13 UTC
Step 1) of the previous comment is wrong, apologies.

correct step 1) click and hold on the folder view widget to drag it to some position.

Rest of the steps are correct.
Comment 2 Eike Hein 2017-06-07 09:06:18 UTC
*** Bug 380905 has been marked as a duplicate of this bug. ***
Comment 3 Eike Hein 2017-06-17 03:25:49 UTC
Patch under review at https://phabricator.kde.org/D6246
Comment 4 Eike Hein 2017-06-19 10:35:17 UTC
Git commit fd4d41bd65fd3a3190471476104b0bac9f8ab542 by Eike Hein.
Committed on 17/06/2017 at 03:24.
Pushed by hein into branch 'master'.

Don't rely on QQuickWindow delivering QEvent::Ungrab as mouseUngrabEvent (as it no longer does in Qt 5.8+)

Summary:
QQuickWindow::sendEvent in Qt 5.7 and older had the following code
to deliver QEvent::UngrabMouse by calling QQuickItem::mouseUngrabEvent:

case QEvent::UngrabMouse: {
        QSet<QQuickItem *> hasFiltered;
        if (!d->sendFilteredMouseEvent(item->parentItem(), item, e, &hasFiltered)) {
            e->accept();
            item->mouseUngrabEvent();
        }
    }

This is gone from Qt 5.8+. While QEvent::Ungrab is still delivered to
items, QQuickItem::mouseUngrabEvent is only called under constrained
circumstances elsewhere, e.g. when ending an actual mouse grab held by
an item and tracked by Qt.

MouseEventListener relied on mouseUngrabEvent being called to implement
something akin to MouseArea::canceled: Signaling a user it should clean
up state after a press event, instead of, say, assuming the button is
still held and waiting around for a release event. While QEvent::Ungrab
was already being intercepted as well, it was only done for event de-
duplication, not used for the above.

This changes the code so handleUngrab checks first whether we're
actually in press state (to make it safe to call repeatedly) and then
call it from both the generic event handler and mouseUngrabEvent. This
makes it work again with newer Qts.

We rely on this particularly in the desktop containment, where we use
EventGenerator from this same lib to deliver QEvent::Ungrab to applets
when the containment goes into applet move mode on press-and-hold.
Without MouseEventListener emiting canceled in response, e.g. moving
a Folder View applet will e.g. put it into rectangle selection mode
unwanted.

Reviewers: #plasma

Subscribers: plasma-devel, #frameworks

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D6246

M  +7    -4    src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.cpp

https://commits.kde.org/kdeclarative/fd4d41bd65fd3a3190471476104b0bac9f8ab542