Add WindowDoesNotAcceptFocus flag and use it in xcb
authorJan Arne Petersen <jpetersen@openismus.com>
Fri, 2 Dec 2011 14:20:04 +0000 (15:20 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 23 Feb 2012 12:25:26 +0000 (13:25 +0100)
Add window flag to support windows which should not get the input
focus.

Sets the input field in the WM_HINTS structure of the window to false
if the WindowDoesNotAcceptFocus flag is set on a window in xcb.

Change-Id: Ifbc10695b83484c17dca0eb13ea826d74f174833
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/corelib/global/qnamespace.h
src/corelib/global/qnamespace.qdoc
src/plugins/platforms/xcb/qxcbwindow.cpp
src/plugins/platforms/xcb/qxcbwindow.h

index 2087d76..4ea62c7 100644 (file)
@@ -293,6 +293,7 @@ public:
         WindowStaysOnTopHint = 0x00040000,
         WindowTransparentForInput = 0x00080000,
         WindowOverridesSystemGestures = 0x00100000,
+        WindowDoesNotAcceptFocus = 0x00200000,
 
         CustomizeWindowHint = 0x02000000,
         WindowStaysOnBottomHint = 0x04000000,
index d50960f..895feb7 100644 (file)
            implements its own set of gestures and that system level gestures, like for
            instance three-finger desktop switching, should be disabled.
 
+    \value WindowDoesNotAcceptFocus Informs the window system that this window should
+           not receive the input focus.
+
     \value WindowType_Mask  A mask for extracting the window type
                             part of the window flags.
 
index 43e4a6b..067cb77 100644 (file)
@@ -77,6 +77,7 @@
 #define xcb_size_hints_set_win_gravity xcb_icccm_size_hints_set_win_gravity
 #define xcb_wm_hints_set_iconic xcb_icccm_wm_hints_set_iconic
 #define xcb_wm_hints_set_normal xcb_icccm_wm_hints_set_normal
+#define xcb_wm_hints_set_input xcb_icccm_wm_hints_set_input
 #define xcb_wm_hints_t xcb_icccm_wm_hints_t
 #define XCB_WM_STATE_ICONIC XCB_ICCCM_WM_STATE_ICONIC
 #define XCB_WM_STATE_WITHDRAWN XCB_ICCCM_WM_STATE_WITHDRAWN
@@ -322,6 +323,8 @@ void QXcbWindow::create()
     memset(&hints, 0, sizeof(hints));
     xcb_wm_hints_set_normal(&hints);
 
+    xcb_wm_hints_set_input(&hints, !(window()->windowFlags() & Qt::WindowDoesNotAcceptFocus));
+
     xcb_set_wm_hints(xcb_connection(), m_window, &hints);
 
     xcb_window_t leader = m_screen->clientLeader();
@@ -509,6 +512,8 @@ void QXcbWindow::show()
         else
             xcb_wm_hints_set_normal(&hints);
 
+        xcb_wm_hints_set_input(&hints, !(window()->windowFlags() & Qt::WindowDoesNotAcceptFocus));
+
         xcb_set_wm_hints(xcb_connection(), m_window, &hints);
 
         // update WM_NORMAL_HINTS
@@ -730,6 +735,7 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
     setMotifWindowFlags(flags);
 
     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+    updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
 
     return flags;
 }
@@ -1062,6 +1068,24 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent)
     m_transparent = transparent;
 }
 
+void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus)
+{
+    xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window);
+
+    xcb_generic_error_t *error;
+
+    xcb_wm_hints_t hints;
+    xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error);
+
+    if (error) {
+        connection()->handleXcbError(error);
+        free(error);
+        return;
+    }
+
+    xcb_wm_hints_set_input(&hints, !doesNotAcceptFocus);
+    xcb_set_wm_hints(xcb_connection(), m_window, &hints);
+}
 
 WId QXcbWindow::winId() const
 {
index 365c8b0..6ae55e7 100644 (file)
@@ -132,6 +132,7 @@ private:
     void updateNetWmStateBeforeMap();
 
     void setTransparentForMouseEvents(bool transparent);
+    void updateDoesNotAcceptFocus(bool doesNotAcceptFocus);
 
     void create();
     void destroy();