World: extract function createScroller

This commit is contained in:
Peter Fajdiga
2024-04-20 15:30:05 +02:00
parent 4556198b2e
commit 3ba66f1c89

View File

@@ -45,10 +45,7 @@ class World {
marginBottom: config.gapsOuterBottom,
marginLeft: config.gapsOuterLeft,
marginRight: config.gapsOuterRight,
scroller: config.scrollingLazy ? new LazyScroller() :
config.scrollingCentered ? new CenteredScroller() :
config.scrollingGrouped ? new GroupedScroller() :
console.assert(false),
scroller: World.createScroller(config),
clamper: config.scrollingLazy ? new EdgeClamper() : new CenterClamper(),
},
layoutConfig,
@@ -60,6 +57,19 @@ class World {
this.update();
}
private static createScroller(config: Config) {
if (config.scrollingLazy) {
return new LazyScroller();
} else if (config.scrollingCentered) {
return new CenteredScroller();
} else if (config.scrollingGrouped) {
return new GroupedScroller();
} else {
log("No scrolling mode selected, using default");
return new LazyScroller();
}
}
private addExistingClients() {
const kwinClients = Workspace.windows;
for (let i = 0; i < kwinClients.length; i++) {