dialog: Handle key events on self

And set the dialog actor reactive. Specifically, we do not know whether
the parent actor is reactive or not, and we should not be changing that
from here, so do not use that actor to handle key events.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2045>
This commit is contained in:
Carlos Garnacho 2022-01-28 11:59:51 +01:00
parent 7419674bd3
commit 21913b45af

View File

@ -13,7 +13,10 @@ function _setLabel(label, value) {
var Dialog = GObject.registerClass( var Dialog = GObject.registerClass(
class Dialog extends St.Widget { class Dialog extends St.Widget {
_init(parentActor, styleClass) { _init(parentActor, styleClass) {
super._init({ layout_manager: new Clutter.BinLayout() }); super._init({
layout_manager: new Clutter.BinLayout(),
reactive: true,
});
this.connect('destroy', this._onDestroy.bind(this)); this.connect('destroy', this._onDestroy.bind(this));
this._initialKeyFocus = null; this._initialKeyFocus = null;
@ -27,7 +30,6 @@ class Dialog extends St.Widget {
this._dialog.add_style_class_name(styleClass); this._dialog.add_style_class_name(styleClass);
this._parentActor = parentActor; this._parentActor = parentActor;
this._eventId = this._parentActor.connect('event', this._modalEventHandler.bind(this));
this._parentActor.add_child(this); this._parentActor.add_child(this);
} }
@ -70,7 +72,7 @@ class Dialog extends St.Widget {
this.makeInactive(); this.makeInactive();
} }
_modalEventHandler(actor, event) { vfunc_event(event) {
if (event.type() == Clutter.EventType.KEY_PRESS) { if (event.type() == Clutter.EventType.KEY_PRESS) {
this._pressedKey = event.get_key_symbol(); this._pressedKey = event.get_key_symbol();
} else if (event.type() == Clutter.EventType.KEY_RELEASE) { } else if (event.type() == Clutter.EventType.KEY_RELEASE) {