diff --git a/src/extern/kwin.d.ts b/src/extern/kwin.d.ts index 8638303..688b8c3 100644 --- a/src/extern/kwin.d.ts +++ b/src/extern/kwin.d.ts @@ -21,7 +21,7 @@ declare const Workspace: { readonly currentActivityChanged: QSignal<[]>; readonly virtualScreenSizeChanged: QSignal<[]>; - clientArea(option: ClientAreaOption, output: Output, desktopNumber: number); + clientArea(option: ClientAreaOption, output: Output, kwinDesktop: KwinDesktop); }; const enum ClientAreaOption { diff --git a/src/layout/Desktop.ts b/src/layout/Desktop.ts index 66c4122..1f1113b 100644 --- a/src/layout/Desktop.ts +++ b/src/layout/Desktop.ts @@ -38,7 +38,7 @@ class Desktop { } private static getClientArea(kwinDesktop: KwinDesktop) { - return Workspace.clientArea(ClientAreaOption.PlacementArea, Workspace.activeScreen, 0); // TODO: pass desktop + return Workspace.clientArea(ClientAreaOption.PlacementArea, Workspace.activeScreen, kwinDesktop); } private static getTilingArea(clientArea: QmlRect, kwinDesktop: KwinDesktop, pinManager: PinManager, config: Desktop.Config) { diff --git a/src/world/Clients.ts b/src/world/Clients.ts index 636019b..9904c78 100644 --- a/src/world/Clients.ts +++ b/src/world/Clients.ts @@ -19,13 +19,28 @@ namespace Clients { } } + export function getKwinDesktopApprox(kwinClient: KwinClient) { + switch (kwinClient.desktops.length) { + case 0: // TODO: is empty = all desktops? + return Workspace.currentDesktop; + case 1: + return kwinClient.desktops[0]; + default: + if (kwinClient.desktops.includes(Workspace.currentDesktop)) { + return Workspace.currentDesktop; + } else { + return kwinClient.desktops[0]; + } + } + } + export function isMaximizedGeometry(kwinClient: KwinClient) { - const maximizeArea = Workspace.clientArea(ClientAreaOption.MaximizeArea, kwinClient.output, 0); // TODO: pass desktop + const maximizeArea = Workspace.clientArea(ClientAreaOption.MaximizeArea, kwinClient.output, getKwinDesktopApprox(kwinClient)); return kwinClient.frameGeometry === maximizeArea; } export function isFullScreenGeometry(kwinClient: KwinClient) { - const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.output, 0); // TODO: pass desktop + const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.output, getKwinDesktopApprox(kwinClient)); return kwinClient.frameGeometry === fullScreenArea; } diff --git a/src/world/clientState/Floating.ts b/src/world/clientState/Floating.ts index 631824c..3408ee6 100644 --- a/src/world/clientState/Floating.ts +++ b/src/world/clientState/Floating.ts @@ -24,7 +24,11 @@ namespace ClientState { } private static limitHeight(client: ClientWrapper) { - const placementArea = Workspace.clientArea(ClientAreaOption.PlacementArea, client.kwinClient.output, 0); // TODO: pass desktop + const placementArea = Workspace.clientArea( + ClientAreaOption.PlacementArea, + client.kwinClient.output, + Clients.getKwinDesktopApprox(client.kwinClient), + ); const clientRect = client.kwinClient.frameGeometry; const width = client.preferredWidth; client.place(