Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix: no crashes in closing transients -- might fix others too; ref #110
Browse files Browse the repository at this point in the history
…, #109
  • Loading branch information
bladedvox authored and Mikhail Zolotukhin committed Oct 18, 2021
1 parent 49ac131 commit 502f812
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
66 changes: 34 additions & 32 deletions src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,17 @@ export class TilingController implements Controller {
this.engine.arrange();

// Switch to next window if monocle with config.monocleMinimizeRest
try {
if (!this.currentWindow && this.engine.isLayoutMonocleAndMinimizeRest()) {
this.engine.focusOrder(1, true);
/* HACK: force window to maximize if it isn't already
* This is ultimately to trigger onWindowFocused() at the right time
*/
this.engine.focusOrder(1, true);
this.engine.focusOrder(-1, true);
}
} catch {
/* HACK for the HACK: transient modals cause an error with the above workaround,
* so if we catch it here and ignore it, all is well */
return;
if (
!window.window.isDialog &&
!this.currentWindow &&
this.engine.isLayoutMonocleAndMinimizeRest()
) {
this.engine.focusOrder(1, true);
/* HACK: force window to maximize if it isn't already
* This is ultimately to trigger onWindowFocused() at the right time
*/
this.engine.focusOrder(1, true);
this.engine.focusOrder(-1, true);
}
}

Expand Down Expand Up @@ -352,25 +350,29 @@ export class TilingController implements Controller {
}

public onWindowFocused(window: Window): void {
window.timestamp = new Date().getTime();
this.currentWindow = window;
// Minimize other windows if Monocle and config.monocleMinimizeRest
if (
this.engine.isLayoutMonocleAndMinimizeRest() &&
this.engine.windows.getVisibleTiles(window.surface).includes(window)
) {
/* If a window hasn't been focused in this layout yet, ensure its geometry
* gets maximized.
*/
this.engine
.currentLayoutOnCurrentSurface()
.apply(
this,
this.engine.windows.getAllTileables(window.surface),
window.surface.workingArea
);

this.engine.minimizeOthers(window);
try {
window.timestamp = new Date().getTime();
this.currentWindow = window;
// Minimize other windows if Monocle and config.monocleMinimizeRest
if (
this.engine.isLayoutMonocleAndMinimizeRest() &&
this.engine.windows.getVisibleTiles(window.surface).includes(window)
) {
/* If a window hasn't been focused in this layout yet, ensure its geometry
* gets maximized.
*/
this.engine
.currentLayoutOnCurrentSurface()
.apply(
this,
this.engine.windows.getAllTileables(window.surface),
window.surface.workingArea
);

this.engine.minimizeOthers(window);
}
} catch {
return;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/driver/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface DriverWindow {
readonly shouldFloat: boolean;
readonly screen: number;
readonly active: boolean;
readonly isDialog: boolean;
surface: DriverSurface;
minimized: boolean;
shaded: boolean;
Expand Down Expand Up @@ -261,4 +262,8 @@ export class KWinWindow implements DriverWindow {

return new Rect(geometry.x, geometry.y, width, height);
}

public get isDialog(): boolean {
return this.client.dialog;
}
}

0 comments on commit 502f812

Please sign in to comment.