Skip to content

Commit 5da320c

Browse files
committed
gwl: Make sure to scroll to the focused app group on workspace switched
1 parent 4bb4ad2 commit 5da320c

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

files/usr/share/cinnamon/applets/[email protected]/workspace.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ class Workspace {
1515
this.state.connect({
1616
orientation: (state) => {
1717
this.on_orientation_changed(state.orientation);
18+
},
19+
currentWs: (state) => {
20+
if (this.metaWorkspace && state.currentWs === this.metaWorkspace.index()) {
21+
this.scrollToFocusedApp();
22+
}
1823
}
1924
});
2025
this.workspaceState = createStore({
@@ -283,6 +288,18 @@ class Workspace {
283288
if (index === -1) return;
284289

285290
const isHorizontal = this.state.isHorizontal;
291+
292+
let containerSize, boxSize;
293+
if (isHorizontal) {
294+
containerSize = this.container.width > 0 ? this.container.width : this.container.get_preferred_width(-1)[1];
295+
boxSize = this.scrollBox.width;
296+
} else {
297+
containerSize = this.container.height > 0 ? this.container.height : this.container.get_preferred_height(-1)[1];
298+
boxSize = this.scrollBox.height;
299+
}
300+
301+
if (containerSize <= boxSize) return;
302+
286303
let itemPos = 0;
287304
let itemSize = 0;
288305

@@ -296,15 +313,6 @@ class Workspace {
296313
itemPos += itemSize;
297314
}
298315

299-
const boxSize = isHorizontal ? this.scrollBox.width : this.scrollBox.height;
300-
301-
let containerSize;
302-
if (isHorizontal) {
303-
containerSize = this.container.width > 0 ? this.container.width : this.container.get_preferred_width(-1)[1];
304-
} else {
305-
containerSize = this.container.height > 0 ? this.container.height : this.container.get_preferred_height(-1)[1];
306-
}
307-
308316
// Subtract half size to get center.
309317
const targetCenter = itemPos - (itemSize / 2);
310318
// We want targetCenter to be at boxSize / 2

0 commit comments

Comments
 (0)