From 4292ad0292e719bf57b2bd1e8b2d1e156264faad Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 19 Aug 2020 12:38:20 +0200 Subject: [PATCH] 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 --- src/widgets/widgets/qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 9528be17b7..eba20445aa 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -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());