main: Use Clutter.grab() underneath Main.push/popModal

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2045>
This commit is contained in:
Carlos Garnacho 2021-11-18 00:36:44 +01:00
parent 49b9ae08d8
commit f4cae72d17

View File

@ -544,13 +544,10 @@ function pushModal(actor, params) {
options: 0, options: 0,
actionMode: Shell.ActionMode.NONE }); actionMode: Shell.ActionMode.NONE });
if (modalCount == 0) { let grab = global.stage.grab(actor);
if (!global.begin_modal(params.timestamp, params.options)) {
log('pushModal: invocation of begin_modal failed'); if (modalCount === 0)
return false;
}
Meta.disable_unredirect_for_display(global.display); Meta.disable_unredirect_for_display(global.display);
}
modalCount += 1; modalCount += 1;
let actorDestroyId = actor.connect('destroy', () => { let actorDestroyId = actor.connect('destroy', () => {
@ -571,10 +568,12 @@ function pushModal(actor, params) {
}); });
} }
modalActorFocusStack.push({ actor, modalActorFocusStack.push({ actor,
grab,
destroyId: actorDestroyId, destroyId: actorDestroyId,
prevFocus, prevFocus,
prevFocusDestroyId, prevFocusDestroyId,
actionMode }); actionMode,
});
actionMode = params.actionMode; actionMode = params.actionMode;
global.stage.set_key_focus(actor); global.stage.set_key_focus(actor);
@ -602,7 +601,6 @@ function popModal(actor, timestamp) {
let focusIndex = _findModal(actor); let focusIndex = _findModal(actor);
if (focusIndex < 0) { if (focusIndex < 0) {
global.stage.set_key_focus(null); global.stage.set_key_focus(null);
global.end_modal(timestamp);
actionMode = Shell.ActionMode.NORMAL; actionMode = Shell.ActionMode.NORMAL;
throw new Error('incorrect pop'); throw new Error('incorrect pop');
@ -613,6 +611,9 @@ function popModal(actor, timestamp) {
let record = modalActorFocusStack[focusIndex]; let record = modalActorFocusStack[focusIndex];
record.actor.disconnect(record.destroyId); record.actor.disconnect(record.destroyId);
let grab = record.grab;
grab.dismiss();
if (focusIndex == modalActorFocusStack.length - 1) { if (focusIndex == modalActorFocusStack.length - 1) {
if (record.prevFocus) if (record.prevFocus)
record.prevFocus.disconnect(record.prevFocusDestroyId); record.prevFocus.disconnect(record.prevFocusDestroyId);
@ -650,7 +651,6 @@ function popModal(actor, timestamp) {
return; return;
layoutManager.modalEnded(); layoutManager.modalEnded();
global.end_modal(timestamp);
Meta.enable_unredirect_for_display(global.display); Meta.enable_unredirect_for_display(global.display);
actionMode = Shell.ActionMode.NORMAL; actionMode = Shell.ActionMode.NORMAL;
} }