Skip to content

Commit 7272680

Browse files
authored
Merge pull request #113 from grimmerk/fix/dock-activation-policy
fix: use setActivationPolicy for proper Dock behavior
2 parents 20908f9 + 8693a7b commit 7272680

4 files changed

Lines changed: 39 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 1.0.71
4+
5+
- Fix: use `setActivationPolicy` instead of `app.dock.hide/show` for proper Dock behavior
6+
- Normal mode: Dock icon with running dot + App Switcher
7+
- Menu bar mode: no Dock icon (clean accessory mode)
8+
- No Dock icon flash on app launch (LSUIElement=true kept)
9+
- Feat: tray right-click menu mode toggle (Switch to Normal/Menu Bar Mode)
10+
311
## 1.0.70
412

513
- Feat: Normal App mode — window stays visible, shows in Dock, draggable

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "CodeV",
33
"productName": "CodeV",
4-
"version": "1.0.70",
4+
"version": "1.0.71",
55
"description": "Quick switcher for VS Code, Cursor, and Claude Code sessions",
66
"repository": {
77
"type": "git",

src/TrayGenerator.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class TrayGenerator {
2121
tray: Tray;
2222
attachedWindow: BrowserWindow;
2323
onTrayClickCallback: any;
24+
onToggleAppMode: (() => void) | null = null;
25+
getAppMode: (() => string) | null = null;
2426
title: string;
2527
shortcuts: ShortcutSettings = {
2628
quickSwitcher: 'Command+Control+R',
@@ -83,7 +85,17 @@ export class TrayGenerator {
8385
},
8486
];
8587

88+
const currentMode = this.getAppMode ? this.getAppMode() : 'normal';
89+
const modeLabel = currentMode === 'normal' ? 'Switch to Menu Bar Mode' : 'Switch to Normal App Mode';
90+
8691
const menu: any = [
92+
{
93+
label: modeLabel,
94+
click: () => {
95+
if (this.onToggleAppMode) this.onToggleAppMode();
96+
},
97+
},
98+
{ type: 'separator' },
8799
{
88100
label: 'Settings',
89101
submenu: settingsItems,

src/main.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,9 +1032,11 @@ const trayToggleEvtHandler = async () => {
10321032

10331033
// Load app mode setting early (before window creation)
10341034
appMode = ((await settings.get('app-mode')) as 'normal' | 'menubar') || 'normal';
1035-
if (appMode === 'menubar') {
1036-
app.dock.hide();
1035+
if (appMode === 'normal') {
1036+
app.setActivationPolicy('regular');
10371037
}
1038+
// LSUIElement=true in Info.plist starts as accessory (no dock icon).
1039+
// 'regular' adds dock icon + running dot + App Switcher.
10381040

10391041
// Auto-update: check for updates via update.electronjs.org (non-MAS only)
10401042
if (!isMAS()) {
@@ -1292,6 +1294,12 @@ const trayToggleEvtHandler = async () => {
12921294
}
12931295

12941296
tray = new TrayGenerator(switcherWindow, title, trayToggleEvtHandler);
1297+
tray.getAppMode = () => appMode;
1298+
tray.onToggleAppMode = () => {
1299+
const newMode = appMode === 'normal' ? 'menubar' : 'normal';
1300+
// Reuse the same logic as the IPC handler
1301+
require('electron').ipcMain.emit('set-app-mode', {}, newMode);
1302+
};
12951303

12961304
// https://www.electronjs.org/docs/latest/tutorial/keyboard-shortcuts#global-shortcuts
12971305

@@ -1972,9 +1980,14 @@ ipcMain.on('set-app-mode', async (_event, mode: string) => {
19721980
await settings.set('app-mode', newMode);
19731981
appMode = newMode;
19741982
if (newMode === 'menubar') {
1975-
app.dock.hide();
1983+
app.setActivationPolicy('accessory');
1984+
// accessory mode hides all windows — re-show after short delay
1985+
const win = getSwitcherWindow();
1986+
if (win) {
1987+
setTimeout(() => { win.show(); win.focus(); }, 100);
1988+
}
19761989
} else {
1977-
await app.dock.show();
1990+
app.setActivationPolicy('regular');
19781991
}
19791992
// Notify renderer to update drag region
19801993
const window = getSwitcherWindow();
@@ -2131,4 +2144,4 @@ ipcMain.handle('detect-active-ide-projects', async () => {
21312144
return Array.from(folderNames);
21322145
});
21332146

2134-
// app.dock.hide() moved to async init block (after settings loaded)
2147+
// Dock visibility managed via app.setActivationPolicy() (see set-app-mode handler)

0 commit comments

Comments
 (0)