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:
@ -192,14 +192,15 @@ var ScreenShield = class {
|
||||
if (this._isModal)
|
||||
return true;
|
||||
|
||||
this._isModal = Main.pushModal(this.actor, { actionMode: Shell.ActionMode.LOCK_SCREEN });
|
||||
if (this._isModal)
|
||||
return true;
|
||||
let grab = Main.pushModal(this.actor, { actionMode: Shell.ActionMode.LOCK_SCREEN });
|
||||
|
||||
// We expect at least a keyboard grab here
|
||||
this._isModal = (grab.get_seat_state() & Clutter.GrabState.KEYBOARD) !== 0;
|
||||
if (this._isModal)
|
||||
this._grab = grab;
|
||||
else
|
||||
Main.popModal(grab);
|
||||
|
||||
// We failed to get a pointer grab, it means that
|
||||
// something else has it. Try with a keyboard grab only
|
||||
this._isModal = Main.pushModal(this.actor, { options: Meta.ModalOptions.POINTER_ALREADY_GRABBED,
|
||||
actionMode: Shell.ActionMode.LOCK_SCREEN });
|
||||
return this._isModal;
|
||||
}
|
||||
|
||||
@ -550,7 +551,8 @@ var ScreenShield = class {
|
||||
this._dialog.popModal();
|
||||
|
||||
if (this._isModal) {
|
||||
Main.popModal(this.actor);
|
||||
Main.popModal(this._grab);
|
||||
this._grab = null;
|
||||
this._isModal = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user