main: Rename curFocus to prevFocus
This better describes what we're tracking here: the previous keyboard focus before pushing the modal. https://bugzilla.gnome.org/show_bug.cgi?id=690965
This commit is contained in:
parent
55aa0cf303
commit
2d9ddd4bc8
@ -547,19 +547,20 @@ function pushModal(actor, params) {
|
|||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
popModal(actor);
|
popModal(actor);
|
||||||
});
|
});
|
||||||
let curFocus = global.stage.get_key_focus();
|
|
||||||
let curFocusDestroyId;
|
let prevFocus = global.stage.get_key_focus();
|
||||||
if (curFocus != null) {
|
let prevFocusDestroyId;
|
||||||
curFocusDestroyId = curFocus.connect('destroy', function() {
|
if (prevFocus != null) {
|
||||||
|
prevFocusDestroyId = prevFocus.connect('destroy', function() {
|
||||||
let index = _findModal(actor);
|
let index = _findModal(actor);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
modalActorFocusStack[index].focus = null;
|
modalActorFocusStack[index].prevFocus = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
modalActorFocusStack.push({ actor: actor,
|
modalActorFocusStack.push({ actor: actor,
|
||||||
focus: curFocus,
|
|
||||||
destroyId: actorDestroyId,
|
destroyId: actorDestroyId,
|
||||||
focusDestroyId: curFocusDestroyId,
|
prevFocus: prevFocus,
|
||||||
|
prevFocusDestroyId: prevFocusDestroyId,
|
||||||
keybindingMode: keybindingMode });
|
keybindingMode: keybindingMode });
|
||||||
|
|
||||||
keybindingMode = params.keybindingMode;
|
keybindingMode = params.keybindingMode;
|
||||||
@ -600,18 +601,18 @@ function popModal(actor, timestamp) {
|
|||||||
record.actor.disconnect(record.destroyId);
|
record.actor.disconnect(record.destroyId);
|
||||||
|
|
||||||
if (focusIndex == modalActorFocusStack.length - 1) {
|
if (focusIndex == modalActorFocusStack.length - 1) {
|
||||||
if (record.focus)
|
if (record.prevFocus)
|
||||||
record.focus.disconnect(record.focusDestroyId);
|
record.prevFocus.disconnect(record.prevFocusDestroyId);
|
||||||
keybindingMode = record.keybindingMode;
|
keybindingMode = record.keybindingMode;
|
||||||
global.stage.set_key_focus(record.focus);
|
global.stage.set_key_focus(record.prevFocus);
|
||||||
} else {
|
} else {
|
||||||
let t = modalActorFocusStack[modalActorFocusStack.length - 1];
|
let t = modalActorFocusStack[modalActorFocusStack.length - 1];
|
||||||
if (t.focus)
|
if (t.prevFocus)
|
||||||
t.focus.disconnect(t.focusDestroyId);
|
t.prevFocus.disconnect(t.prevFocusDestroyId);
|
||||||
// Remove from the middle, shift the focus chain up
|
// Remove from the middle, shift the focus chain up
|
||||||
for (let i = modalActorFocusStack.length - 1; i > focusIndex; i--) {
|
for (let i = modalActorFocusStack.length - 1; i > focusIndex; i--) {
|
||||||
modalActorFocusStack[i].focus = modalActorFocusStack[i - 1].focus;
|
modalActorFocusStack[i].prevFocus = modalActorFocusStack[i - 1].prevFocus;
|
||||||
modalActorFocusStack[i].focusDestroyId = modalActorFocusStack[i - 1].focusDestroyId;
|
modalActorFocusStack[i].prevFocusDestroyId = modalActorFocusStack[i - 1].prevFocusDestroyId;
|
||||||
modalActorFocusStack[i].keybindingMode = modalActorFocusStack[i - 1].keybindingMode;
|
modalActorFocusStack[i].keybindingMode = modalActorFocusStack[i - 1].keybindingMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user