diff --git a/src/lib/Actions.ts b/src/lib/Actions.ts index abcd8f2..6a72b3a 100644 --- a/src/lib/Actions.ts +++ b/src/lib/Actions.ts @@ -252,6 +252,12 @@ namespace Actions { }); }; + case "screen-switch": return () => { + world.do((clientManager, desktopManager) => { + desktopManager.selectScreen(Workspace.activeScreen); + }); + }; + default: throw new Error("unknown action: " + name); } } diff --git a/src/lib/keyBindings/definition.ts b/src/lib/keyBindings/definition.ts index 2d1f69e..fe13657 100644 --- a/src/lib/keyBindings/definition.ts +++ b/src/lib/keyBindings/definition.ts @@ -146,6 +146,11 @@ const keyBindings: KeyBinding[] = [ description: "Scroll to end", defaultKeySequence: "Meta+Alt+End", }, + { + name: "screen-switch", + description: "Move Karousel grid to the current screen", + defaultKeySequence: "Meta+Ctrl+Return", + } ]; const numKeyBindings: NumKeyBinding[] = [ diff --git a/src/lib/layout/Desktop.ts b/src/lib/layout/Desktop.ts index fb4f4d1..9ed97fa 100644 --- a/src/lib/layout/Desktop.ts +++ b/src/lib/layout/Desktop.ts @@ -11,6 +11,7 @@ class Desktop { public readonly kwinDesktop: KwinDesktop, private readonly pinManager: PinManager, private readonly config: Desktop.Config, + private readonly getScreen: () => Output, layoutConfig: LayoutConfig, ) { this.scrollX = 0; @@ -18,12 +19,12 @@ class Desktop { this.dirtyScroll = true; this.dirtyPins = true; this.grid = new Grid(this, layoutConfig); - this.clientArea = Desktop.getClientArea(kwinDesktop); + this.clientArea = Desktop.getClientArea(this.getScreen(), kwinDesktop); this.tilingArea = Desktop.getTilingArea(this.clientArea, kwinDesktop, pinManager, config); } private updateArea() { - const newClientArea = Desktop.getClientArea(this.kwinDesktop); + const newClientArea = Desktop.getClientArea(this.getScreen(), this.kwinDesktop); if (newClientArea === this.clientArea && !this.dirtyPins) { return; } @@ -36,8 +37,8 @@ class Desktop { this.autoAdjustScroll(); } - private static getClientArea(kwinDesktop: KwinDesktop) { - return Workspace.clientArea(ClientAreaOption.PlacementArea, Workspace.activeScreen, kwinDesktop); + private static getClientArea(screen: Output, kwinDesktop: KwinDesktop) { + return Workspace.clientArea(ClientAreaOption.PlacementArea, screen, kwinDesktop); } private static getTilingArea(clientArea: QmlRect, kwinDesktop: KwinDesktop, pinManager: PinManager, config: Desktop.Config) { diff --git a/src/lib/world/DesktopManager.ts b/src/lib/world/DesktopManager.ts index c473a0c..4f46849 100644 --- a/src/lib/world/DesktopManager.ts +++ b/src/lib/world/DesktopManager.ts @@ -3,6 +3,7 @@ class DesktopManager { private readonly config: Desktop.Config; public readonly layoutConfig: LayoutConfig; private readonly desktops: Map; // key is activityId|desktopId + private selectedScreen: Output; private kwinActivities: Set; private kwinDesktops: Set; @@ -11,6 +12,7 @@ class DesktopManager { this.config = config; this.layoutConfig = layoutConfig; this.desktops = new Map(); + this.selectedScreen = Workspace.activeScreen; this.kwinActivities = new Set(Workspace.activities); this.kwinDesktops = new Set(Workspace.desktops); this.addDesktop(currentActivity, currentDesktop); @@ -43,7 +45,13 @@ class DesktopManager { private addDesktop(activity: string, kwinDesktop: KwinDesktop) { const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop); - const desktop = new Desktop(kwinDesktop, this.pinManager, this.config, this.layoutConfig); + const desktop = new Desktop( + kwinDesktop, + this.pinManager, + this.config, + () => this.selectedScreen, + this.layoutConfig, + ); this.desktops.set(desktopKey, desktop); return desktop; } @@ -72,6 +80,10 @@ class DesktopManager { this.kwinDesktops = newDesktops; } + public selectScreen(screen: Output) { + this.selectedScreen = screen; + } + private removeActivity(activity: string) { for (const kwinDesktop of this.kwinDesktops) { this.destroyDesktop(activity, kwinDesktop);