main: Only restore key focus on pop when modal actor is still focused

If something grabs the key focus while a modal is pushed, keeping
key-focus on that actor seems like the smarter thing to do than setting
it back to the last focus after the modal gets popped again. So check if
the key focus actor that we set when pushing the modal got changed when
popping that modal, and if it got changed, simply don't touch key focus.

This fixes a bug with the close dialog, where key focus isn't correctly
set to the dialog after alt-tabbing to a window showing a close dialog.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/786>
This commit is contained in:
Jonas Dreßler 2021-02-13 16:16:20 +01:00 committed by Florian Müllner
parent de834fe307
commit 4d544d7b56

View File

@ -755,7 +755,8 @@ export function popModal(grab, timestamp) {
if (record.prevFocus) if (record.prevFocus)
record.prevFocus.disconnect(record.prevFocusDestroyId); record.prevFocus.disconnect(record.prevFocusDestroyId);
actionMode = record.actionMode; actionMode = record.actionMode;
global.stage.set_key_focus(record.prevFocus); if (global.stage.key_focus === record.actor)
global.stage.set_key_focus(record.prevFocus);
} else { } else {
// If we have: // If we have:
// global.stage.set_focus(a); // global.stage.set_focus(a);