ClientWrapper: prevent moving transient windows on other desktops

This commit is contained in:
Peter Fajdiga
2023-08-19 14:07:13 +02:00
parent de3e78424a
commit c87ef982ae

View File

@@ -37,19 +37,21 @@ class ClientWrapper {
}); });
} }
private moveTransient(dx: number, dy: number) { private moveTransient(dx: number, dy: number, desktop: number) {
// TODO: prevent moving off the grid // TODO: prevent moving off the grid
if (this.stateManager.getState() instanceof ClientStateFloating) { if (this.stateManager.getState() instanceof ClientStateFloating) {
const frame = this.kwinClient.frameGeometry; if (this.kwinClient.desktop === desktop) {
this.kwinClient.frameGeometry = Qt.rect( const frame = this.kwinClient.frameGeometry;
frame.x + dx, this.kwinClient.frameGeometry = Qt.rect(
frame.y + dy, frame.x + dx,
frame.width, frame.y + dy,
frame.height, frame.width,
); frame.height,
);
}
for (const transient of this.transients) { for (const transient of this.transients) {
transient.moveTransient(dx, dy); transient.moveTransient(dx, dy, desktop);
} }
} }
} }
@@ -124,12 +126,14 @@ class ClientWrapper {
if (transient.stateManager.getState() instanceof ClientStateFloating) { if (transient.stateManager.getState() instanceof ClientStateFloating) {
transient.ensureVisible(screenSize); transient.ensureVisible(screenSize);
transient.ensureTransientsVisible(screenSize); transient.ensureTransientsVisible(screenSize);
} }
} }
} }
public ensureVisible(screenSize: QRect) { public ensureVisible(screenSize: QRect) {
if (this.kwinClient.desktop !== workspace.currentDesktop) {
return;
}
const frame = this.kwinClient.frameGeometry; const frame = this.kwinClient.frameGeometry;
if (frame.left < 0) { if (frame.left < 0) {
frame.x = 0; frame.x = 0;
@@ -164,7 +168,7 @@ class ClientWrapper {
const dx = Math.round(newCenterX - oldCenterX); const dx = Math.round(newCenterX - oldCenterX);
const dy = Math.round(newCenterY - oldCenterY); const dy = Math.round(newCenterY - oldCenterY);
for (const transient of client.transients) { for (const transient of client.transients) {
transient.moveTransient(dx, dy); transient.moveTransient(dx, dy, client.kwinClient.desktop);
} }
} }
}); });