From c4435b8a31432fa93a8b1d1762155902cc0af198 Mon Sep 17 00:00:00 2001 From: Alexandre Bodelot Date: Thu, 3 Jul 2014 13:59:55 +0200 Subject: [PATCH] X11: Notify instead of force focus Signed-off-by: Jan Haller --- src/SFML/Window/Unix/WindowImplX11.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index bd1fb2c8..e01d4920 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -486,18 +486,19 @@ 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; - - // Bring window to the front and give it input focus - XRaiseWindow(m_display, m_window); - XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime); + // Ensure WM hints exist + XWMHints* hints = XGetWMHints(m_display, m_window); + if (hints == NULL) + { + hints = XAllocWMHints(); + } + else + { + // Add Urgency Hint flag (visual notification) + hints->flags |= XUrgencyHint; + XSetWMHints(m_display, m_window, hints); + XFree(hints); + } }