Skip to content

Commit 654c8e6

Browse files
authored
Merge pull request #114 from grimmerk/fix/quick-switcher-focus-when-covered
fix: window-toggle actions focus when covered (Cmd+Ctrl+R/T, tray click)
2 parents 7272680 + 5933a0a commit 654c8e6

3 files changed

Lines changed: 54 additions & 12 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.72
4+
5+
- Fix: window-toggle actions bring window to front when covered by another app (Normal mode)
6+
- `Cmd+Ctrl+R` (Quick Switcher), `Cmd+Ctrl+T` (Terminal), and tray left-click
7+
- Previously: visible-but-unfocused first press hid the window
8+
- Now: visible+unfocused → focus to top; visible+focused → hide (or toggle Terminal tab)
9+
- Menu bar mode unaffected (`onBlur` auto-hide makes the state unreachable)
10+
311
## 1.0.71
412

513
- Fix: use `setActivationPolicy` instead of `app.dock.hide/show` for proper Dock behavior

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.71",
4+
"version": "1.0.72",
55
"description": "Quick switcher for VS Code, Cursor, and Claude Code sessions",
66
"repository": {
77
"type": "git",

src/main.ts

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,12 +1002,24 @@ const trayToggleEvtHandler = async () => {
10021002
showSwitcherWindow();
10031003
} else {
10041004
const window = getSwitcherWindow();
1005-
1006-
if (window && window.isVisible()) {
1007-
if (isDebug) {
1008-
console.log('is visible, to hide');
1005+
1006+
if (window && window.isVisible() && !window.isMinimized()) {
1007+
if (window.isFocused()) {
1008+
if (isDebug) {
1009+
console.log('is visible and focused, to hide');
1010+
}
1011+
hideSwitcherWindow();
1012+
} else {
1013+
// Visible but covered by another app — bring to front instead of hiding
1014+
if (isDebug) {
1015+
console.log('is visible but unfocused, bringing to front');
1016+
}
1017+
if (appMode === 'normal') {
1018+
app.focus({ steal: true });
1019+
}
1020+
window.show();
1021+
window.focus();
10091022
}
1010-
hideSwitcherWindow();
10111023
} else if (window) {
10121024
if (isDebug) {
10131025
console.log('is not visible, to show');
@@ -1327,10 +1339,22 @@ const trayToggleEvtHandler = async () => {
13271339
const window = getSwitcherWindow();
13281340

13291341
if (window && window.isVisible() && !window.isMinimized()) {
1330-
if (isDebug) {
1331-
console.log('Switcher window visible, hiding it');
1342+
if (window.isFocused()) {
1343+
if (isDebug) {
1344+
console.log('Switcher window visible and focused, hiding it');
1345+
}
1346+
hideSwitcherWindow();
1347+
} else {
1348+
// Visible but covered by another app — bring to top instead of hiding
1349+
if (isDebug) {
1350+
console.log('Switcher window visible but unfocused, bringing to front');
1351+
}
1352+
if (appMode === 'normal') {
1353+
app.focus({ steal: true });
1354+
}
1355+
window.show();
1356+
window.focus();
13321357
}
1333-
hideSwitcherWindow();
13341358
} else if (window) {
13351359
if (isDebug) {
13361360
console.log('Switcher window exists but hidden, showing it');
@@ -1626,9 +1650,19 @@ const trayToggleEvtHandler = async () => {
16261650
switcherWindow = createSwitcherWindow();
16271651
}
16281652
const window = getSwitcherWindow();
1629-
if (window && window.isVisible()) {
1630-
// If already showing Terminal tab, hide; otherwise switch to Terminal
1631-
window.webContents.send('check-terminal-and-hide');
1653+
if (window && window.isVisible() && !window.isMinimized()) {
1654+
if (window.isFocused()) {
1655+
// If already showing Terminal tab, hide; otherwise switch to Terminal
1656+
window.webContents.send('check-terminal-and-hide');
1657+
} else {
1658+
// Visible but covered — bring to front and switch to Terminal tab
1659+
if (appMode === 'normal') {
1660+
app.focus({ steal: true });
1661+
}
1662+
window.show();
1663+
window.focus();
1664+
window.webContents.send('switch-to-terminal');
1665+
}
16321666
} else if (window) {
16331667
window.webContents.send('switch-to-terminal');
16341668
showSwitcherWindow();

0 commit comments

Comments
 (0)