From 5c355a63d3a86039a8f1a88e6ea508209de97dbc Mon Sep 17 00:00:00 2001 From: George Marques Date: Tue, 5 Jul 2016 12:29:08 -0300 Subject: Add OS.request_attention() for Windows --- core/bind/core_bind.cpp | 6 ++++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + doc/base/classes.xml | 5 +++++ platform/windows/os_windows.cpp | 11 +++++++++++ platform/windows/os_windows.h | 1 + 6 files changed, 25 insertions(+) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ace7e7c7b7..a0f4a2bc7a 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -946,6 +946,11 @@ void _OS::native_video_stop() { OS::get_singleton()->native_video_stop(); }; +void _OS::request_attention() { + + OS::get_singleton()->request_attention(); +} + bool _OS::is_debug_build() const { #ifdef DEBUG_ENABLED @@ -1039,6 +1044,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_window_minimized"),&_OS::is_window_minimized); ObjectTypeDB::bind_method(_MD("set_window_maximized", "enabled"),&_OS::set_window_maximized); ObjectTypeDB::bind_method(_MD("is_window_maximized"),&_OS::is_window_maximized); + ObjectTypeDB::bind_method(_MD("request_attention"), &_OS::request_attention); ObjectTypeDB::bind_method(_MD("set_borderless_window", "borderless"), &_OS::set_borderless_window); ObjectTypeDB::bind_method(_MD("get_borderless_window"), &_OS::get_borderless_window); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 856d942d02..295268d740 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -158,6 +158,7 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; + virtual void request_attention(); virtual void set_borderless_window(bool p_borderless); virtual bool get_borderless_window() const; diff --git a/core/os/os.h b/core/os/os.h index c291d09250..3df83b6d43 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -174,6 +174,7 @@ public: virtual bool is_window_minimized() const { return false; } virtual void set_window_maximized(bool p_enabled) {} virtual bool is_window_maximized() const { return true; } + virtual void request_attention() { } virtual void set_borderless_window(int p_borderless) {} virtual bool get_borderless_window() { return 0; } diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 4b5c424d4b..285e6a812b 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -22729,6 +22729,11 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) + + + Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX. + + diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 89de969cff..eee03b8dc1 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1683,6 +1683,17 @@ bool OS_Windows::get_borderless_window() { return video_mode.borderless_window; } +void OS_Windows::request_attention() { + + FLASHWINFO info; + info.cbSize = sizeof(FLASHWINFO); + info.hwnd = hWnd; + info.dwFlags = FLASHW_TRAY; + info.dwTimeout = 0; + info.uCount = 2; + FlashWindowEx(&info); +} + void OS_Windows::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index d2249bf352..388cc6c37d 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -230,6 +230,7 @@ public: virtual bool is_window_minimized() const; virtual void set_window_maximized(bool p_enabled); virtual bool is_window_maximized() const; + virtual void request_attention(); virtual void set_borderless_window(int p_borderless); virtual bool get_borderless_window(); -- cgit v1.2.3