From 1b7c6cf15015c87d9573dd9dfc7a56975dc81995 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sun, 28 May 2023 03:42:13 +0200 Subject: [PATCH] Windows: Do not auto-focus from our console Although auto-focus only works between a single Blender instance's child windows, this does include our own console and we don't want that. Luckily fixing this only requires a single check for null - because GetFocus() returns null to us for our console. Pull Request: https://projects.blender.org/blender/blender/pulls/108362 --- intern/ghost/intern/GHOST_SystemWin32.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 55efddbe7a5..0fc70c6634e 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -1867,9 +1867,10 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, /* Mouse Tracking is now off. TrackMouseEvent restarts in MouseMove. */ window->m_mousePresent = false; - /* Auto-focus only occurs within Blender windows, not with _other_ applications. */ + /* Auto-focus only occurs within Blender windows, not with _other_ applications. We are + * notified of change of focus from our console, but it returns null from GetFocus. */ HWND old_hwnd = ::GetFocus(); - if (hwnd != old_hwnd) { + if (old_hwnd && hwnd != old_hwnd) { HWND new_parent = ::GetParent(hwnd); HWND old_parent = ::GetParent(old_hwnd); if (hwnd == old_parent || old_hwnd == new_parent) {