prevent off-screen transients (fixes #11)

This commit is contained in:
Peter Fajdiga
2023-08-15 21:44:42 +02:00
parent b447eacdfd
commit 5e9db7d2cd
3 changed files with 26 additions and 0 deletions

View File

@@ -127,6 +127,7 @@ class ScrollView {
// TODO (optimization): only arrange visible windows
this.updateArea();
this.grid.arrange(this.tilingArea.x - this.scrollX);
this.world.ensureFocusedTransientsVisible(); // TODO: refactor - call from elsewhere
}
public onGridWidthChanged() {

View File

@@ -119,6 +119,25 @@ class ClientWrapper {
this.transients.splice(i, 1);
}
public ensureTransientsVisible(screenSize: QRect) {
for (const transient of this.transients) {
if (transient.stateManager.getState() instanceof ClientStateFloating) {
transient.ensureVisible(screenSize);
transient.ensureTransientsVisible(screenSize);
}
}
}
public ensureVisible(screenSize: QRect) {
const frame = this.kwinClient.frameGeometry;
if (frame.left < 0) {
frame.x = 0;
} else if (frame.right > screenSize.width) {
frame.x = screenSize.width - frame.width;
}
}
destroy(passFocus: boolean) {
this.stateManager.destroy(passFocus);
this.signalManager.destroy();

View File

@@ -113,6 +113,12 @@ class World {
return transientFor;
}
public ensureFocusedTransientsVisible() {
this.doIfTiledFocused(true, (window, column, grid) => {
window.client.ensureTransientsVisible(grid.container.clientArea);
});
}
minimizeClient(kwinClient: AbstractClient) {
const client = this.clientMap.get(kwinClient);
if (client === undefined) {