imawizard / MiguruWM

A tiling window manager for Windows
BSD 2-Clause "Simplified" License
39 stars 3 forks source link

Inconsistent focus upon switching desktops #10

Closed imawizard closed 1 year ago

imawizard commented 1 year ago

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.:

  1. 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
    • IsWindowVisible returns true, IsWindowCloaked returns false, VD.DesktopByWindow returns unassigned
  2. there's a pinned window
    • 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.