fix: 🐛 prevent KWin freeze in various scenarious

This removes some hacks and functionality. Those could be added later.
This commit is contained in:
Mikhail Zolotukhin 2021-10-21 23:46:57 +03:00
parent caf7d080d9
commit 34d24a4cb6
2 changed files with 18 additions and 47 deletions

View File

@ -205,12 +205,6 @@ export class ControllerImpl implements Controller {
public onCurrentSurfaceChanged(): void { public onCurrentSurfaceChanged(): void {
this.log.log(["onCurrentSurfaceChanged", { srf: this.currentSurface }]); this.log.log(["onCurrentSurfaceChanged", { srf: this.currentSurface }]);
this.engine.arrange(); this.engine.arrange();
/* HACK: minimize others and change geometry with Monocle Layout and
* config.monocleMinimizeRest
*/
if (this.currentWindow) {
this.onWindowFocused(this.currentWindow);
}
} }
public onWindowAdded(window: EngineWindow): void { public onWindowAdded(window: EngineWindow): void {
@ -236,26 +230,23 @@ export class ControllerImpl implements Controller {
} }
public onWindowRemoved(window: EngineWindow): void { public onWindowRemoved(window: EngineWindow): void {
this.log.log(["onWindowRemoved", { window }]); this.log.log(`[Controller#onWindowRemoved] Window removed: ${window}`);
this.engine.unmanage(window); this.engine.unmanage(window);
this.engine.arrange();
// Switch to next window if monocle with config.monocleMinimizeRest if (this.engine.isLayoutMonocleAndMinimizeRest()) {
if ( // Switch to the next window if needed
!window.isDialog && if (!this.currentWindow) {
!this.currentWindow && this.log.log(
this.engine.isLayoutMonocleAndMinimizeRest() `[Controller#onWindowRemoved] Switching to the minimized window`
) { );
this.engine.focusOrder(1, true); 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);
} }
} }
this.engine.arrange();
}
public onWindowMoveStart(_window: EngineWindow): void { public onWindowMoveStart(_window: EngineWindow): void {
/* do nothing */ /* do nothing */
} }
@ -353,32 +344,12 @@ export class ControllerImpl implements Controller {
} }
} }
public onWindowFocused(window: EngineWindow): void { public onWindowFocused(win: EngineWindow): void {
try { win.timestamp = new Date().getTime();
window.timestamp = new Date().getTime();
this.currentWindow = window;
// Minimize other windows if Monocle and config.monocleMinimizeRest
if (
this.engine.isLayoutMonocleAndMinimizeRest() &&
this.engine.windows
.visibleTiledWindowsOn(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.tileableWindowsOn(window.surface),
window.surface.workingArea
);
this.engine.minimizeOthers(window); // Minimize other windows if Monocle and config.monocleMinimizeRest
} if (this.engine.isLayoutMonocleAndMinimizeRest()) {
} catch { this.engine.minimizeOthers(win);
return;
} }
} }

View File

@ -150,7 +150,6 @@ export interface Engine {
/** /**
* Minimize all windows on the surface except the given window. * Minimize all windows on the surface except the given window.
* Used mainly in Monocle mode with config.monocleMinimizeRest
*/ */
minimizeOthers(window: EngineWindow): void; minimizeOthers(window: EngineWindow): void;
@ -409,7 +408,8 @@ export class EngineImpl implements Engine {
this.windows.remove(window); this.windows.remove(window);
} }
/** Focus next or previous window /**
* Focus next or previous window
* @param step direction to step in (1 for forward, -1 for back) * @param step direction to step in (1 for forward, -1 for back)
* @param includeHidden whether to switch to or skip minimized windows * @param includeHidden whether to switch to or skip minimized windows
*/ */