File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 24
24
typedef struct {
25
25
HWND * windows ;
26
26
unsigned count ;
27
+ HWND focus ;
27
28
} Windows ;
28
29
29
30
typedef struct {
@@ -43,6 +44,18 @@ typedef struct {
43
44
HWND pinned [NUM_PINNED ];
44
45
} Virgo ;
45
46
47
+ static void save_current_desktops_focus (Windows * desktops ) {
48
+ desktops -> focus = GetForegroundWindow ();
49
+ }
50
+
51
+ static unsigned is_valid_window (HWND hwnd );
52
+ static void restore_current_desktops_focus (Windows * desktops ) {
53
+ if (!desktops -> focus || !is_valid_window (desktops -> focus )) {
54
+ return ;
55
+ }
56
+ SetForegroundWindow (desktops -> focus );
57
+ }
58
+
46
59
static void * stb__sbgrowf (void * arr , unsigned increment , unsigned itemsize )
47
60
{
48
61
unsigned dbl_cur = arr ? 2 * stb__sbm (arr ) : 0 ;
@@ -339,8 +352,10 @@ static void virgo_go_to_desk(Virgo *v, unsigned desk)
339
352
return ;
340
353
}
341
354
virgo_update (v );
355
+ save_current_desktops_focus (& v -> desktops [v -> current ]);
342
356
windows_hide (& v -> desktops [v -> current ]);
343
357
windows_show (& v -> desktops [desk ]);
358
+ restore_current_desktops_focus (& v -> desktops [desk ]);
344
359
v -> current = desk ;
345
360
trayicon_set (& v -> trayicon , v -> current + 1 );
346
361
}
You can’t perform that action at this time.
0 commit comments