When a browser window is minimized, a call to ShowWindow(hWnd, SW_RESTORE) should properly restore focus. What seems to happen is that there's an extra WM_SETFOCUS/WM_KILLFOCUS message pair that moves focus from the child window (which had focus before the minimize) to the top level window. Because there is no WM_ACTIVATE that precedes this pair of messages, the event is suppressed so the focus manager does not restore focus to the child window. This occurs when restoring a minimized window programatically via the Windows 7 taskbar preview. An external application could attempt to do the same and we'd see the same result. Switching to another window and back again fixes the issue.
Created attachment 391086 [details] [diff] [review] patch Seems that ShowWindow(mWnd, SW_RESTORE) isn't quite the same as the user restoring. The latter sends an extra WM_SETFOCUS. Instead, this patch fires an extra NS_ACTIVATE after restoring or maximizing. The focus manager will call SetFocus or the right child widget but do nothing more as the window is already active. The test changes don't actually test this bug, but are just an extra check to ensure everything is still focused as it should in case something else breaks.