From 2e71832e5db68248f5873c2f23d2cb46844d1339 Mon Sep 17 00:00:00 2001 From: "Franc[e]sco" Date: Mon, 19 Nov 2018 11:20:07 +0100 Subject: [PATCH] remember focused window when switching desktops --- virgo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virgo.c b/virgo.c index 2359d80..1d653ab 100644 --- a/virgo.c +++ b/virgo.c @@ -38,6 +38,7 @@ typedef struct { unsigned current; unsigned handle_hotkeys; Windows desktops[NUM_DESKTOPS]; + HWND focused[NUM_DESKTOPS]; Trayicon trayicon; } Virgo; @@ -291,8 +292,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); }