diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-06-30 16:58:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 16:58:46 +0200 |
commit | 5f2295f2dfdbf1ac4e63b562e4cef71f2fda4036 (patch) | |
tree | e55f07e3c6ae4a1986bba3d53e979c4d1414576b /platform/windows | |
parent | f3c5f12e3965b0a3147a9264f5ac42599abca672 (diff) | |
parent | 438c380458ee284d44f0561f86c2468ec11adc3b (diff) |
Merge pull request #39986 from reduz/app-inout-notification
Add a separate application focus/in notification
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/display_server_windows.cpp | 19 | ||||
-rw-r--r-- | platform/windows/display_server_windows.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index f47afcc4e5..61dc156fbc 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1790,6 +1790,12 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA // Restore mouse mode _set_mouse_mode_impl(mouse_mode); + if (!app_focused) { + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN); + } + app_focused = true; + } break; } case WM_KILLFOCUS: { @@ -1805,6 +1811,19 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } touch_state.clear(); + bool self_steal = false; + HWND new_hwnd = (HWND)wParam; + if (IsWindow(new_hwnd)) { + self_steal = true; + } + + if (!self_steal) { + if (OS::get_singleton()->get_main_loop()) { + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT); + } + app_focused = false; + } + break; } case WM_ACTIVATE: // Watch For Window Activate Message diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 995ced0809..8433bb449b 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -317,6 +317,7 @@ private: int pressrc; HINSTANCE hInstance; // Holds The Instance Of The Application String rendering_driver; + bool app_focused = false; struct WindowData { HWND hWnd; |