Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
feat: 合并 henkman#20 (切换桌面时记住焦点窗口)
Browse files Browse the repository at this point in the history
Title: remember focused window when switching desktops
Links: henkman#20

```Describe-Text
i was a bit annoyed that switching desktops would sometimes keep the hidden window focused and make me accidentally type into it so I made this simple edit that remembers the focused window for each desktop

the focus restore should silently fail and not cause issues if the window is somehow closed while it's hidden
```
  • Loading branch information
kitty-panics committed Apr 7, 2023
1 parent e9279ed commit 6462a70
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions virgo.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef struct {
Windows desktops[NUM_DESKTOPS];
Trayicon trayicon;
HWND pinned[NUM_PINNED];
HWND focused[NUM_DESKTOPS];
} Virgo;

static void *stb__sbgrowf(void *arr, unsigned increment, unsigned itemsize)
Expand Down Expand Up @@ -339,8 +340,10 @@ static void virgo_go_to_desk(Virgo *v, unsigned desk)
return;
}
virgo_update(v);
v->focused[v->current] = GetForegroundWindow();
windows_hide(&v->desktops[v->current]);
windows_show(&v->desktops[desk]);
SetForegroundWindow(v->focused[desk]);
v->current = desk;
trayicon_set(&v->trayicon, v->current + 1);
}
Expand Down

0 comments on commit 6462a70

Please sign in to comment.