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()
{
// 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);
}
}