Fix unintentional breadcrumb menu item activation
ClosedPublic

Authored by aleksejshilin on Nov 23 2017, 12:05 AM.

Details

Summary

Since breadcrumb menu is opened on mouse press, it may receive
the corresponding mouse release event which may unintentionally
activate the random item which happens to be under mouse pointer.

This commit makes the menu ignore the first mouse release event
unless the pointer was moved. It fixes the issue and still allows
'Press mouse button' -> 'Move to an item' -> 'Release the button'
usage scenario.

BUG: 380287
FIXED-IN: 5.44

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
aleksejshilin created this revision.Nov 23 2017, 12:05 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptNov 23 2017, 12:05 AM

I think you should store the mouse position and then check whether the manhattanLength() between new and old is >= QApplication::startDragDisance() to be consistent with regular click and drag drop handling – not everyone is capable of holding a mouse perfectly still.

  • Don't consider mouse moves which are smaller than drag distance
  • Don't pass the ignored mouse release event to the base class

So, any comments on the updated revision?

Hi again. :)
Any news on this? Is there anything I should improve?

Would you mind re-basing this on master? I can reproduce the issue and would be happy to test the patch.

aleksejshilin updated this revision to Diff 26872.EditedFeb 10 2018, 2:23 PM

Rebase on master

ngraham added inline comments.Feb 10 2018, 2:27 PM
src/filewidgets/kurlnavigatormenu.cpp
85 ↗(On Diff #26872)

Will this still work if the user is using the mouse in left-handed mode?

aleksejshilin added inline comments.Feb 10 2018, 2:43 PM
src/filewidgets/kurlnavigatormenu.cpp
85 ↗(On Diff #26872)

Quoting Qt documentation [1]:

Qt::LeftButtonThe left button is pressed, or an event refers to the left button. (The left button may be the right button on left-handed mice.)

Should work just fine.

[1] http://doc.qt.io/qt-5/qt.html#MouseButton-enum

OK cool. The patch works for me! +1. Get a code review from someone else before committing.

OK cool. The patch works for me! +1.

Great, thanks a lot!

Get a code review from someone else before committing.

I don't have push access, so no worries. :)

Instead of the bool member, isn't it enough to test the distance again in mouseReleaseEvent? AFAIK that's how most widget do it. It also leads to one difference of behaviour in case someone moves the mouse a bit and then back to the original position, in that case the mouseReleaseEvent considers that no move happened (not sure if that's what you want here).

Instead of the bool member, isn't it enough to test the distance again in mouseReleaseEvent? AFAIK that's how most widget do it. It also leads to one difference of behaviour in case someone moves the mouse a bit and then back to the original position, in that case the mouseReleaseEvent considers that no move happened (not sure if that's what you want here).

If user moved the mouse considerably, then it's assumed to be intentional, and the subsequent release event shouldn't be ignored even if the final position is the same as the initial one. This way it is consistent with drag'n'drop behavior.

Besides, only the first mouse release event should be ignored, so a flag is needed anyway.

dfaure accepted this revision.Feb 19 2018, 7:58 AM

Ah, OK.

This revision is now accepted and ready to land.Feb 19 2018, 7:58 AM
aleksejshilin edited the summary of this revision. (Show Details)Feb 23 2018, 5:35 PM

@aleksejshilin doesn't have commit access, so would you like to land this, @dfaure?

This revision was automatically updated to reflect the committed changes.

@aleksejshilin doesn't have commit access

Actually, I do now. :)