X11: Notify instead of force focus

Signed-off-by: Jan Haller <bromeon@gmail.com>
This commit is contained in:
Alexandre Bodelot 2014-07-03 13:59:55 +02:00 committed by Jan Haller
parent c98bd1eaba
commit c4435b8a31

View File

@ -486,18 +486,19 @@ void WindowImplX11::setKeyRepeatEnabled(bool enabled)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void WindowImplX11::requestFocus() void WindowImplX11::requestFocus()
{ {
// Check if window is viewable (not on other desktop, minimized, ...) // Ensure WM hints exist
XWindowAttributes attributes; XWMHints* hints = XGetWMHints(m_display, m_window);
if (XGetWindowAttributes(m_display, m_window, &attributes) == 0) if (hints == NULL)
return; // error getting attribute {
hints = XAllocWMHints();
// Not viewable: Can't set focus }
if (attributes.map_state != IsViewable) else
return; {
// Add Urgency Hint flag (visual notification)
// Bring window to the front and give it input focus hints->flags |= XUrgencyHint;
XRaiseWindow(m_display, m_window); XSetWMHints(m_display, m_window, hints);
XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime); XFree(hints);
}
} }