popupMenu: Only activate items that still have the pointer

After the introduction of implicit grabs in Clutter, a release
event will now always be delivered to the actor that received
the corresponding press event.

This results in surprising behavior when moving the pointer
while pressed, as a button release will always activate the
original item, even when the pointer moved to a different item
or outside the menu altogether.

Address this by checking the hover state (that is, whether
the item contains the pointer actor) before activating it.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6606

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2740>
This commit is contained in:
Florian Müllner 2023-04-19 12:08:53 +02:00 committed by Marge Bot
parent ec37f2158d
commit 728a94dead

View File

@ -138,6 +138,11 @@ var PopupBaseMenuItem = GObject.registerClass({
return Clutter.EVENT_PROPAGATE;
this.remove_style_pseudo_class('active');
// Pointer left the item during the grab
if (!this.hover)
return Clutter.EVENT_PROPAGATE;
this.activate(Clutter.get_current_event());
return Clutter.EVENT_STOP;
}