summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorMario Schlack <m4r10.5ch14ck@gmail.com>2016-07-21 19:40:36 +0200
committerMario Schlack <m4r10.5ch14ck@gmail.com>2016-07-21 19:40:36 +0200
commitd04ada397318bd895360b2000e2091a431854fb9 (patch)
tree71f745b2cfdcdec68053f6fbd95b04c76fc5c4ff /platform/x11
parentb623acb718c50b86219027e0f6f7bebd11d96909 (diff)
Implement OS.request_attention() for X11
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp20
-rw-r--r--platform/x11/os_x11.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 20fae72abd..a9a8c73a74 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1043,6 +1043,26 @@ bool OS_X11::is_window_maximized() const {
return false;
}
+void OS_X11::request_attention() {
+ // Using EWMH -- Extended Window Manager Hints
+ //
+ // Sets the _NET_WM_STATE_DEMANDS_ATTENTION atom for WM_STATE
+ // Will be unset by the window manager after user react on the request for attention
+ //
+ XEvent xev;
+ Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
+ Atom wm_attention = XInternAtom(x11_display, "_NET_WM_STATE_DEMANDS_ATTENTION", False);
+
+ memset(&xev, 0, sizeof(xev));
+ xev.type = ClientMessage;
+ xev.xclient.window = x11_window;
+ xev.xclient.message_type = wm_state;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
+ xev.xclient.data.l[1] = wm_attention;
+
+ XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+}
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 71bbe726dd..b27f71406a 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -253,6 +253,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 move_window_to_foreground();
virtual void alert(const String& p_alert,const String& p_title="ALERT!");