Fix-restore-focus-on-desktop-switch
## Summary
When switching between virtual desktops, the previously focused window on the target desktop now automatically regains focus. This fixes the issue where users had to manually click on a window to focus it after switching desktops.
## Problem
When switching virtual desktops using keyboard shortcuts, Windows does not automatically restore focus to the previously focused window on the target desktop. Users had to manually click on a window to give it focus.
## Solution
Added focus restoration logic to the `OnCurrentDesktopChanged` event handler in `TilingService.Private.cs`:
- Uses async dispatcher with 100ms delay to ensure Windows completes the desktop transition before attempting to set focus
- Retrieves the tracked focused window for the desktop using `GetFocus()`
- Falls back to finding any visible window on the desktop if no tracked focus exists
- Uses `FocusHelper.ForceActivate()` to restore focus
- Handles edge cases gracefully (closed windows, minimized windows, exceptions)
合并状态:未合并 4 条评论