Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix dock icon hiding on macOS occlusion

Manav Rathi4fa13285d508
diff --git a/desktop/src/main.ts b/desktop/src/main.ts
index 8adc89a897..7ac7797fce 100644
--- a/desktop/src/main.ts
+++ b/desktop/src/main.ts
@@ -416,22 +416,16 @@ const createMainWindow = () => {
window.on("close", (event) => {
if (!shouldAllowWindowClose) {
event.preventDefault();
- window.hide();
- }
- return false;
- });
-
- window.on("hide", () => {
- // On macOS, when hiding the window also hide the app's icon in the dock
- // unless the user has unchecked the Settings > Hide dock icon checkbox.
- if (shouldHideDockIcon()) {
- // macOS emits a window "hide" event when going fullscreen, and if
- // we hide the dock icon there then the window disappears. So ignore
- // this scenario.
- if (!window.isFullScreen()) {
+ // Only hide the dock icon when we are intercepting an explicit
+ // close action. On macOS, the generic "hide" event is also emitted
+ // for occlusion changes, so reacting there causes the dock icon to
+ // disappear when the window is fully covered by another window.
+ if (shouldHideDockIcon()) {
app.dock?.hide();
}
+ window.hide();
}
+ return false;
});
window.on("show", () => void app.dock?.show());
diff --git a/desktop/src/main/services/store.ts b/desktop/src/main/services/store.ts
index 1123b58a53..6e32b1923b 100644
--- a/desktop/src/main/services/store.ts
+++ b/desktop/src/main/services/store.ts
@@ -111,10 +111,10 @@ export const setLastShownChangelogVersion = (version: number) =>
* Return true if the dock icon should be hidden when the window is closed
* [macOS only].
*
- * On macOS, if this function returns true then when hiding ("closing" it with
- * the x traffic light) the window we also hide the app's icon in the dock. The
- * user can modify their preference using the Menu bar > ente > Settings > Hide
- * dock icon checkbox.
+ * On macOS, if this function returns true then when the user closes the window
+ * using the x traffic light we also hide the app's icon in the dock. The user
+ * can modify their preference using the Menu bar > ente > Settings > Hide dock
+ * icon checkbox.
*
* If the user has not set a value for this preference (i.e., the value is
* `undefined`), we use the default `true`. This is confusing, but this way we
diff --git a/desktop/src/main/stores/user-preferences.ts b/desktop/src/main/stores/user-preferences.ts
index 52aeef2dbc..12d529c395 100644
--- a/desktop/src/main/stores/user-preferences.ts
+++ b/desktop/src/main/stores/user-preferences.ts
@@ -3,8 +3,8 @@ import Store, { Schema } from "electron-store";
interface UserPreferences {
/**
* If true, then the user has set a preference to also hide the dock icon on
- * macOS whenever the app is hidden. The tray icon is always visible and can
- * then be used to reopen the app when needed.
+ * macOS when the window is closed using the x traffic light. The tray icon
+ * remains visible and can then be used to reopen the app when needed.
*/
hideDockIcon?: boolean;
skipAppVersion?: string;