From c8f022d66f4f5e5d7273d2043dbabff263886c5f Mon Sep 17 00:00:00 2001 From: Peter Fajdiga Date: Sat, 2 Mar 2024 21:10:30 +0100 Subject: [PATCH] kwin.d.ts: rename `Workspace` --- src/Actions.ts | 2 +- src/extern/kwin.d.ts | 2 +- src/layout/Desktop.ts | 2 +- src/workspace.ts | 24 ++++++++++++------------ src/world/ClientWrapper.ts | 6 +++--- src/world/Clients.ts | 8 ++++---- src/world/DesktopManager.ts | 6 +++--- src/world/World.ts | 8 ++++---- src/world/clientState/Floating.ts | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Actions.ts b/src/Actions.ts index 53f2bdc..4da6d4f 100644 --- a/src/Actions.ts +++ b/src/Actions.ts @@ -128,7 +128,7 @@ namespace Actions { }, windowToggleFloating: () => { - const kwinClient = workspace.activeClient; + const kwinClient = Workspace.activeClient; world.do((clientManager, desktopManager) => { clientManager.toggleFloatingClient(kwinClient); }); diff --git a/src/extern/kwin.d.ts b/src/extern/kwin.d.ts index ef450a2..fdb1add 100644 --- a/src/extern/kwin.d.ts +++ b/src/extern/kwin.d.ts @@ -3,7 +3,7 @@ declare const KWin: { registerShortcut(name: string, description: string, keySequence: string, callback: () => void): void; }; -declare const workspace: { +declare const Workspace: { readonly desktops: number; readonly currentDesktop: number; readonly currentActivity: string; diff --git a/src/layout/Desktop.ts b/src/layout/Desktop.ts index cfd9740..787d8bf 100644 --- a/src/layout/Desktop.ts +++ b/src/layout/Desktop.ts @@ -38,7 +38,7 @@ class Desktop { } private static getClientArea(desktopNumber: number) { - return workspace.clientArea(ClientAreaOption.PlacementArea, 0, desktopNumber); + return Workspace.clientArea(ClientAreaOption.PlacementArea, 0, desktopNumber); } private static getTilingArea(clientArea: QmlRect, desktopNumber: number, pinManager: PinManager, config: Desktop.Config) { diff --git a/src/workspace.ts b/src/workspace.ts index f175173..a9cfcd0 100644 --- a/src/workspace.ts +++ b/src/workspace.ts @@ -1,14 +1,14 @@ function initWorkspaceSignalHandlers(world: World) { const manager = new SignalManager(); - manager.connect(workspace.clientAdded, (kwinClient: KwinClient) => { + manager.connect(Workspace.clientAdded, (kwinClient: KwinClient) => { if (Clients.canTileEver(kwinClient)) { // never open new tileable clients on all desktops or activities if (kwinClient.desktop <= 0) { - kwinClient.desktop = workspace.currentDesktop; + kwinClient.desktop = Workspace.currentDesktop; } if (kwinClient.activities.length !== 1) { - kwinClient.activities = [workspace.currentActivity]; + kwinClient.activities = [Workspace.currentActivity]; } } world.do((clientManager, desktopManager) => { @@ -16,25 +16,25 @@ function initWorkspaceSignalHandlers(world: World) { }); }); - manager.connect(workspace.clientRemoved, (kwinClient: KwinClient) => { + manager.connect(Workspace.clientRemoved, (kwinClient: KwinClient) => { world.do((clientManager, desktopManager) => { clientManager.removeClient(kwinClient, true); }); }); - manager.connect(workspace.clientMinimized, (kwinClient: KwinClient) => { + manager.connect(Workspace.clientMinimized, (kwinClient: KwinClient) => { world.do((clientManager, desktopManager) => { clientManager.minimizeClient(kwinClient); }); }); - manager.connect(workspace.clientUnminimized, (kwinClient: KwinClient) => { + manager.connect(Workspace.clientUnminimized, (kwinClient: KwinClient) => { world.do((clientManager, desktopManager) => { clientManager.unminimizeClient(kwinClient); }); }); - manager.connect(workspace.clientMaximizeSet, (kwinClient: KwinClient, horizontally: boolean, vertically: boolean) => { + manager.connect(Workspace.clientMaximizeSet, (kwinClient: KwinClient, horizontally: boolean, vertically: boolean) => { if ((horizontally || vertically) && kwinClient.tile !== null) { kwinClient.tile = null; } @@ -43,7 +43,7 @@ function initWorkspaceSignalHandlers(world: World) { }); }); - manager.connect(workspace.clientActivated, (kwinClient: KwinClient) => { + manager.connect(Workspace.clientActivated, (kwinClient: KwinClient) => { if (kwinClient === null) { return; } @@ -52,19 +52,19 @@ function initWorkspaceSignalHandlers(world: World) { }); }); - manager.connect(workspace.currentDesktopChanged, () => { + manager.connect(Workspace.currentDesktopChanged, () => { world.do(() => {}); // re-arrange desktop }); - manager.connect(workspace.currentActivityChanged, () => { + manager.connect(Workspace.currentActivityChanged, () => { world.do(() => {}); // re-arrange desktop }); - manager.connect(workspace.numberDesktopsChanged, () => { + manager.connect(Workspace.numberDesktopsChanged, () => { world.updateDesktops(); }); - manager.connect(workspace.virtualScreenSizeChanged, () => { + manager.connect(Workspace.virtualScreenSizeChanged, () => { world.onScreenResized(); }); diff --git a/src/world/ClientWrapper.ts b/src/world/ClientWrapper.ts index 9c2d4c6..d37bbf9 100644 --- a/src/world/ClientWrapper.ts +++ b/src/world/ClientWrapper.ts @@ -69,11 +69,11 @@ class ClientWrapper { } public focus() { - workspace.activeClient = this.kwinClient; + Workspace.activeClient = this.kwinClient; } public isFocused() { - return workspace.activeClient === this.kwinClient; + return Workspace.activeClient === this.kwinClient; } public setMaximize(horizontally: boolean, vertically: boolean) { @@ -124,7 +124,7 @@ class ClientWrapper { } public ensureVisible(screenSize: QmlRect) { - if (this.kwinClient.desktop !== workspace.currentDesktop) { + if (this.kwinClient.desktop !== Workspace.currentDesktop) { return; } const frame = this.kwinClient.frameGeometry; diff --git a/src/world/Clients.ts b/src/world/Clients.ts index e7888e1..d2dec4c 100644 --- a/src/world/Clients.ts +++ b/src/world/Clients.ts @@ -12,20 +12,20 @@ namespace Clients { kwinClient.minimized = false; } if (kwinClient.desktop <= 0) { - kwinClient.desktop = workspace.currentDesktop; + kwinClient.desktop = Workspace.currentDesktop; } if (kwinClient.activities.length !== 1) { - kwinClient.activities = [workspace.currentActivity]; + kwinClient.activities = [Workspace.currentActivity]; } } export function isMaximizedGeometry(kwinClient: KwinClient) { - const maximizeArea = workspace.clientArea(ClientAreaOption.MaximizeArea, kwinClient.screen, kwinClient.desktop); + const maximizeArea = Workspace.clientArea(ClientAreaOption.MaximizeArea, kwinClient.screen, kwinClient.desktop); return kwinClient.frameGeometry === maximizeArea; } export function isFullScreenGeometry(kwinClient: KwinClient) { - const fullScreenArea = workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.screen, kwinClient.desktop); + const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.screen, kwinClient.desktop); return kwinClient.frameGeometry === fullScreenArea; } diff --git a/src/world/DesktopManager.ts b/src/world/DesktopManager.ts index dd4f3c2..59fd226 100644 --- a/src/world/DesktopManager.ts +++ b/src/world/DesktopManager.ts @@ -16,7 +16,7 @@ class DesktopManager { } public update() { - this.setNVirtualDesktops(workspace.desktops); + this.setNVirtualDesktops(Workspace.desktops); } public getDesktop(activity: string, desktopNumber: number) { @@ -31,11 +31,11 @@ class DesktopManager { } public getCurrentDesktop() { - return this.getDesktop(workspace.currentActivity, workspace.currentDesktop); + return this.getDesktop(Workspace.currentActivity, Workspace.currentDesktop); } public getDesktopInCurrentActivity(desktopNumber: number) { - return this.getDesktop(workspace.currentActivity, desktopNumber); + return this.getDesktop(Workspace.currentActivity, desktopNumber); } public getDesktopForClient(kwinClient: KwinClient) { diff --git a/src/world/World.ts b/src/world/World.ts index 7bdaf43..2a8ca37 100644 --- a/src/world/World.ts +++ b/src/world/World.ts @@ -11,7 +11,7 @@ class World { this.workspaceSignalManager = initWorkspaceSignalHandlers(this); this.screenResizedDelayer = new Delayer(1000, () => { - // this delay ensures that docks are taken into account by `workspace.clientArea` + // this delay ensures that docks are taken into account by `Workspace.clientArea` const desktopManager = this.desktopManager; // workaround for bug in Qt5's JS engine for (const desktop of desktopManager.desktops()) { desktop.onLayoutChanged(); @@ -47,7 +47,7 @@ class World { clamper: config.scrollingLazy ? new EdgeClamper() : new CenterClamper(), }, layoutConfig, - workspace.currentActivity, + Workspace.currentActivity, ); this.clientManager = new ClientManager(config, this, this.desktopManager, this.pinManager); this.addExistingClients(); @@ -55,7 +55,7 @@ class World { } private addExistingClients() { - const kwinClients = workspace.clientList(); + const kwinClients = Workspace.clientList(); for (let i = 0; i < kwinClients.length; i++) { const kwinClient = kwinClients[i]; this.clientManager.addClient(kwinClient); @@ -94,7 +94,7 @@ class World { followTransient: boolean, f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void, ) { - this.doIfTiled(workspace.activeClient, followTransient, f); + this.doIfTiled(Workspace.activeClient, followTransient, f); } public destroy() { diff --git a/src/world/clientState/Floating.ts b/src/world/clientState/Floating.ts index 9024a18..cb654b9 100644 --- a/src/world/clientState/Floating.ts +++ b/src/world/clientState/Floating.ts @@ -24,7 +24,7 @@ namespace ClientState { } private static limitHeight(client: ClientWrapper) { - const placementArea = workspace.clientArea(ClientAreaOption.PlacementArea, client.kwinClient.screen, client.kwinClient.desktop); + const placementArea = Workspace.clientArea(ClientAreaOption.PlacementArea, client.kwinClient.screen, client.kwinClient.desktop); const clientRect = client.kwinClient.frameGeometry; const width = client.preferredWidth; client.place(