js: Change main.pushModal to return the Clutter.Grab handle

All callers have been updated to keep this handle to identify their
own grab.

Also, optionally use the windowing state to determine whether
the grab is suitable for the specific uses. This removes the need
to trying to grab twice in the places where we settle for a keyboard
grab.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2045>
This commit is contained in:
Carlos Garnacho
2021-11-25 10:49:42 +01:00
parent 2709f6c102
commit 7419674bd3
12 changed files with 87 additions and 52 deletions

View File

@ -904,9 +904,13 @@ var UnlockDialog = GObject.registerClass({
timestamp,
actionMode: Shell.ActionMode.UNLOCK_SCREEN,
};
if (!Main.pushModal(this, modalParams))
let grab = Main.pushModal(this, modalParams);
if (grab.get_seat_state() !== Clutter.GrabState.ALL) {
Main.popModal(grab);
return false;
}
this._grab = grab;
this._isModal = true;
return true;
@ -918,7 +922,8 @@ var UnlockDialog = GObject.registerClass({
popModal(timestamp) {
if (this._isModal) {
Main.popModal(this, timestamp);
Main.popModal(this._grab, timestamp);
this._grab = null;
this._isModal = false;
}
}