X11: Notify instead of force focus
Signed-off-by: Jan Haller <bromeon@gmail.com>
This commit is contained in:
parent
c98bd1eaba
commit
c4435b8a31
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user