From 8bcaf951a632cdadb149b7b6e53c94f666146afb Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Thu, 29 Sep 2011 08:01:06 +0000 Subject: [PATCH] Improve sys_focus on win32 --- sys-win32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys-win32.c b/sys-win32.c index 04e4ef4..ba3a7e9 100644 --- a/sys-win32.c +++ b/sys-win32.c @@ -324,9 +324,13 @@ void sys_focus(win_t *win) * certain circumstances and instead flashes the windows toolbar icon. * Attaching the thread input queues avoids this behavior */ DWORD oldId = GetWindowThreadProcessId(GetForegroundWindow(), NULL); - DWORD newId = GetWindowThreadProcessId(win->sys->hwnd, NULL); + DWORD newId = GetCurrentThreadId(); AttachThreadInput(oldId, newId, TRUE); + + BringWindowToTop(win->sys->hwnd); SetForegroundWindow(win->sys->hwnd); + SetFocus(win->sys->hwnd); + AttachThreadInput(oldId, newId, FALSE); } -- 2.43.2