Fix switchWorkspace when triggered from random focus

This commit is contained in:
Tor Hedin Brønner
2018-04-22 15:01:57 +02:00
parent b0bc53833b
commit cfcbdb01d3
2 changed files with 30 additions and 17 deletions
+26 -16
View File
@@ -304,13 +304,20 @@ function preview_navigate(display, screen, meta_window, binding) {
tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask())
}
function switchWorkspace(to, callback) {
function switchWorkspace(to, from, callback) {
TopBar.updateWorkspaceIndicator(to.index());
let xDest = 0, yDest = global.screen_height;
let toSpace = Tiling.spaces.spaceOf(to);
if (from) {
Tiling.spaces.spaceOf(from).forEach(w => {
w.get_compositor_private().hide();
w.clone.show();
});
}
Tweener.addTween(toSpace.cloneContainer,
{ x: 0,
y: 0,
@@ -320,24 +327,27 @@ function switchWorkspace(to, callback) {
transition: 'easeInOutQuad',
onComplete: () => {
toSpace.cloneContainer.raise_top();
_
callback && callback();
}
});
let last = toSpace.cloneContainer.get_next_sibling();
if (last === null)
return;
let cloneParent = last.get_parent();
cloneParent.set_child_below_sibling(
toSpace.cloneContainer,
last);
let next = toSpace.cloneContainer.get_next_sibling();
Tweener.addTween(last,
{ x: xDest,
y: yDest,
scale_x: scale,
scale_y: scale,
time: 0.25,
transition: 'easeInOutQuad',
});
while (next !== null) {
Tweener.addTween(next,
{ x: xDest,
y: yDest,
scale_x: scale,
scale_y: scale,
time: 0.25,
transition: 'easeInOutQuad',
onComplete() {
this.set_position(0, global.screen_height*0.1);
},
onCompleteScope: next
});
next = next.get_next_sibling();
}
}
+4 -1
View File
@@ -450,7 +450,10 @@ function enable() {
global.screen.connect(
'workspace-switched',
(screen, from, to) => {
Navigator.switchWorkspace(global.screen.get_workspace_by_index(to));
Navigator.switchWorkspace(
global.screen.get_workspace_by_index(to),
global.screen.get_workspace_by_index(from)
);
}),
// Reset primary when monitors change