Skip to content

Commit

Permalink
More minimize/maximize and app closing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Jun 24, 2023
1 parent c195d8b commit af7026b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions main/src/Window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@ class TabPlumbing implements Disposable {
const window = this.#windowManager.getWindowForTab(tab);
window.handleTabMouseButtonPress(tab, ev);
});

tab.getContents().addEventListener(WidgetEventTypes.FocusIn, (nativeEvent) => {
// TODO: remove?
});
}

setIsCurrent(isCurrent: boolean): void {
Expand Down Expand Up @@ -656,6 +652,7 @@ export class Window implements Disposable {

#windowOpenState = WindowOpenState.Closed;
dockContainer: CFloatingDockContainer = null;
#initialEmptyState = true;

#windowHandle: QWindow = null;
#screen: QScreen = null;
Expand Down Expand Up @@ -725,14 +722,7 @@ export class Window implements Disposable {

this.#dockContainerEventHolder.addEventListener(WidgetEventTypes.Close, () => {
this.#windowOpenState = WindowOpenState.Closed;
doLater(() => {
if ( ! this.#windowManager.getAllWindows().includes(this)) {
return; // Window has already been disposed.
}
if (this.#getTabs().length === 0) {
this.#windowManager.disposeWindow(this);
}
});
this.#checkForEmptyWindowLater.trigger();
});

this.#dockContainerEventHolder.addEventListener(WidgetEventTypes.Hide, () => {
Expand Down Expand Up @@ -786,8 +776,14 @@ export class Window implements Disposable {
}

#checkForEmptyWindow(): void {
if ( ! this.#windowManager.getAllWindows().includes(this)) {
return; // Window has already been disposed.
}
if (this.#initialEmptyState) {
return;
}
if (this.#getTabs().length === 0) {
this.dockContainer.close();
this.#windowManager.disposeWindow(this);
}
}

Expand Down Expand Up @@ -1289,6 +1285,7 @@ export class Window implements Disposable {
if (this.#windowManager.hasTab(tab)) {
return;
}
this.#initialEmptyState = false;

const tabPlumbing = this.#windowManager.prepareTab(tab);
tab.setParent(this);
Expand Down Expand Up @@ -1383,6 +1380,8 @@ export class Window implements Disposable {
}

tabPlumbing.dispose();

this.#checkForEmptyWindowLater.trigger();
}

focusTab(tab: Tab): void {
Expand Down

0 comments on commit af7026b

Please sign in to comment.