- //HWND hwnd = win->sys->hwnd;
- //HWND top = GetAncestor(hwnd,GA_ROOT);
- //SetWindowPos(top, HWND_TOPMOST, 0, 0, 0, 0,
- // SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ /* See note in sys_focus */
+ DWORD oldId = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
+ DWORD newId = GetCurrentThreadId();
+ AttachThreadInput(oldId, newId, TRUE);
+
+ SetWindowPos(win->sys->hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
+
+ AttachThreadInput(oldId, newId, FALSE);