diff --git a/src/world/ClientWrapper.ts b/src/world/ClientWrapper.ts index 4925bf9..abae955 100644 --- a/src/world/ClientWrapper.ts +++ b/src/world/ClientWrapper.ts @@ -90,37 +90,6 @@ class ClientWrapper { return this.manipulatingGeometry.isDoing(); } - public prepareForTiling() { - this.kwinClient.keepBelow = true; - this.setFullScreen(false); - if (this.kwinClient.tile !== null) { - this.setMaximize(false, true); // disable quick tile mode - } - this.setMaximize(false, false); - } - - public restoreAfterTiling(screenSize: QRect) { - this.kwinClient.keepBelow = false; - this.setShade(false); - this.setFullScreen(false); - if (this.kwinClient.tile === null) { - this.setMaximize(false, false); - } - this.ensureVisible(screenSize); - } - - public prepareForFloating() { - const placementArea = workspace.clientArea(ClientAreaOption.PlacementArea, this.kwinClient.screen, this.kwinClient.desktop); - const clientRect = this.kwinClient.frameGeometry; - const width = this.preferredWidth; - this.place( - clientRect.x, - clientRect.y, - width, - Math.min(clientRect.height, Math.round(placementArea.height / 2)), - ); - } - private addTransient(transient: ClientWrapper) { this.transients.push(transient); } diff --git a/src/world/clientState/Floating.ts b/src/world/clientState/Floating.ts index 08132ef..366e8a0 100644 --- a/src/world/clientState/Floating.ts +++ b/src/world/clientState/Floating.ts @@ -2,10 +2,22 @@ namespace ClientState { export class Floating implements State { constructor(client: ClientWrapper | null) { if (client !== null && client.kwinClient.tile === null) { - client.prepareForFloating(); + Floating.prepareClientForFloating(client); } } public destroy(passFocus: boolean) {} + + private static prepareClientForFloating(client: ClientWrapper) { + const placementArea = workspace.clientArea(ClientAreaOption.PlacementArea, client.kwinClient.screen, client.kwinClient.desktop); + const clientRect = client.kwinClient.frameGeometry; + const width = client.preferredWidth; + client.place( + clientRect.x, + clientRect.y, + width, + Math.min(clientRect.height, Math.round(placementArea.height / 2)), + ); + } } } diff --git a/src/world/clientState/Tiled.ts b/src/world/clientState/Tiled.ts index eee35e5..48cfa30 100644 --- a/src/world/clientState/Tiled.ts +++ b/src/world/clientState/Tiled.ts @@ -4,7 +4,7 @@ namespace ClientState { private readonly signalManager: SignalManager; constructor(world: World, client: ClientWrapper, grid: Grid) { - client.prepareForTiling(); + Tiled.prepareClientForTiling(client); const column = new Column(grid, grid.getLastFocusedColumn() ?? grid.getLastColumn()); const window = new Window(client, column); @@ -21,7 +21,7 @@ namespace ClientState { const client = window.client; window.destroy(passFocus); - client.restoreAfterTiling(grid.desktop.clientArea); + Tiled.restoreClientAfterTiling(client, grid.desktop.clientArea); } private static initSignalManager(world: World, window: Window) { @@ -121,5 +121,24 @@ namespace ClientState { const newColumn = new Column(newGrid, newGrid.getLastFocusedColumn() ?? newGrid.getLastColumn()); window.moveToColumn(newColumn); } + + private static prepareClientForTiling(client: ClientWrapper) { + client.kwinClient.keepBelow = true; + client.setFullScreen(false); + if (client.kwinClient.tile !== null) { + client.setMaximize(false, true); // disable quick tile mode + } + client.setMaximize(false, false); + } + + private static restoreClientAfterTiling(client: ClientWrapper, screenSize: QRect) { + client.kwinClient.keepBelow = false; + client.setShade(false); + client.setFullScreen(false); + if (client.kwinClient.tile === null) { + client.setMaximize(false, false); + } + client.ensureVisible(screenSize); + } } }