Right now calling VD.FocusDesktop focuses the taskbar (to prevent the taskbar icons from flashing) and restores the prior active window with Alt-Escape (see commit 5621361).
However, there are cases where it's not working consistently, e.g.:
MS Teams is running but its main-window is not opened anywhere
upon switching desktops with above method the (actually closed) MS Teams gets focused
it's always the pinned window that gets focused upon switching desktops with above method
also right before the EV_DESKTOP_CHANGED-event, there's a EV_WINDOW_FOCUSED-event for the pinned window, so in _onDesktopEvent using workspace.ActiveWindow actually results in the pinned window, not in actual prior active window
Switching desktops with the built-in method by swiping the trackpad does not have these limitations (there are other minor annoyances, though, I can't recall right now), but I couldn't find a workaround so far.
Ultimately it should be possible mimicking the built-in behaviour by reversing the swipe-handlers twinui.pcshell.dll, which would obviously be pretty time-consuming, though.
Right now calling VD.FocusDesktop focuses the taskbar (to prevent the taskbar icons from flashing) and restores the prior active window with Alt-Escape (see commit 5621361).
However, there are cases where it's not working consistently, e.g.:
_onDesktopEvent
usingworkspace.ActiveWindow
actually results in the pinned window, not in actual prior active windowSwitching desktops with the built-in method by swiping the trackpad does not have these limitations (there are other minor annoyances, though, I can't recall right now), but I couldn't find a workaround so far.
Ultimately it should be possible mimicking the built-in behaviour by reversing the swipe-handlers twinui.pcshell.dll, which would obviously be pretty time-consuming, though.