From ab3637dd678d4d7fe94f91a927230cbdd91fe3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 5 Feb 2014 12:41:40 +0100 Subject: [PATCH] Do not set input focus if WM supports _NET_ACTIVE_WINDOW MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/plugins/platforms/xcb/qxcbwindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 433d6d5948..a1e7bea0dd 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -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,10 +1391,10 @@ 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())); } - Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time())); - connection()->sync(); }