Do not set input focus if WM supports _NET_ACTIVE_WINDOW

In case the window manager supports _NET_ACTIVE_WINDOW a client message
is sent to the root window and the window manager is expected to either
activate the window or mark it with demands attention.

In addition the code unconditionally also called xcb_set_input_focus
which breaks the intention of sending the client message. Thus it is
now only done if the WM doesn't support the protocol. This was also the
logic in Qt 4.x in QWidget::activateWindow (qwidget_x11.cpp).

In addition set_input_focus is only called if the window is a toplevel.

Change-Id: Iec4c02f0ea62db30a4b347d474fdfd2f05b8895b
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
Martin Gräßlin 2014-02-05 12:41:40 +01:00 committed by The Qt Project
parent 54835e3ccf
commit ab3637dd67

View File

@ -1375,6 +1375,7 @@ void QXcbWindow::requestActivateWindow()
updateNetWmUserTime(connection()->time());
if (window()->isTopLevel()
&& !(window()->flags() & Qt::X11BypassWindowManagerHint)
&& connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_ACTIVE_WINDOW))) {
xcb_client_message_event_t event;
@ -1390,9 +1391,9 @@ void QXcbWindow::requestActivateWindow()
event.data.data32[4] = 0;
Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event));
}
} else {
Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time()));
}
connection()->sync();
}