js: Mass move to Clutter.Event getter methods in Clutter.Actor vfuncs

These traditionally got the various ClutterEvent subtype structs as their
argument, so it was not allowed to use ClutterEvent generic getter methods
in these vfuncs. These methods used direct access to struct fields instead.

This got spoiled with the move to make ClutterEvent opaque types, since
these are no longer public structs so GNOME Shell most silently failed to
fetch the expected values from event fields. But since they are not
ClutterEvents either, the getters could not be used on them.

Mutter is changing so that these vmethods all contain an alias to the
one and only Clutter.Event type, thus lifting those barriers, and making
it possible to use the ClutterEvent methods in these vfuncs.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2950
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2872>
This commit is contained in:
Carlos Garnacho
2023-08-08 18:14:04 +02:00
parent 5e36a06835
commit 8423ba44fe
15 changed files with 114 additions and 107 deletions

View File

@ -142,14 +142,14 @@ export const PopupBaseMenuItem = GObject.registerClass({
this._parent = parent;
}
vfunc_key_press_event(keyEvent) {
vfunc_key_press_event(event) {
if (global.focus_manager.navigate_from_event(Clutter.get_current_event()))
return Clutter.EVENT_STOP;
if (!this._activatable)
return super.vfunc_key_press_event(keyEvent);
return super.vfunc_key_press_event(event);
let state = keyEvent.modifier_state;
let state = event.get_state();
// if user has a modifier down (except capslock and numlock)
// then don't handle the key press here
@ -160,7 +160,7 @@ export const PopupBaseMenuItem = GObject.registerClass({
if (state)
return Clutter.EVENT_PROPAGATE;
let symbol = keyEvent.keyval;
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
this.activate(Clutter.get_current_event());
return Clutter.EVENT_STOP;
@ -1244,8 +1244,8 @@ class PopupSubMenuMenuItem extends PopupBaseMenuItem {
return this.menu.isOpen;
}
vfunc_key_press_event(keyPressEvent) {
let symbol = keyPressEvent.keyval;
vfunc_key_press_event(event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Right) {
this._setOpenState(true);
@ -1256,7 +1256,7 @@ class PopupSubMenuMenuItem extends PopupBaseMenuItem {
return Clutter.EVENT_STOP;
}
return super.vfunc_key_press_event(keyPressEvent);
return super.vfunc_key_press_event(event);
}
activate(_event) {