summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2016-07-21 17:29:45 +0200
committerGitHub <noreply@github.com>2016-07-21 17:29:45 +0200
commitd723e5a62ff10d338b8a2848e5a7a43a81233c24 (patch)
tree96b4aac1dc2795ecb49ecf0c149be43890794e1e
parent4abc945466c69426cf4c00ab87d61b927ef1639d (diff)
parent5c355a63d3a86039a8f1a88e6ea508209de97dbc (diff)
Merge pull request #5560 from vnen/os-request-attention
Add OS.request_attention() for Windows
-rw-r--r--core/bind/core_bind.cpp6
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/os/os.h1
-rw-r--r--doc/base/classes.xml5
-rw-r--r--platform/windows/os_windows.cpp11
-rw-r--r--platform/windows/os_windows.h1
6 files changed, 25 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 9cc934bb6f..e56684dc5e 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -944,6 +944,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
@@ -1042,6 +1047,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 b43c5246ed..9ca439a454 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 40f3989a55..2521d67e29 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 b8156133de..3f203170b3 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -22877,6 +22877,11 @@
<description>
</description>
</method>
+ <method name="request_attention">
+ <description>
+ Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX.
+ </description>
+ </method>
<method name="set_borderless_window">
<argument index="0" name="borderless" type="bool">
</argument>
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index b0a50ca4b8..c73e66f2b2 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 5acb300c0f..e3e037e57b 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();