QMenu: make less sensitive to mouse jitter

On systems where a right-press brings up the menu, the next mouse
move will select an action, even if it's just a move by a single pixel.
This makes it too easy to activate an action on e.g a context menu
accidentially when the button is released.

Ignore the first couple of mouse moves, using the same logic that
prevents accidental tearing off.

Change-Id: Ib4dd448ef2d6ae915b48da62666aa95b37145d63
Fixes: QTBUG-57849
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-08-19 12:38:20 +02:00
parent ecfb5d2d15
commit 4292ad0292

View File

@ -3473,7 +3473,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e)
return;
d->motions++;
if (d->motions == 0)
if (!d->hasMouseMoved(e->globalPosition().toPoint()))
return;
d->hasHadMouse = d->hasHadMouse || rect().contains(e->position().toPoint());