Last active
August 29, 2015 14:02
-
-
Save abodelot/37ad3a65521499a1462d to your computer and use it in GitHub Desktop.
window gently requests focus instead of stealing it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp | |
index 4add01b..4cc2e7e 100644 | |
--- a/src/SFML/Window/Unix/WindowImplX11.cpp | |
+++ b/src/SFML/Window/Unix/WindowImplX11.cpp | |
@@ -486,18 +486,18 @@ void WindowImplX11::setKeyRepeatEnabled(bool enabled) | |
//////////////////////////////////////////////////////////// | |
void WindowImplX11::requestFocus() | |
{ | |
- // Check if window is viewable (not on other desktop, minimized, ...) | |
- XWindowAttributes attributes; | |
- if (XGetWindowAttributes(m_display, m_window, &attributes) == 0) | |
- return; // error getting attribute | |
- | |
- // Not viewable: Can't set focus | |
- if (attributes.map_state != IsViewable) | |
- return; | |
+ // Ensure WM hints exist | |
+ XWMHints* hints = XGetWMHints(m_display, m_window); | |
+ if (hints == NULL) | |
+ hints = XAllocWMHints(); | |
- // Bring window to the front and give it input focus | |
- XRaiseWindow(m_display, m_window); | |
- XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime); | |
+ if (hints != NULL) | |
+ { | |
+ // Add Urgency Hint flag (visual notification) | |
+ hints->flags |= XUrgencyHint; | |
+ XSetWMHints(m_display, m_window, hints); | |
+ XFree(hints); | |
+ } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment