prevent setting incorrect frameGeometry to windows that went from Karousel-tiled to Kwin-quick-tiled

This commit is contained in:
Peter Fajdiga
2023-09-02 10:54:47 +02:00
parent 681ae38d85
commit 08135a4ad4
4 changed files with 17 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ class ClientManager {
console.assert(!this.hasClient(kwinClient));
const client = new ClientWrapper(
kwinClient,
new ClientState.Floating(),
new ClientState.Floating(null),
this.findTransientFor(kwinClient),
this.windowRuleEnforcer.initClientSignalManager(this.world, kwinClient),
);
@@ -101,7 +101,7 @@ class ClientManager {
return;
}
if (client.stateManager.getState() instanceof ClientState.Tiled) {
client.stateManager.setState(() => new ClientState.Floating(), false);
client.stateManager.setState(() => new ClientState.Floating(client), false);
}
}
@@ -117,7 +117,7 @@ class ClientManager {
const grid = this.desktopManager.getDesktopForClient(client.kwinClient).grid;
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
} else if (clientState instanceof ClientState.Tiled) {
client.stateManager.setState(() => new ClientState.Floating(), false);
client.stateManager.setState(() => new ClientState.Floating(client), false);
}
}

View File

@@ -99,21 +99,25 @@ class ClientWrapper {
this.setMaximize(false, false);
}
public prepareForFloating(screenSize: QRect) {
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(
clamp(clientRect.x, screenSize.left, screenSize.right - width),
clientRect.x,
clientRect.y,
width,
Math.min(clientRect.height, Math.round(screenSize.height / 2)),
Math.min(clientRect.height, Math.round(placementArea.height / 2)),
);
}

View File

@@ -1,5 +1,11 @@
namespace ClientState {
export class Floating implements State {
constructor(client: ClientWrapper | null) {
if (client !== null && client.kwinClient.tile === null) {
client.prepareForFloating();
}
}
public destroy(passFocus: boolean) {}
}
}

View File

@@ -21,7 +21,7 @@ namespace ClientState {
const client = window.client;
window.destroy(passFocus);
client.prepareForFloating(grid.desktop.clientArea);
client.restoreAfterTiling(grid.desktop.clientArea);
}
private static initSignalManager(world: World, window: Window) {