summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts57
-rw-r--r--gui/src/main/window-controller.ts20
2 files changed, 42 insertions, 35 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts
index 684956a92c..3a7a6f1073 100644
--- a/gui/src/main/index.ts
+++ b/gui/src/main/index.ts
@@ -1938,34 +1938,43 @@ class ApplicationMain {
}
private installTrayClickHandlers() {
- if (this.guiSettings.unpinnedWindow) {
- if (process.platform === 'win32' || process.platform === 'darwin') {
- this.tray?.on('right-click', () =>
+ switch (process.platform) {
+ case 'win32':
+ if (this.guiSettings.unpinnedWindow) {
// This needs to be executed on click since if it is added to the tray icon it will be
// displayed on left click as well.
- this.tray?.popUpContextMenu(this.createTrayContextMenu()),
- );
- }
- this.tray?.on('click', () => this.windowController?.show());
- } else {
- this.tray?.on('click', (event) => {
- // The app shouldn't become visible if the user is reordering the tray icons on macOS. The
- // tray icon becomes draggable when holding the command key (meta).
- if (process.platform !== 'darwin' || !event.metaKey) {
- const isMacOsBigSur = process.platform === 'darwin' && parseInt(os.release(), 10) >= 20;
- if (isMacOsBigSur && !this.windowController?.isVisible()) {
- // This is a workaround for this Electron issue, when it's resolved
- // `this.windowController?.toggle()` should do the trick on all platforms:
- // https://github.com/electron/electron/issues/28776
- const contextMenu = Menu.buildFromTemplate([]);
- contextMenu.on('menu-will-show', () => this.windowController?.show());
- this.tray?.popUpContextMenu(contextMenu);
+ this.tray?.on('right-click', () =>
+ this.tray?.popUpContextMenu(this.createTrayContextMenu()),
+ );
+ this.tray?.on('click', () => this.windowController?.show());
+ } else {
+ this.tray?.on('right-click', () => this.windowController?.hide());
+ this.tray?.on('click', () => this.windowController?.toggle());
+ }
+ break;
+ case 'darwin':
+ this.tray?.on('right-click', () => this.windowController?.hide());
+ this.tray?.on('click', (event) => {
+ if (event.metaKey) {
+ setImmediate(() => this.windowController?.updatePosition());
} else {
- this.windowController?.toggle();
+ const isBigSurOrNewer = parseInt(os.release(), 10) >= 20;
+ if (isBigSurOrNewer && !this.windowController?.isVisible()) {
+ // This is a workaround for this Electron issue, when it's resolved
+ // `this.windowController?.toggle()` should do the trick on all platforms:
+ // https://github.com/electron/electron/issues/28776
+ const contextMenu = Menu.buildFromTemplate([]);
+ contextMenu.on('menu-will-show', () => this.windowController?.show());
+ this.tray?.popUpContextMenu(contextMenu);
+ } else {
+ this.windowController?.toggle();
+ }
}
- }
- });
- this.tray?.on('right-click', () => this.windowController?.hide());
+ });
+ break;
+ case 'linux':
+ this.tray?.on('click', () => this.windowController?.show());
+ break;
}
}
diff --git a/gui/src/main/window-controller.ts b/gui/src/main/window-controller.ts
index 81b5e5d130..b01fa90734 100644
--- a/gui/src/main/window-controller.ts
+++ b/gui/src/main/window-controller.ts
@@ -170,7 +170,6 @@ export default class WindowController {
: new AttachedToTrayWindowPositioning(this.tray);
this.updatePosition();
- this.notifyUpdateWindowShape();
}
public show(whenReady = true) {
@@ -201,6 +200,15 @@ export default class WindowController {
this.windowPositioningScheduler.cancel();
}
+ public updatePosition() {
+ if (this.window) {
+ const { x, y } = this.windowPositioning.getPosition(this.window);
+ this.window.setPosition(x, y, false);
+ }
+
+ this.notifyUpdateWindowShape();
+ }
+
private showImmediately() {
const window = this.window;
@@ -216,23 +224,14 @@ export default class WindowController {
window?.focus();
this.updatePosition();
- this.notifyUpdateWindowShape();
} else {
this.updatePosition();
- this.notifyUpdateWindowShape();
window?.show();
window?.focus();
}
}
- private updatePosition() {
- if (this.window) {
- const { x, y } = this.windowPositioning.getPosition(this.window);
- this.window.setPosition(x, y, false);
- }
- }
-
private notifyUpdateWindowShape() {
if (this.window) {
const shapeParameters = this.windowPositioning.getWindowShapeParameters(this.window);
@@ -272,7 +271,6 @@ export default class WindowController {
private onWorkAreaSizeChange() {
this.updatePosition();
- this.notifyUpdateWindowShape();
}
private forceResizeWindow() {