Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||||||||||||||
6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||||||||||||||
40 | #include "qxcbwindow.h" | - | ||||||||||||||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||||||||||||||
42 | #include <QtDebug> | - | ||||||||||||||||||||||||||||||||||||
43 | #include <QMetaEnum> | - | ||||||||||||||||||||||||||||||||||||
44 | #include <QScreen> | - | ||||||||||||||||||||||||||||||||||||
45 | #include <QtGui/QIcon> | - | ||||||||||||||||||||||||||||||||||||
46 | #include <QtGui/QRegion> | - | ||||||||||||||||||||||||||||||||||||
47 | #include <QtGui/private/qhighdpiscaling_p.h> | - | ||||||||||||||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||||||||||||||
49 | #include "qxcbintegration.h" | - | ||||||||||||||||||||||||||||||||||||
50 | #include "qxcbconnection.h" | - | ||||||||||||||||||||||||||||||||||||
51 | #include "qxcbscreen.h" | - | ||||||||||||||||||||||||||||||||||||
52 | #include "qxcbdrag.h" | - | ||||||||||||||||||||||||||||||||||||
53 | #include "qxcbkeyboard.h" | - | ||||||||||||||||||||||||||||||||||||
54 | #include "qxcbwmsupport.h" | - | ||||||||||||||||||||||||||||||||||||
55 | #include "qxcbimage.h" | - | ||||||||||||||||||||||||||||||||||||
56 | #include "qxcbnativeinterface.h" | - | ||||||||||||||||||||||||||||||||||||
57 | #include "qxcbsystemtraytracker.h" | - | ||||||||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||||||||
59 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||||||||||||||||||||
60 | #include <qpa/qplatformcursor.h> | - | ||||||||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||||||||
62 | #include <algorithm> | - | ||||||||||||||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||||||||||||||
64 | // FIXME This workaround can be removed for xcb-icccm > 3.8 | - | ||||||||||||||||||||||||||||||||||||
65 | #define class class_name | - | ||||||||||||||||||||||||||||||||||||
66 | #include <xcb/xcb_icccm.h> | - | ||||||||||||||||||||||||||||||||||||
67 | #undef class | - | ||||||||||||||||||||||||||||||||||||
68 | #include <xcb/xfixes.h> | - | ||||||||||||||||||||||||||||||||||||
69 | #include <xcb/shape.h> | - | ||||||||||||||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||||||||||||||
71 | // xcb-icccm 3.8 support | - | ||||||||||||||||||||||||||||||||||||
72 | #ifdef XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS | - | ||||||||||||||||||||||||||||||||||||
73 | #define xcb_get_wm_hints_reply xcb_icccm_get_wm_hints_reply | - | ||||||||||||||||||||||||||||||||||||
74 | #define xcb_get_wm_hints xcb_icccm_get_wm_hints | - | ||||||||||||||||||||||||||||||||||||
75 | #define xcb_get_wm_hints_unchecked xcb_icccm_get_wm_hints_unchecked | - | ||||||||||||||||||||||||||||||||||||
76 | #define xcb_set_wm_hints xcb_icccm_set_wm_hints | - | ||||||||||||||||||||||||||||||||||||
77 | #define xcb_set_wm_normal_hints xcb_icccm_set_wm_normal_hints | - | ||||||||||||||||||||||||||||||||||||
78 | #define xcb_size_hints_set_base_size xcb_icccm_size_hints_set_base_size | - | ||||||||||||||||||||||||||||||||||||
79 | #define xcb_size_hints_set_max_size xcb_icccm_size_hints_set_max_size | - | ||||||||||||||||||||||||||||||||||||
80 | #define xcb_size_hints_set_min_size xcb_icccm_size_hints_set_min_size | - | ||||||||||||||||||||||||||||||||||||
81 | #define xcb_size_hints_set_position xcb_icccm_size_hints_set_position | - | ||||||||||||||||||||||||||||||||||||
82 | #define xcb_size_hints_set_resize_inc xcb_icccm_size_hints_set_resize_inc | - | ||||||||||||||||||||||||||||||||||||
83 | #define xcb_size_hints_set_size xcb_icccm_size_hints_set_size | - | ||||||||||||||||||||||||||||||||||||
84 | #define xcb_size_hints_set_win_gravity xcb_icccm_size_hints_set_win_gravity | - | ||||||||||||||||||||||||||||||||||||
85 | #define xcb_wm_hints_set_iconic xcb_icccm_wm_hints_set_iconic | - | ||||||||||||||||||||||||||||||||||||
86 | #define xcb_wm_hints_set_normal xcb_icccm_wm_hints_set_normal | - | ||||||||||||||||||||||||||||||||||||
87 | #define xcb_wm_hints_set_input xcb_icccm_wm_hints_set_input | - | ||||||||||||||||||||||||||||||||||||
88 | #define xcb_wm_hints_t xcb_icccm_wm_hints_t | - | ||||||||||||||||||||||||||||||||||||
89 | #define XCB_WM_STATE_ICONIC XCB_ICCCM_WM_STATE_ICONIC | - | ||||||||||||||||||||||||||||||||||||
90 | #define XCB_WM_STATE_WITHDRAWN XCB_ICCCM_WM_STATE_WITHDRAWN | - | ||||||||||||||||||||||||||||||||||||
91 | #endif | - | ||||||||||||||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||||||||||||||
93 | #include <private/qguiapplication_p.h> | - | ||||||||||||||||||||||||||||||||||||
94 | #include <private/qwindow_p.h> | - | ||||||||||||||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||||||||||||||
96 | #include <qpa/qplatformbackingstore.h> | - | ||||||||||||||||||||||||||||||||||||
97 | #include <qpa/qwindowsysteminterface.h> | - | ||||||||||||||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||||||||||||||
99 | #include <QTextCodec> | - | ||||||||||||||||||||||||||||||||||||
100 | #include <stdio.h> | - | ||||||||||||||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||||||||||||||
102 | #ifdef XCB_USE_XLIB | - | ||||||||||||||||||||||||||||||||||||
103 | #include <X11/Xlib.h> | - | ||||||||||||||||||||||||||||||||||||
104 | #include <X11/Xutil.h> | - | ||||||||||||||||||||||||||||||||||||
105 | #endif | - | ||||||||||||||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||||||||||||||
107 | #if defined(XCB_USE_XINPUT2) | - | ||||||||||||||||||||||||||||||||||||
108 | #include <X11/extensions/XInput2.h> | - | ||||||||||||||||||||||||||||||||||||
109 | #include <X11/extensions/XI2proto.h> | - | ||||||||||||||||||||||||||||||||||||
110 | #endif | - | ||||||||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||||||||
112 | #define XCOORD_MAX 16383 | - | ||||||||||||||||||||||||||||||||||||
113 | enum { | - | ||||||||||||||||||||||||||||||||||||
114 | defaultWindowWidth = 160, | - | ||||||||||||||||||||||||||||||||||||
115 | defaultWindowHeight = 160 | - | ||||||||||||||||||||||||||||||||||||
116 | }; | - | ||||||||||||||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||||||||||||||
118 | //#ifdef NET_WM_STATE_DEBUG | - | ||||||||||||||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||||||||||||||
120 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||||||||||||||
121 | - | |||||||||||||||||||||||||||||||||||||
122 | #undef FocusIn | - | ||||||||||||||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||||||||||||||
124 | enum QX11EmbedFocusInDetail { | - | ||||||||||||||||||||||||||||||||||||
125 | XEMBED_FOCUS_CURRENT = 0, | - | ||||||||||||||||||||||||||||||||||||
126 | XEMBED_FOCUS_FIRST = 1, | - | ||||||||||||||||||||||||||||||||||||
127 | XEMBED_FOCUS_LAST = 2 | - | ||||||||||||||||||||||||||||||||||||
128 | }; | - | ||||||||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||||||||
130 | enum QX11EmbedInfoFlags { | - | ||||||||||||||||||||||||||||||||||||
131 | XEMBED_MAPPED = (1 << 0), | - | ||||||||||||||||||||||||||||||||||||
132 | }; | - | ||||||||||||||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||||||||||||||
134 | enum QX11EmbedMessageType { | - | ||||||||||||||||||||||||||||||||||||
135 | XEMBED_EMBEDDED_NOTIFY = 0, | - | ||||||||||||||||||||||||||||||||||||
136 | XEMBED_WINDOW_ACTIVATE = 1, | - | ||||||||||||||||||||||||||||||||||||
137 | XEMBED_WINDOW_DEACTIVATE = 2, | - | ||||||||||||||||||||||||||||||||||||
138 | XEMBED_REQUEST_FOCUS = 3, | - | ||||||||||||||||||||||||||||||||||||
139 | XEMBED_FOCUS_IN = 4, | - | ||||||||||||||||||||||||||||||||||||
140 | XEMBED_FOCUS_OUT = 5, | - | ||||||||||||||||||||||||||||||||||||
141 | XEMBED_FOCUS_NEXT = 6, | - | ||||||||||||||||||||||||||||||||||||
142 | XEMBED_FOCUS_PREV = 7, | - | ||||||||||||||||||||||||||||||||||||
143 | XEMBED_MODALITY_ON = 10, | - | ||||||||||||||||||||||||||||||||||||
144 | XEMBED_MODALITY_OFF = 11, | - | ||||||||||||||||||||||||||||||||||||
145 | XEMBED_REGISTER_ACCELERATOR = 12, | - | ||||||||||||||||||||||||||||||||||||
146 | XEMBED_UNREGISTER_ACCELERATOR = 13, | - | ||||||||||||||||||||||||||||||||||||
147 | XEMBED_ACTIVATE_ACCELERATOR = 14 | - | ||||||||||||||||||||||||||||||||||||
148 | }; | - | ||||||||||||||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||||||||||||||
150 | const quint32 XEMBED_VERSION = 0; | - | ||||||||||||||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||||||||||||||
152 | QXcbScreen *QXcbWindow::parentScreen() | - | ||||||||||||||||||||||||||||||||||||
153 | { | - | ||||||||||||||||||||||||||||||||||||
154 | return parent() ? static_cast<QXcbWindow*>(parent())->parentScreen() : xcbScreen(); | - | ||||||||||||||||||||||||||||||||||||
155 | } | - | ||||||||||||||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||||||||||||||
157 | // Returns \c true if we should set WM_TRANSIENT_FOR on \a w | - | ||||||||||||||||||||||||||||||||||||
158 | static inline bool isTransient(const QWindow *w) | - | ||||||||||||||||||||||||||||||||||||
159 | { | - | ||||||||||||||||||||||||||||||||||||
160 | return w->type() == Qt::Dialog | - | ||||||||||||||||||||||||||||||||||||
161 | || w->type() == Qt::Sheet | - | ||||||||||||||||||||||||||||||||||||
162 | || w->type() == Qt::Tool | - | ||||||||||||||||||||||||||||||||||||
163 | || w->type() == Qt::SplashScreen | - | ||||||||||||||||||||||||||||||||||||
164 | || w->type() == Qt::ToolTip | - | ||||||||||||||||||||||||||||||||||||
165 | || w->type() == Qt::Drawer | - | ||||||||||||||||||||||||||||||||||||
166 | || w->type() == Qt::Popup; | - | ||||||||||||||||||||||||||||||||||||
167 | } | - | ||||||||||||||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||||||||||||||
169 | static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, quint32 blue_mask, bool *rgbSwap) | - | ||||||||||||||||||||||||||||||||||||
170 | { | - | ||||||||||||||||||||||||||||||||||||
171 | if (rgbSwap)
| 0-4405 | ||||||||||||||||||||||||||||||||||||
172 | *rgbSwap = false; executed 4405 times by 128 tests: *rgbSwap = false; Executed by:
| 4405 | ||||||||||||||||||||||||||||||||||||
173 | switch (depth) { | - | ||||||||||||||||||||||||||||||||||||
174 | case 32: executed 4 times by 2 tests: case 32: Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||
175 | if (blue_mask == 0xff)
| 0-4 | ||||||||||||||||||||||||||||||||||||
176 | return QImage::Format_ARGB32_Premultiplied; executed 4 times by 2 tests: return QImage::Format_ARGB32_Premultiplied; Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||
177 | if (red_mask == 0x3ff)
| 0 | ||||||||||||||||||||||||||||||||||||
178 | return QImage::Format_A2BGR30_Premultiplied; never executed: return QImage::Format_A2BGR30_Premultiplied; | 0 | ||||||||||||||||||||||||||||||||||||
179 | if (blue_mask == 0x3ff)
| 0 | ||||||||||||||||||||||||||||||||||||
180 | return QImage::Format_A2RGB30_Premultiplied; never executed: return QImage::Format_A2RGB30_Premultiplied; | 0 | ||||||||||||||||||||||||||||||||||||
181 | if (red_mask == 0xff) {
| 0 | ||||||||||||||||||||||||||||||||||||
182 | if (rgbSwap)
| 0 | ||||||||||||||||||||||||||||||||||||
183 | *rgbSwap = true; never executed: *rgbSwap = true; | 0 | ||||||||||||||||||||||||||||||||||||
184 | return QImage::Format_ARGB32_Premultiplied; never executed: return QImage::Format_ARGB32_Premultiplied; | 0 | ||||||||||||||||||||||||||||||||||||
185 | } | - | ||||||||||||||||||||||||||||||||||||
186 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
187 | case 30: never executed: case 30: | 0 | ||||||||||||||||||||||||||||||||||||
188 | if (red_mask == 0x3ff)
| 0 | ||||||||||||||||||||||||||||||||||||
189 | return QImage::Format_BGR30; never executed: return QImage::Format_BGR30; | 0 | ||||||||||||||||||||||||||||||||||||
190 | if (blue_mask == 0x3ff)
| 0 | ||||||||||||||||||||||||||||||||||||
191 | return QImage::Format_RGB30; never executed: return QImage::Format_RGB30; | 0 | ||||||||||||||||||||||||||||||||||||
192 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
193 | case 24: executed 4401 times by 128 tests: case 24: Executed by:
| 4401 | ||||||||||||||||||||||||||||||||||||
194 | if (blue_mask == 0xff)
| 0-4401 | ||||||||||||||||||||||||||||||||||||
195 | return QImage::Format_RGB32; executed 4401 times by 128 tests: return QImage::Format_RGB32; Executed by:
| 4401 | ||||||||||||||||||||||||||||||||||||
196 | if (red_mask == 0xff) {
| 0 | ||||||||||||||||||||||||||||||||||||
197 | if (rgbSwap)
| 0 | ||||||||||||||||||||||||||||||||||||
198 | *rgbSwap = true; never executed: *rgbSwap = true; | 0 | ||||||||||||||||||||||||||||||||||||
199 | return QImage::Format_RGB32; never executed: return QImage::Format_RGB32; | 0 | ||||||||||||||||||||||||||||||||||||
200 | } | - | ||||||||||||||||||||||||||||||||||||
201 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
202 | case 16: never executed: case 16: | 0 | ||||||||||||||||||||||||||||||||||||
203 | if (blue_mask == 0x1f)
| 0 | ||||||||||||||||||||||||||||||||||||
204 | return QImage::Format_RGB16; never executed: return QImage::Format_RGB16; | 0 | ||||||||||||||||||||||||||||||||||||
205 | if (red_mask
| 0 | ||||||||||||||||||||||||||||||||||||
206 | if (rgbSwap
| 0 | ||||||||||||||||||||||||||||||||||||
207 | *rgbSwap = true; never executed: *rgbSwap = true; | 0 | ||||||||||||||||||||||||||||||||||||
208 | return QImage::Format_RGB16; never executed: return QImage::Format_RGB16; | 0 | ||||||||||||||||||||||||||||||||||||
209 | } | - | ||||||||||||||||||||||||||||||||||||
210 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
211 | case 15: never executed: case 15: | 0 | ||||||||||||||||||||||||||||||||||||
212 | if (blue_mask == 0x1f)
| 0 | ||||||||||||||||||||||||||||||||||||
213 | return QImage::Format_RGB555; never executed: return QImage::Format_RGB555; | 0 | ||||||||||||||||||||||||||||||||||||
214 | if (red_mask == 0x1f) {
| 0 | ||||||||||||||||||||||||||||||||||||
215 | if (rgbSwap)
| 0 | ||||||||||||||||||||||||||||||||||||
216 | *rgbSwap = true; never executed: *rgbSwap = true; | 0 | ||||||||||||||||||||||||||||||||||||
217 | return QImage::Format_RGB555 never executed: ;return QImage::Format_RGB555; never executed: return QImage::Format_RGB555; | 0 | ||||||||||||||||||||||||||||||||||||
218 | } | - | ||||||||||||||||||||||||||||||||||||
219 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
220 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
221 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
222 | } | - | ||||||||||||||||||||||||||||||||||||
223 | qWarning("Unsupported screen format: depth: %d, red_mask: %x, blue_mask: %x", depth, red_mask, blue_mask); | - | ||||||||||||||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||||||||||||||
225 | switch (depth) { | - | ||||||||||||||||||||||||||||||||||||
226 | case 24: never executed: case 24: | 0 | ||||||||||||||||||||||||||||||||||||
227 | qWarning("Using RGB32 fallback, if this works your X11 server is reporting a bad screen format."); | - | ||||||||||||||||||||||||||||||||||||
228 | return QImage::Format_RGB32; never executed: return QImage::Format_RGB32; | 0 | ||||||||||||||||||||||||||||||||||||
229 | case 16: never executed: case 16: | 0 | ||||||||||||||||||||||||||||||||||||
230 | qWarning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format."); | - | ||||||||||||||||||||||||||||||||||||
231 | return QImage::Format_RGB16; never executed: return QImage::Format_RGB16; | 0 | ||||||||||||||||||||||||||||||||||||
232 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
233 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
234 | } | - | ||||||||||||||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||||||||||||||
236 | return QImage::Format_Invalid; never executed: return QImage::Format_Invalid; | 0 | ||||||||||||||||||||||||||||||||||||
237 | } | - | ||||||||||||||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||||||||||||||
239 | static inline bool positionIncludesFrame(QWindow *w) | - | ||||||||||||||||||||||||||||||||||||
240 | { | - | ||||||||||||||||||||||||||||||||||||
241 | return qt_window_private(w)->positionPolicy == QWindowPrivate::WindowFrameInclusive; | - | ||||||||||||||||||||||||||||||||||||
242 | } | - | ||||||||||||||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||||||||||||||
244 | #ifdef XCB_USE_XLIB | - | ||||||||||||||||||||||||||||||||||||
245 | static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) | - | ||||||||||||||||||||||||||||||||||||
246 | { | - | ||||||||||||||||||||||||||||||||||||
247 | #include <X11/Xatom.h> | - | ||||||||||||||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||||||||||||||
249 | static XTextProperty tp = { 0, 0, 0, 0 }; | - | ||||||||||||||||||||||||||||||||||||
250 | static bool free_prop = true; // we can't free tp.value in case it references | - | ||||||||||||||||||||||||||||||||||||
251 | // the data of the static QByteArray below. | - | ||||||||||||||||||||||||||||||||||||
252 | if (tp.value) { | - | ||||||||||||||||||||||||||||||||||||
253 | if (free_prop) | - | ||||||||||||||||||||||||||||||||||||
254 | XFree(tp.value); | - | ||||||||||||||||||||||||||||||||||||
255 | tp.value = 0; | - | ||||||||||||||||||||||||||||||||||||
256 | free_prop = true; | - | ||||||||||||||||||||||||||||||||||||
257 | } | - | ||||||||||||||||||||||||||||||||||||
258 | - | |||||||||||||||||||||||||||||||||||||
259 | static const QTextCodec* mapper = QTextCodec::codecForLocale(); | - | ||||||||||||||||||||||||||||||||||||
260 | int errCode = 0; | - | ||||||||||||||||||||||||||||||||||||
261 | if (mapper) { | - | ||||||||||||||||||||||||||||||||||||
262 | QByteArray mapped = mapper->fromUnicode(s); | - | ||||||||||||||||||||||||||||||||||||
263 | char* tl[2]; | - | ||||||||||||||||||||||||||||||||||||
264 | tl[0] = mapped.data(); | - | ||||||||||||||||||||||||||||||||||||
265 | tl[1] = 0; | - | ||||||||||||||||||||||||||||||||||||
266 | errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp); | - | ||||||||||||||||||||||||||||||||||||
267 | if (errCode < 0) | - | ||||||||||||||||||||||||||||||||||||
268 | qDebug("XmbTextListToTextProperty result code %d", errCode); | - | ||||||||||||||||||||||||||||||||||||
269 | } | - | ||||||||||||||||||||||||||||||||||||
270 | if (!mapper || errCode < 0) { | - | ||||||||||||||||||||||||||||||||||||
271 | mapper = QTextCodec::codecForName("latin1"); | - | ||||||||||||||||||||||||||||||||||||
272 | if (!mapper || !mapper->canEncode(s)) | - | ||||||||||||||||||||||||||||||||||||
273 | return Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
274 | static QByteArray qcs; | - | ||||||||||||||||||||||||||||||||||||
275 | qcs = s.toLatin1(); | - | ||||||||||||||||||||||||||||||||||||
276 | tp.value = (uchar*)qcs.data(); | - | ||||||||||||||||||||||||||||||||||||
277 | tp.encoding = XA_STRING; | - | ||||||||||||||||||||||||||||||||||||
278 | tp.format = 8; | - | ||||||||||||||||||||||||||||||||||||
279 | tp.nitems = qcs.length(); | - | ||||||||||||||||||||||||||||||||||||
280 | free_prop = false; | - | ||||||||||||||||||||||||||||||||||||
281 | } | - | ||||||||||||||||||||||||||||||||||||
282 | return &tp; | - | ||||||||||||||||||||||||||||||||||||
283 | } | - | ||||||||||||||||||||||||||||||||||||
284 | #endif // XCB_USE_XLIB | - | ||||||||||||||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||||||||||||||
286 | // TODO move this into a utility function in QWindow or QGuiApplication | - | ||||||||||||||||||||||||||||||||||||
287 | static QWindow *childWindowAt(QWindow *win, const QPoint &p) | - | ||||||||||||||||||||||||||||||||||||
288 | { | - | ||||||||||||||||||||||||||||||||||||
289 | foreachfor (QObject *obj ,: win->children()) { | - | ||||||||||||||||||||||||||||||||||||
290 | if (obj->isWindowType()) {
| 0-3 | ||||||||||||||||||||||||||||||||||||
291 | QWindow *childWin = static_cast<QWindow *>(obj); | - | ||||||||||||||||||||||||||||||||||||
292 | if (childWin->isVisible()) {
| 1-2 | ||||||||||||||||||||||||||||||||||||
293 | if (QWindow *recurse = childWindowAt(childWin, p))
| 0-2 | ||||||||||||||||||||||||||||||||||||
294 | return recurse; executed 2 times by 1 test: return recurse; Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||
295 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
296 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
297 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
298 | if (!win->isTopLevel()
| 1-5 | ||||||||||||||||||||||||||||||||||||
299 | && !(win->flags() & Qt::WindowTransparentForInput)
| 0-1 | ||||||||||||||||||||||||||||||||||||
300 | && win->geometry().contains(win->parent()->mapFromGlobal(p))) {
| 0-1 | ||||||||||||||||||||||||||||||||||||
301 | return win; executed 1 time by 1 test: return win; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
302 | } | - | ||||||||||||||||||||||||||||||||||||
303 | return Q_NULLPTR; executed 5 times by 3 tests: return nullptr; Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
304 | } | - | ||||||||||||||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||||||||||||||
306 | static const char *wm_window_type_property_id = "_q_xcb_wm_window_type"; | - | ||||||||||||||||||||||||||||||||||||
307 | static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; | - | ||||||||||||||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||||||||||||||
309 | QXcbWindow::QXcbWindow(QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
310 | : QPlatformWindow(window) | - | ||||||||||||||||||||||||||||||||||||
311 | , m_window(0) | - | ||||||||||||||||||||||||||||||||||||
312 | , m_syncCounter(0) | - | ||||||||||||||||||||||||||||||||||||
313 | , m_gravity(XCB_GRAVITY_STATIC) | - | ||||||||||||||||||||||||||||||||||||
314 | , m_mapped(false) | - | ||||||||||||||||||||||||||||||||||||
315 | , m_transparent(false) | - | ||||||||||||||||||||||||||||||||||||
316 | , m_usingSyncProtocol(false) | - | ||||||||||||||||||||||||||||||||||||
317 | , m_deferredActivation(false) | - | ||||||||||||||||||||||||||||||||||||
318 | , m_embedded(false) | - | ||||||||||||||||||||||||||||||||||||
319 | , m_alertState(false) | - | ||||||||||||||||||||||||||||||||||||
320 | , m_netWmUserTimeWindow(XCB_NONE) | - | ||||||||||||||||||||||||||||||||||||
321 | , m_dirtyFrameMargins(false) | - | ||||||||||||||||||||||||||||||||||||
322 | , m_lastWindowStateEvent(-1) | - | ||||||||||||||||||||||||||||||||||||
323 | , m_syncState(NoSyncNeeded) | - | ||||||||||||||||||||||||||||||||||||
324 | , m_pendingSyncRequest(0) | - | ||||||||||||||||||||||||||||||||||||
325 | , m_currentBitmapCursor(XCB_CURSOR_NONE) | - | ||||||||||||||||||||||||||||||||||||
326 | { | - | ||||||||||||||||||||||||||||||||||||
327 | setConnection(xcbScreen()->connection()); | - | ||||||||||||||||||||||||||||||||||||
328 | } | - | ||||||||||||||||||||||||||||||||||||
329 | - | |||||||||||||||||||||||||||||||||||||
330 | #ifdef Q_COMPILER_CLASS_ENUM | - | ||||||||||||||||||||||||||||||||||||
331 | enum : quint32 { | - | ||||||||||||||||||||||||||||||||||||
332 | #else | - | ||||||||||||||||||||||||||||||||||||
333 | enum { | - | ||||||||||||||||||||||||||||||||||||
334 | #endif | - | ||||||||||||||||||||||||||||||||||||
335 | baseEventMask | - | ||||||||||||||||||||||||||||||||||||
336 | = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | - | ||||||||||||||||||||||||||||||||||||
337 | | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_FOCUS_CHANGE, | - | ||||||||||||||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||||||||||||||
339 | defaultEventMask = baseEventMask | - | ||||||||||||||||||||||||||||||||||||
340 | | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | - | ||||||||||||||||||||||||||||||||||||
341 | | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | - | ||||||||||||||||||||||||||||||||||||
342 | | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | - | ||||||||||||||||||||||||||||||||||||
343 | | XCB_EVENT_MASK_POINTER_MOTION, | - | ||||||||||||||||||||||||||||||||||||
344 | - | |||||||||||||||||||||||||||||||||||||
345 | transparentForInputEventMask = baseEventMask | - | ||||||||||||||||||||||||||||||||||||
346 | | XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_RESIZE_REDIRECT | - | ||||||||||||||||||||||||||||||||||||
347 | | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | - | ||||||||||||||||||||||||||||||||||||
348 | | XCB_EVENT_MASK_COLOR_MAP_CHANGE | XCB_EVENT_MASK_OWNER_GRAB_BUTTON | - | ||||||||||||||||||||||||||||||||||||
349 | }; | - | ||||||||||||||||||||||||||||||||||||
350 | - | |||||||||||||||||||||||||||||||||||||
351 | void QXcbWindow::create() | - | ||||||||||||||||||||||||||||||||||||
352 | { | - | ||||||||||||||||||||||||||||||||||||
353 | if (window()->type() == Qt::ForeignWindow) {
| 0-4405 | ||||||||||||||||||||||||||||||||||||
354 | m_window = window()->winId(); | - | ||||||||||||||||||||||||||||||||||||
355 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
356 | } | - | ||||||||||||||||||||||||||||||||||||
357 | - | |||||||||||||||||||||||||||||||||||||
358 | destroy(); | - | ||||||||||||||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||||||||||||||
360 | m_windowState = Qt::WindowNoState; | - | ||||||||||||||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||||||||||||||
362 | Qt::WindowType type = window()->type(); | - | ||||||||||||||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||||||||||||||
364 | QXcbScreen *currentScreen = xcbScreen(); | - | ||||||||||||||||||||||||||||||||||||
365 | QRect rect = windowGeometry(); | - | ||||||||||||||||||||||||||||||||||||
366 | QXcbScreen *platformScreen = parent() ? parentScreen() : static_cast<QXcbScreen*>(screenForGeometry(rect));
| 97-4308 | ||||||||||||||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||||||||||||||
368 | if (type == Qt::Desktop) {
| 298-4107 | ||||||||||||||||||||||||||||||||||||
369 | m_window = platformScreen->root(); | - | ||||||||||||||||||||||||||||||||||||
370 | m_depth = platformScreen->screen()->root_depth; | - | ||||||||||||||||||||||||||||||||||||
371 | m_visualId = platformScreen->screen()->root_visual; | - | ||||||||||||||||||||||||||||||||||||
372 | const xcb_visualtype_t *visual = 0; | - | ||||||||||||||||||||||||||||||||||||
373 | if (connection()->hasDefaultVisualId()) {
| 0-298 | ||||||||||||||||||||||||||||||||||||
374 | visual = platformScreen->visualForId(connection()->defaultVisualId()); | - | ||||||||||||||||||||||||||||||||||||
375 | if (visual)
| 0 | ||||||||||||||||||||||||||||||||||||
376 | m_visualId = connection()->defaultVisualId(); never executed: m_visualId = connection()->defaultVisualId(); | 0 | ||||||||||||||||||||||||||||||||||||
377 | if (!visual)
| 0 | ||||||||||||||||||||||||||||||||||||
378 | qWarning() << ("Could not use default visual id. Falling back to root_visual for screen.";); never executed: QMessageLogger(__FILE__, 378, __PRETTY_FUNCTION__).warning("Could not use default visual id. Falling back to root_visual for screen."); | 0 | ||||||||||||||||||||||||||||||||||||
379 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
380 | if (!visual)
| 0-298 | ||||||||||||||||||||||||||||||||||||
381 | visual = platformScreen->visualForId(m_visualId); executed 298 times by 117 tests: visual = platformScreen->visualForId(m_visualId); Executed by:
| 298 | ||||||||||||||||||||||||||||||||||||
382 | m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask, &m_imageRgbSwap); | - | ||||||||||||||||||||||||||||||||||||
383 | connection()->addWindowEventListener(m_window, this); | - | ||||||||||||||||||||||||||||||||||||
384 | return; executed 298 times by 117 tests: return; Executed by:
| 298 | ||||||||||||||||||||||||||||||||||||
385 | } | - | ||||||||||||||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||||||||||||||
387 | const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK; | - | ||||||||||||||||||||||||||||||||||||
const quint32 values[] = { | ||||||||||||||||||||||||||||||||||||||
XCB_NONE, | ||||||||||||||||||||||||||||||||||||||
type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), | ||||||||||||||||||||||||||||||||||||||
type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, | ||||||||||||||||||||||||||||||||||||||
defaultEventMask | ||||||||||||||||||||||||||||||||||||||
};// Parameters to XCreateWindow() are frame corner + inner size. | ||||||||||||||||||||||||||||||||||||||
388 | // This fits in case position policy is frame inclusive. There is | - | ||||||||||||||||||||||||||||||||||||
389 | // currently no way to implement it for frame-exclusive geometries. | - | ||||||||||||||||||||||||||||||||||||
390 | QPlatformWindow::setGeometry(rect); | - | ||||||||||||||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||||||||||||||
392 | if (platformScreen != currentScreen)
| 0-4107 | ||||||||||||||||||||||||||||||||||||
393 | QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen()); never executed: QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen()); | 0 | ||||||||||||||||||||||||||||||||||||
394 | - | |||||||||||||||||||||||||||||||||||||
395 | const QSize minimumSize = windowMinimumSize(); | - | ||||||||||||||||||||||||||||||||||||
396 | if (rect.width() > 0 || rect.height() > 0) {
| 0-4034 | ||||||||||||||||||||||||||||||||||||
397 | rect.setWidth(qBound(1, rect.width(), XCOORD_MAX)); | - | ||||||||||||||||||||||||||||||||||||
398 | rect.setHeight(qBound(1, rect.height(), XCOORD_MAX)); | - | ||||||||||||||||||||||||||||||||||||
399 | } else if (minimumSize.width() > 0 || minimumSize.height() > 0) { executed 4034 times by 119 tests: end of block Executed by:
| 0-4034 | ||||||||||||||||||||||||||||||||||||
400 | rect.setSize(minimumSize); | - | ||||||||||||||||||||||||||||||||||||
401 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
402 | rect.setWidth(QHighDpi::toNativePixels(int(defaultWindowWidth), platformScreen->QPlatformScreen::screen())); | - | ||||||||||||||||||||||||||||||||||||
403 | rect.setHeight(QHighDpi::toNativePixels(int(defaultWindowHeight), platformScreen->QPlatformScreen::screen())); | - | ||||||||||||||||||||||||||||||||||||
404 | } executed 73 times by 13 tests: end of block Executed by:
| 73 | ||||||||||||||||||||||||||||||||||||
405 | - | |||||||||||||||||||||||||||||||||||||
406 | xcb_window_t xcb_parent_id = platformScreen->root(); | - | ||||||||||||||||||||||||||||||||||||
407 | if (parent()) {
| 97-4010 | ||||||||||||||||||||||||||||||||||||
408 | xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window(); | - | ||||||||||||||||||||||||||||||||||||
409 | m_embedded = parent()->window()->type() == Qt::ForeignWindow; | - | ||||||||||||||||||||||||||||||||||||
410 | - | |||||||||||||||||||||||||||||||||||||
411 | QSurfaceFormat parentFormat = parent()->window()->requestedFormat(); | - | ||||||||||||||||||||||||||||||||||||
412 | if (window()->surfaceType() != QSurface::OpenGLSurface && parentFormat.hasAlpha()) {
| 0-97 | ||||||||||||||||||||||||||||||||||||
413 | window()->setFormat(parentFormat); | - | ||||||||||||||||||||||||||||||||||||
414 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
415 | } executed 97 times by 6 tests: end of block Executed by:
| 97 | ||||||||||||||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||||||||||||||
417 | resolveFormat(); | - | ||||||||||||||||||||||||||||||||||||
#ifdef XCB_USE_XLIB | ||||||||||||||||||||||||||||||||||||||
if(platformScreen->surfaceFormatFor(window()->surfaceType() != QSurface::RasterSurface | ||||||||||||||||||||||||||||||||||||||
&& QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { | ||||||||||||||||||||||||||||||||||||||
XVisualInforequestedFormat())); | ||||||||||||||||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||||||||||||||
419 | const xcb_visualtype_t *visualInfovisual = Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
420 | - | |||||||||||||||||||||||||||||||||||||
421 | if (connection()->hasDefaultVisualId()) visualInfo{
| 0-4107 | ||||||||||||||||||||||||||||||||||||
422 | visual = CREATE_VISUALINFO_FROM_DEFAULT_VISUALIDplatformScreen->visualForId(this); | - | ||||||||||||||||||||||||||||||||||||
if (!visualInfo) | ||||||||||||||||||||||||||||||||||||||
visualInfo = static_cast<XVisualInfo *>(createVisualconnection()->defaultVisualId()); | ||||||||||||||||||||||||||||||||||||||
423 | if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurfacevisual)
| 0 | ||||||||||||||||||||||||||||||||||||
424 | qFatal("CouldqWarning() << not"Failed initializeto OpenGL");use requested visual id."; never executed: QMessageLogger(__FILE__, 424, __PRETTY_FUNCTION__).warning() << "Failed to use requested visual id."; | 0 | ||||||||||||||||||||||||||||||||||||
425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
426 | - | |||||||||||||||||||||||||||||||||||||
427 | if (!visualInfo && window()->surfaceType() == QSurface::RasterGLSurfacevisual)
| 0-4107 | ||||||||||||||||||||||||||||||||||||
428 | visual = createVisual(); executed 4107 times by 125 tests: visual = createVisual(); Executed by:
| 4107 | ||||||||||||||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||||||||||||||
430 | if (!visual
| 0-4107 | ||||||||||||||||||||||||||||||||||||
431 | qWarning("Could not initialize() << OpenGL"Falling forback RasterGLSurface,to revertingusing toscreens RasterSurfaceroot_visual."); | - | ||||||||||||||||||||||||||||||||||||
window()->setSurfaceType(QSurface::RasterSurface); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
if (visualInfo) { | ||||||||||||||||||||||||||||||||||||||
m_depth = visualInfo->depth; | ||||||||||||||||||||||||||||||||||||||
432 | m_imageFormatvisual = imageFormatForVisual(visualInfo->depth, visualInfoplatformScreen->red_mask, visualInfovisualForId(platformScreen->blue_mask, &m_imageRgbSwapscreen()->root_visual); | - | ||||||||||||||||||||||||||||||||||||
433 | Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB} never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||||||||||||||
435 | Q_ASSERT(this), xcb_parent_id, visualInfo->visual, AllocNone); | - | ||||||||||||||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||||||||||||||
437 | XSetWindowAttributes a; | - | ||||||||||||||||||||||||||||||||||||
a.background_pixelm_visualId = WhitePixel(DISPLAY_FROM_XCB(this), platformScreenvisual->screenNumber()); | ||||||||||||||||||||||||||||||||||||||
a.border_pixelvisual_id; | ||||||||||||||||||||||||||||||||||||||
438 | m_depth = BlackPixel(DISPLAY_FROM_XCB(this),platformScreen->screenNumber()); | - | ||||||||||||||||||||||||||||||||||||
a.colormap = cmap;depthOfVisual(m_visualId= visualInfo->visualid; | ||||||||||||||||||||||||||||||||||||||
m_window); | ||||||||||||||||||||||||||||||||||||||
439 | m_imageFormat = XCreateWindow(DISPLAY_FROM_XCBimageFormatForVisual(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(), | - | ||||||||||||||||||||||||||||||||||||
0m_depth, visualInfovisual->depth, InputOutputred_mask, visualInfo->visual, | ||||||||||||||||||||||||||||||||||||||
CWBackPixel|CWBorderPixel|CWColormap->blue_mask, &a); | ||||||||||||||||||||||||||||||||||||||
XFree(visualInfo&m_imageRgbSwap); | ||||||||||||||||||||||||||||||||||||||
440 | } | - | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||||||||||
if (!m_window) | ||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||
m_window = xcb_generate_id(xcb_connection()); | ||||||||||||||||||||||||||||||||||||||
m_visualId = UINT_MAX; | ||||||||||||||||||||||||||||||||||||||
const xcb_visualtype_t *visual = Q_NULLPTR; | ||||||||||||||||||||||||||||||||||||||
m_depthxcb_colormap_t colormap = platformScreen->screen()->root_depth0; | ||||||||||||||||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||||||||||||||
442 | uint32_tquint32 mask = 0XCB_CW_BACK_PIXMAP | - | ||||||||||||||||||||||||||||||||||||
443 | | XCB_CW_BORDER_PIXEL | - | ||||||||||||||||||||||||||||||||||||
444 | | XCB_CW_BIT_GRAVITY | - | ||||||||||||||||||||||||||||||||||||
445 | | XCB_CW_OVERRIDE_REDIRECT | - | ||||||||||||||||||||||||||||||||||||
446 | | XCB_CW_SAVE_UNDER | - | ||||||||||||||||||||||||||||||||||||
447 | | XCB_CW_EVENT_MASK; | - | ||||||||||||||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||||||||||||||
449 | uint32_t values[3]; | - | ||||||||||||||||||||||||||||||||||||
if (connection()->hasDefaultVisualId()) { | ||||||||||||||||||||||||||||||||||||||
m_visualIdstatic const bool haveOpenGL = connectionQGuiApplicationPrivate::platformIntegration()->defaultVisualId(); | ||||||||||||||||||||||||||||||||||||||
visual = platformScreen->visualForIdhasCapability(m_visualIdQPlatformIntegration::OpenGL); | ||||||||||||||||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||||||||||||||
451 | }
| 0-3974 | ||||||||||||||||||||||||||||||||||||
if (!visual) {
| ||||||||||||||||||||||||||||||||||||||
qWarning("Failed to use default visual id. Falling back to using screens root_visual");
| ||||||||||||||||||||||||||||||||||||||
m_visualId = platformScreen->screen
| ||||||||||||||||||||||||||||||||||||||
if (m_format.alphaBufferSize
| ||||||||||||||||||||||||||||||||||||||
xcb_depth_iterator_t depthIter = xcb_screen_allowed_depths_iterator(platformScreen->screen());
| ||||||||||||||||||||||||||||||||||||||
while (depthIter.rem) {
| ||||||||||||||||||||||||||||||||||||||
if (depthIter.data->depth == 32
| ||||||||||||||||||||||||||||||||||||||
xcb_visualtype_iterator_t visualIter = xcb_depth_visuals_iterator(depthIter.data);
| ||||||||||||||||||||||||||||||||||||||
if (visualIter
| ||||||||||||||||||||||||||||||||||||||
452 | m_visualId = visualIter.data->visual_id; | - | ||||||||||||||||||||||||||||||||||||
m_depth = 32; | ||||||||||||||||||||||||||||||||||||||
uint32_tcolormap = xcb_generate_id(xcb_connection()); | ||||||||||||||||||||||||||||||||||||||
453 | Q_XCB_CALL(xcb_create_colormap(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
454 | XCB_COLORMAP_ALLOC_NONE, | - | ||||||||||||||||||||||||||||||||||||
455 | colormap, | - | ||||||||||||||||||||||||||||||||||||
456 | xcb_parent_id, | - | ||||||||||||||||||||||||||||||||||||
457 | m_visualId);)); | - | ||||||||||||||||||||||||||||||||||||
458 | - | |||||||||||||||||||||||||||||||||||||
459 | mask |= XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL |XCB_CW_COLORMAP; | - | ||||||||||||||||||||||||||||||||||||
values[0] = platformScreen->screen()->white_pixel; | ||||||||||||||||||||||||||||||||||||||
460 | } executed 3974 times by 118 tests: end of block Executed by:
| 3974 | ||||||||||||||||||||||||||||||||||||
461 | - | |||||||||||||||||||||||||||||||||||||
462 | quint32 values[1][] = { | - | ||||||||||||||||||||||||||||||||||||
463 | XCB_BACK_PIXMAP_NONE, | - | ||||||||||||||||||||||||||||||||||||
464 | platformScreen->screen()->black_pixel; | - | ||||||||||||||||||||||||||||||||||||
values[2] = colormap; | ||||||||||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
xcb_depth_next(&depthIter); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
visual = platformScreen->visualForId(m_visualId); | ||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||
m_imageFormat = imageFormatForVisual(m_depth, | ||||||||||||||||||||||||||||||||||||||
465 | visual->red_maskXCB_GRAVITY_NORTH_WEST, | - | ||||||||||||||||||||||||||||||||||||
466 | visual->blue_masktype == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), | - | ||||||||||||||||||||||||||||||||||||
467 | type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, | - | ||||||||||||||||||||||||||||||||||||
468 | &m_imageRgbSwap);defaultEventMask, | - | ||||||||||||||||||||||||||||||||||||
469 | colormap | - | ||||||||||||||||||||||||||||||||||||
470 | }; | - | ||||||||||||||||||||||||||||||||||||
471 | - | |||||||||||||||||||||||||||||||||||||
472 | m_window = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
473 | Q_XCB_CALL(xcb_create_window(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
474 | m_depth, | - | ||||||||||||||||||||||||||||||||||||
475 | m_window, // window id | - | ||||||||||||||||||||||||||||||||||||
476 | xcb_parent_id, // parent window id | - | ||||||||||||||||||||||||||||||||||||
477 | rect.x(), | - | ||||||||||||||||||||||||||||||||||||
478 | rect.y(), | - | ||||||||||||||||||||||||||||||||||||
479 | rect.width(), | - | ||||||||||||||||||||||||||||||||||||
480 | rect.height(), | - | ||||||||||||||||||||||||||||||||||||
481 | 0, // border width | - | ||||||||||||||||||||||||||||||||||||
482 | XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class | - | ||||||||||||||||||||||||||||||||||||
483 | m_visualId, // visual | - | ||||||||||||||||||||||||||||||||||||
484 | mask, | - | ||||||||||||||||||||||||||||||||||||
485 | values)); | - | ||||||||||||||||||||||||||||||||||||
486 | - | |||||||||||||||||||||||||||||||||||||
487 | }connection()->addWindowEventListener(m_window, this); | - | ||||||||||||||||||||||||||||||||||||
488 | - | |||||||||||||||||||||||||||||||||||||
489 | Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); | - | ||||||||||||||||||||||||||||||||||||
490 | - | |||||||||||||||||||||||||||||||||||||
491 | propagateSizeHints(); | - | ||||||||||||||||||||||||||||||||||||
492 | - | |||||||||||||||||||||||||||||||||||||
493 | xcb_atom_t properties[5]; | - | ||||||||||||||||||||||||||||||||||||
494 | int propertyCount = 0; | - | ||||||||||||||||||||||||||||||||||||
495 | properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW); | - | ||||||||||||||||||||||||||||||||||||
496 | properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); | - | ||||||||||||||||||||||||||||||||||||
497 | properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); | - | ||||||||||||||||||||||||||||||||||||
498 | - | |||||||||||||||||||||||||||||||||||||
499 | m_usingSyncProtocol = platformScreen->syncRequestSupported(); | - | ||||||||||||||||||||||||||||||||||||
500 | - | |||||||||||||||||||||||||||||||||||||
501 | if (m_usingSyncProtocol)
| 0-4107 | ||||||||||||||||||||||||||||||||||||
502 | properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); executed 4107 times by 125 tests: properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); Executed by:
| 4107 | ||||||||||||||||||||||||||||||||||||
503 | - | |||||||||||||||||||||||||||||||||||||
504 | if (window()->flags() & Qt::WindowContextHelpButtonHint)
| 223-3884 | ||||||||||||||||||||||||||||||||||||
505 | properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); executed 223 times by 25 tests: properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); Executed by:
| 223 | ||||||||||||||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||||||||||||||
507 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
508 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
509 | m_window, | - | ||||||||||||||||||||||||||||||||||||
510 | atom(QXcbAtom::WM_PROTOCOLS), | - | ||||||||||||||||||||||||||||||||||||
511 | XCB_ATOM_ATOM, | - | ||||||||||||||||||||||||||||||||||||
512 | 32, | - | ||||||||||||||||||||||||||||||||||||
513 | propertyCount, | - | ||||||||||||||||||||||||||||||||||||
514 | properties)); | - | ||||||||||||||||||||||||||||||||||||
515 | m_syncValue.hi = 0; | - | ||||||||||||||||||||||||||||||||||||
516 | m_syncValue.lo = 0; | - | ||||||||||||||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||||||||||||||
518 | const QByteArray wmClass = QXcbIntegration::instance()->wmClass(); | - | ||||||||||||||||||||||||||||||||||||
519 | if (!wmClass.isEmpty()) {
| 51-4056 | ||||||||||||||||||||||||||||||||||||
520 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
521 | m_window, atom(QXcbAtom::WM_CLASS), | - | ||||||||||||||||||||||||||||||||||||
522 | XCB_ATOM_STRING, 8, wmClass.size(), wmClass.constData())); | - | ||||||||||||||||||||||||||||||||||||
523 | } executed 4056 times by 125 tests: end of block Executed by:
| 4056 | ||||||||||||||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||||||||||||||
525 | if (m_usingSyncProtocol) {
| 0-4107 | ||||||||||||||||||||||||||||||||||||
526 | m_syncCounter = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
527 | Q_XCB_CALL(xcb_sync_create_counter(xcb_connection(), m_syncCounter, m_syncValue)); | - | ||||||||||||||||||||||||||||||||||||
528 | - | |||||||||||||||||||||||||||||||||||||
529 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
530 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
531 | m_window, | - | ||||||||||||||||||||||||||||||||||||
532 | atom(QXcbAtom::_NET_WM_SYNC_REQUEST_COUNTER), | - | ||||||||||||||||||||||||||||||||||||
533 | XCB_ATOM_CARDINAL, | - | ||||||||||||||||||||||||||||||||||||
534 | 32, | - | ||||||||||||||||||||||||||||||||||||
535 | 1, | - | ||||||||||||||||||||||||||||||||||||
536 | &m_syncCounter)); | - | ||||||||||||||||||||||||||||||||||||
537 | } executed 4107 times by 125 tests: end of block Executed by:
| 4107 | ||||||||||||||||||||||||||||||||||||
538 | - | |||||||||||||||||||||||||||||||||||||
539 | // set the PID to let the WM kill the application if unresponsive | - | ||||||||||||||||||||||||||||||||||||
540 | quint32 pid = getpid(); | - | ||||||||||||||||||||||||||||||||||||
541 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
542 | atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32, | - | ||||||||||||||||||||||||||||||||||||
543 | 1, &pid)); | - | ||||||||||||||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||||||||||||||
545 | xcb_wm_hints_t hints; | - | ||||||||||||||||||||||||||||||||||||
546 | memset(&hints, 0, sizeof(hints)); | - | ||||||||||||||||||||||||||||||||||||
547 | xcb_wm_hints_set_normal(&hints); | - | ||||||||||||||||||||||||||||||||||||
548 | - | |||||||||||||||||||||||||||||||||||||
549 | xcb_wm_hints_set_input(&hints, !(window()->flags() & Qt::WindowDoesNotAcceptFocus)); | - | ||||||||||||||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||||||||||||||
551 | xcb_set_wm_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||||||||||||||
553 | xcb_window_t leader = connection()->clientLeader(); | - | ||||||||||||||||||||||||||||||||||||
554 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
555 | atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, | - | ||||||||||||||||||||||||||||||||||||
556 | 1, &leader)); | - | ||||||||||||||||||||||||||||||||||||
557 | - | |||||||||||||||||||||||||||||||||||||
558 | /* Add XEMBED info; this operation doesn't initiate the embedding. */ | - | ||||||||||||||||||||||||||||||||||||
559 | quint32 data[] = { XEMBED_VERSION, XEMBED_MAPPED }; | - | ||||||||||||||||||||||||||||||||||||
560 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
561 | atom(QXcbAtom::_XEMBED_INFO), | - | ||||||||||||||||||||||||||||||||||||
562 | atom(QXcbAtom::_XEMBED_INFO), | - | ||||||||||||||||||||||||||||||||||||
563 | 32, 2, (void *)data)); | - | ||||||||||||||||||||||||||||||||||||
564 | - | |||||||||||||||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||||||||||||||
566 | #if defined(XCB_USE_XINPUT2) | - | ||||||||||||||||||||||||||||||||||||
567 | connection()->xi2Select(m_window); | - | ||||||||||||||||||||||||||||||||||||
568 | #endif | - | ||||||||||||||||||||||||||||||||||||
569 | - | |||||||||||||||||||||||||||||||||||||
570 | setWindowState(window()->windowState()); | - | ||||||||||||||||||||||||||||||||||||
571 | setWindowFlags(window()->flags()); | - | ||||||||||||||||||||||||||||||||||||
572 | setWindowTitle(window()->title()); | - | ||||||||||||||||||||||||||||||||||||
573 | - | |||||||||||||||||||||||||||||||||||||
574 | if (window()->flags() & Qt::WindowTransparentForInput)
| 1-4106 | ||||||||||||||||||||||||||||||||||||
575 | setTransparentForMouseEvents(true); executed 1 time by 1 test: setTransparentForMouseEvents(true); Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
576 | - | |||||||||||||||||||||||||||||||||||||
577 | #ifdef XCB_USE_XLIB | - | ||||||||||||||||||||||||||||||||||||
578 | // force sync to read outstanding requests - see QTBUG-29106 | - | ||||||||||||||||||||||||||||||||||||
579 | XSync(DISPLAY_FROM_XCB(platformScreen), false); | - | ||||||||||||||||||||||||||||||||||||
580 | #endif | - | ||||||||||||||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||||||||||||||
582 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
583 | connection()->drag()->dndEnable(this, true); | - | ||||||||||||||||||||||||||||||||||||
584 | #endif | - | ||||||||||||||||||||||||||||||||||||
585 | - | |||||||||||||||||||||||||||||||||||||
586 | const qreal opacity = qt_window_private(window())->opacity; | - | ||||||||||||||||||||||||||||||||||||
587 | if (!qFuzzyCompare(opacity, qreal(1.0)))
| 0-4107 | ||||||||||||||||||||||||||||||||||||
588 | setOpacity(opacity); never executed: setOpacity(opacity); | 0 | ||||||||||||||||||||||||||||||||||||
589 | if (window()->isTopLevel())
| 97-4010 | ||||||||||||||||||||||||||||||||||||
590 | setWindowIcon(window()->icon()); executed 4010 times by 125 tests: setWindowIcon(window()->icon()); Executed by:
| 4010 | ||||||||||||||||||||||||||||||||||||
591 | - | |||||||||||||||||||||||||||||||||||||
592 | if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) {
| 0-4107 | ||||||||||||||||||||||||||||||||||||
593 | QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray(); | - | ||||||||||||||||||||||||||||||||||||
594 | setWmWindowRole(wmWindowRole); | - | ||||||||||||||||||||||||||||||||||||
595 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
596 | } executed 4107 times by 125 tests: end of block Executed by:
| 4107 | ||||||||||||||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||||||||||||||
598 | QXcbWindow::~QXcbWindow() | - | ||||||||||||||||||||||||||||||||||||
599 | { | - | ||||||||||||||||||||||||||||||||||||
600 | if (m_currentBitmapCursor != XCB_CURSOR_NONE) { | - | ||||||||||||||||||||||||||||||||||||
601 | xcb_free_cursor(xcb_connection(), m_currentBitmapCursor); | - | ||||||||||||||||||||||||||||||||||||
602 | } | - | ||||||||||||||||||||||||||||||||||||
603 | if (window()->type() != Qt::ForeignWindow) | - | ||||||||||||||||||||||||||||||||||||
604 | destroy(); | - | ||||||||||||||||||||||||||||||||||||
605 | else { | - | ||||||||||||||||||||||||||||||||||||
606 | if (connection()->mouseGrabber() == this) | - | ||||||||||||||||||||||||||||||||||||
607 | connection()->setMouseGrabber(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
608 | if (connection()->mousePressWindow() == this) | - | ||||||||||||||||||||||||||||||||||||
609 | connection()->setMousePressWindow(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
610 | } | - | ||||||||||||||||||||||||||||||||||||
611 | } | - | ||||||||||||||||||||||||||||||||||||
612 | - | |||||||||||||||||||||||||||||||||||||
613 | void QXcbWindow::destroy() | - | ||||||||||||||||||||||||||||||||||||
614 | { | - | ||||||||||||||||||||||||||||||||||||
615 | if (connection()->focusWindow() == this) | - | ||||||||||||||||||||||||||||||||||||
616 | doFocusOut(); | - | ||||||||||||||||||||||||||||||||||||
617 | if (connection()->mouseGrabber() == this) | - | ||||||||||||||||||||||||||||||||||||
618 | connection()->setMouseGrabber(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
619 | - | |||||||||||||||||||||||||||||||||||||
620 | if (m_syncCounter && m_usingSyncProtocol) | - | ||||||||||||||||||||||||||||||||||||
621 | Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter)); | - | ||||||||||||||||||||||||||||||||||||
622 | if (m_window) { | - | ||||||||||||||||||||||||||||||||||||
623 | if (m_netWmUserTimeWindow) { | - | ||||||||||||||||||||||||||||||||||||
624 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); | - | ||||||||||||||||||||||||||||||||||||
625 | // Some window managers, like metacity, do XSelectInput on the _NET_WM_USER_TIME_WINDOW window, | - | ||||||||||||||||||||||||||||||||||||
626 | // without trapping BadWindow (which crashes when the user time window is destroyed). | - | ||||||||||||||||||||||||||||||||||||
627 | connection()->sync(); | - | ||||||||||||||||||||||||||||||||||||
628 | xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow); | - | ||||||||||||||||||||||||||||||||||||
629 | m_netWmUserTimeWindow = XCB_NONE; | - | ||||||||||||||||||||||||||||||||||||
630 | } | - | ||||||||||||||||||||||||||||||||||||
631 | connection()->removeWindowEventListener(m_window); | - | ||||||||||||||||||||||||||||||||||||
632 | Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); | - | ||||||||||||||||||||||||||||||||||||
633 | m_window = 0; | - | ||||||||||||||||||||||||||||||||||||
634 | } | - | ||||||||||||||||||||||||||||||||||||
635 | m_mapped = false; | - | ||||||||||||||||||||||||||||||||||||
636 | - | |||||||||||||||||||||||||||||||||||||
637 | if (m_pendingSyncRequest) | - | ||||||||||||||||||||||||||||||||||||
638 | m_pendingSyncRequest->invalidate(); | - | ||||||||||||||||||||||||||||||||||||
639 | } | - | ||||||||||||||||||||||||||||||||||||
640 | - | |||||||||||||||||||||||||||||||||||||
641 | void QXcbWindow::setGeometry(const QRect &rect) | - | ||||||||||||||||||||||||||||||||||||
642 | { | - | ||||||||||||||||||||||||||||||||||||
643 | QPlatformWindow::setGeometry(rect); | - | ||||||||||||||||||||||||||||||||||||
644 | - | |||||||||||||||||||||||||||||||||||||
645 | propagateSizeHints(); | - | ||||||||||||||||||||||||||||||||||||
646 | - | |||||||||||||||||||||||||||||||||||||
647 | QXcbScreen *currentScreen = xcbScreen(); | - | ||||||||||||||||||||||||||||||||||||
648 | QXcbScreen *newScreen = parent() ? parentScreen() : static_cast<QXcbScreen*>(screenForGeometry(rect));
| 43-2810 | ||||||||||||||||||||||||||||||||||||
649 | - | |||||||||||||||||||||||||||||||||||||
650 | if (!newScreen)
| 0-2853 | ||||||||||||||||||||||||||||||||||||
651 | newScreen = xcbScreen(); never executed: newScreen = xcbScreen(); | 0 | ||||||||||||||||||||||||||||||||||||
652 | - | |||||||||||||||||||||||||||||||||||||
653 | const QRect wmGeometry = windowToWmGeometry(rect); | - | ||||||||||||||||||||||||||||||||||||
654 | - | |||||||||||||||||||||||||||||||||||||
655 | if (newScreen &&newScreen != currentScreen)
| 0-2853 | ||||||||||||||||||||||||||||||||||||
656 | QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); never executed: QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen()); | 0 | ||||||||||||||||||||||||||||||||||||
657 | - | |||||||||||||||||||||||||||||||||||||
658 | if (qt_window_private(window())->positionAutomatic) {
| 1074-1779 | ||||||||||||||||||||||||||||||||||||
659 | const quint32 mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; | - | ||||||||||||||||||||||||||||||||||||
660 | const qint32 values[] = { | - | ||||||||||||||||||||||||||||||||||||
661 | qBound<qint32>(1, wmGeometry.width(), XCOORD_MAX), | - | ||||||||||||||||||||||||||||||||||||
662 | qBound<qint32>(1, wmGeometry.height(), XCOORD_MAX), | - | ||||||||||||||||||||||||||||||||||||
663 | }; | - | ||||||||||||||||||||||||||||||||||||
664 | Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast<const quint32*>(values))); | - | ||||||||||||||||||||||||||||||||||||
665 | } else { executed 1779 times by 86 tests: end of block Executed by:
| 1779 | ||||||||||||||||||||||||||||||||||||
666 | const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; | - | ||||||||||||||||||||||||||||||||||||
667 | const qint32 values[] = { | - | ||||||||||||||||||||||||||||||||||||
668 | qBound<qint32>(-XCOORD_MAX, wmGeometry.x(), XCOORD_MAX), | - | ||||||||||||||||||||||||||||||||||||
669 | qBound<qint32>(-XCOORD_MAX, wmGeometry.y(), XCOORD_MAX), | - | ||||||||||||||||||||||||||||||||||||
670 | qBound<qint32>(1, wmGeometry.width(), XCOORD_MAX), | - | ||||||||||||||||||||||||||||||||||||
671 | qBound<qint32>(1, wmGeometry.height(), XCOORD_MAX), | - | ||||||||||||||||||||||||||||||||||||
672 | }; | - | ||||||||||||||||||||||||||||||||||||
673 | Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast<const quint32*>(values))); | - | ||||||||||||||||||||||||||||||||||||
674 | } executed 1074 times by 69 tests: end of block Executed by:
| 1074 | ||||||||||||||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||||||||||||||
676 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
677 | } executed 2853 times by 106 tests: end of block Executed by:
| 2853 | ||||||||||||||||||||||||||||||||||||
678 | - | |||||||||||||||||||||||||||||||||||||
679 | QMargins QXcbWindow::frameMargins() const | - | ||||||||||||||||||||||||||||||||||||
680 | { | - | ||||||||||||||||||||||||||||||||||||
681 | if (m_dirtyFrameMargins) { | - | ||||||||||||||||||||||||||||||||||||
682 | if (connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_FRAME_EXTENTS))) { | - | ||||||||||||||||||||||||||||||||||||
683 | xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, m_window, | - | ||||||||||||||||||||||||||||||||||||
684 | atom(QXcbAtom::_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4); | - | ||||||||||||||||||||||||||||||||||||
685 | QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply( | - | ||||||||||||||||||||||||||||||||||||
686 | xcb_get_property_reply(xcb_connection(), cookie, NULL)); | - | ||||||||||||||||||||||||||||||||||||
687 | if (reply && reply->type == XCB_ATOM_CARDINAL && reply->format == 32 && reply->value_len == 4) { | - | ||||||||||||||||||||||||||||||||||||
688 | quint32 *data = (quint32 *)xcb_get_property_value(reply.data()); | - | ||||||||||||||||||||||||||||||||||||
689 | // _NET_FRAME_EXTENTS format is left, right, top, bottom | - | ||||||||||||||||||||||||||||||||||||
690 | m_frameMargins = QMargins(data[0], data[2], data[1], data[3]); | - | ||||||||||||||||||||||||||||||||||||
691 | m_dirtyFrameMargins = false; | - | ||||||||||||||||||||||||||||||||||||
692 | return m_frameMargins; | - | ||||||||||||||||||||||||||||||||||||
693 | } | - | ||||||||||||||||||||||||||||||||||||
694 | } | - | ||||||||||||||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||||||||||||||
696 | // _NET_FRAME_EXTENTS property is not available, so | - | ||||||||||||||||||||||||||||||||||||
697 | // walk up the window tree to get the frame parent | - | ||||||||||||||||||||||||||||||||||||
698 | xcb_window_t window = m_window; | - | ||||||||||||||||||||||||||||||||||||
699 | xcb_window_t parent = m_window; | - | ||||||||||||||||||||||||||||||||||||
700 | - | |||||||||||||||||||||||||||||||||||||
701 | bool foundRoot = false; | - | ||||||||||||||||||||||||||||||||||||
702 | - | |||||||||||||||||||||||||||||||||||||
703 | const QVector<xcb_window_t> &virtualRoots = | - | ||||||||||||||||||||||||||||||||||||
704 | connection()->wmSupport()->virtualRoots(); | - | ||||||||||||||||||||||||||||||||||||
705 | - | |||||||||||||||||||||||||||||||||||||
706 | while (!foundRoot) { | - | ||||||||||||||||||||||||||||||||||||
707 | xcb_query_tree_cookie_t cookie = xcb_query_tree_unchecked(xcb_connection(), parent); | - | ||||||||||||||||||||||||||||||||||||
708 | - | |||||||||||||||||||||||||||||||||||||
709 | xcb_query_tree_reply_t *reply = xcb_query_tree_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
710 | if (reply) { | - | ||||||||||||||||||||||||||||||||||||
711 | if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1 || reply->parent == XCB_WINDOW_NONE) { | - | ||||||||||||||||||||||||||||||||||||
712 | foundRoot = true; | - | ||||||||||||||||||||||||||||||||||||
713 | } else { | - | ||||||||||||||||||||||||||||||||||||
714 | window = parent; | - | ||||||||||||||||||||||||||||||||||||
715 | parent = reply->parent; | - | ||||||||||||||||||||||||||||||||||||
716 | } | - | ||||||||||||||||||||||||||||||||||||
717 | - | |||||||||||||||||||||||||||||||||||||
718 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
719 | } else { | - | ||||||||||||||||||||||||||||||||||||
720 | m_dirtyFrameMargins = false; | - | ||||||||||||||||||||||||||||||||||||
721 | m_frameMargins = QMargins(); | - | ||||||||||||||||||||||||||||||||||||
722 | return m_frameMargins; | - | ||||||||||||||||||||||||||||||||||||
723 | } | - | ||||||||||||||||||||||||||||||||||||
724 | } | - | ||||||||||||||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||||||||||||||
726 | QPoint offset; | - | ||||||||||||||||||||||||||||||||||||
727 | - | |||||||||||||||||||||||||||||||||||||
728 | xcb_translate_coordinates_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
729 | xcb_translate_coordinates_reply( | - | ||||||||||||||||||||||||||||||||||||
730 | xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
731 | xcb_translate_coordinates(xcb_connection(), window, parent, 0, 0), | - | ||||||||||||||||||||||||||||||||||||
732 | NULL); | - | ||||||||||||||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||||||||||||||
734 | if (reply) { | - | ||||||||||||||||||||||||||||||||||||
735 | offset = QPoint(reply->dst_x, reply->dst_y); | - | ||||||||||||||||||||||||||||||||||||
736 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
737 | } | - | ||||||||||||||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||||||||||||||
739 | xcb_get_geometry_reply_t *geom = | - | ||||||||||||||||||||||||||||||||||||
740 | xcb_get_geometry_reply( | - | ||||||||||||||||||||||||||||||||||||
741 | xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
742 | xcb_get_geometry(xcb_connection(), parent), | - | ||||||||||||||||||||||||||||||||||||
743 | NULL); | - | ||||||||||||||||||||||||||||||||||||
744 | - | |||||||||||||||||||||||||||||||||||||
745 | if (geom) { | - | ||||||||||||||||||||||||||||||||||||
746 | // -- | - | ||||||||||||||||||||||||||||||||||||
747 | // add the border_width for the window managers frame... some window managers | - | ||||||||||||||||||||||||||||||||||||
748 | // do not use a border_width of zero for their frames, and if we the left and | - | ||||||||||||||||||||||||||||||||||||
749 | // top strut, we ensure that pos() is absolutely correct. frameGeometry() | - | ||||||||||||||||||||||||||||||||||||
750 | // will still be incorrect though... perhaps i should have foffset as well, to | - | ||||||||||||||||||||||||||||||||||||
751 | // indicate the frame offset (equal to the border_width on X). | - | ||||||||||||||||||||||||||||||||||||
752 | // - Brad | - | ||||||||||||||||||||||||||||||||||||
753 | // -- copied from qwidget_x11.cpp | - | ||||||||||||||||||||||||||||||||||||
754 | - | |||||||||||||||||||||||||||||||||||||
755 | int left = offset.x() + geom->border_width; | - | ||||||||||||||||||||||||||||||||||||
756 | int top = offset.y() + geom->border_width; | - | ||||||||||||||||||||||||||||||||||||
757 | int right = geom->width + geom->border_width - geometry().width() - offset.x(); | - | ||||||||||||||||||||||||||||||||||||
758 | int bottom = geom->height + geom->border_width - geometry().height() - offset.y(); | - | ||||||||||||||||||||||||||||||||||||
759 | - | |||||||||||||||||||||||||||||||||||||
760 | m_frameMargins = QMargins(left, top, right, bottom); | - | ||||||||||||||||||||||||||||||||||||
761 | - | |||||||||||||||||||||||||||||||||||||
762 | free(geom); | - | ||||||||||||||||||||||||||||||||||||
763 | } | - | ||||||||||||||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||||||||||||||
765 | m_dirtyFrameMargins = false; | - | ||||||||||||||||||||||||||||||||||||
766 | } | - | ||||||||||||||||||||||||||||||||||||
767 | - | |||||||||||||||||||||||||||||||||||||
768 | return m_frameMargins; | - | ||||||||||||||||||||||||||||||||||||
769 | } | - | ||||||||||||||||||||||||||||||||||||
770 | - | |||||||||||||||||||||||||||||||||||||
771 | void QXcbWindow::setVisible(bool visible) | - | ||||||||||||||||||||||||||||||||||||
772 | { | - | ||||||||||||||||||||||||||||||||||||
773 | if (visible) | - | ||||||||||||||||||||||||||||||||||||
774 | show(); | - | ||||||||||||||||||||||||||||||||||||
775 | else | - | ||||||||||||||||||||||||||||||||||||
776 | hide(); | - | ||||||||||||||||||||||||||||||||||||
777 | } | - | ||||||||||||||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||||||||||||||
779 | static inline bool testShowWithoutActivating(const QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
780 | { | - | ||||||||||||||||||||||||||||||||||||
781 | // QWidget-attribute Qt::WA_ShowWithoutActivating. | - | ||||||||||||||||||||||||||||||||||||
782 | const QVariant showWithoutActivating = window->property("_q_showWithoutActivating"); | - | ||||||||||||||||||||||||||||||||||||
783 | return showWithoutActivating.isValid() && showWithoutActivating.toBool(); | - | ||||||||||||||||||||||||||||||||||||
784 | } | - | ||||||||||||||||||||||||||||||||||||
785 | - | |||||||||||||||||||||||||||||||||||||
786 | void QXcbWindow::show() | - | ||||||||||||||||||||||||||||||||||||
787 | { | - | ||||||||||||||||||||||||||||||||||||
788 | if (window()->isTopLevel()) { | - | ||||||||||||||||||||||||||||||||||||
789 | xcb_get_property_cookie_t cookie = xcb_get_wm_hints_unchecked(xcb_connection(), m_window); | - | ||||||||||||||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||||||||||||||
791 | xcb_wm_hints_t hints; | - | ||||||||||||||||||||||||||||||||||||
792 | xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, NULL); | - | ||||||||||||||||||||||||||||||||||||
793 | - | |||||||||||||||||||||||||||||||||||||
794 | if (window()->windowState() & Qt::WindowMinimized) | - | ||||||||||||||||||||||||||||||||||||
795 | xcb_wm_hints_set_iconic(&hints); | - | ||||||||||||||||||||||||||||||||||||
796 | else | - | ||||||||||||||||||||||||||||||||||||
797 | xcb_wm_hints_set_normal(&hints); | - | ||||||||||||||||||||||||||||||||||||
798 | - | |||||||||||||||||||||||||||||||||||||
799 | xcb_wm_hints_set_input(&hints, !(window()->flags() & Qt::WindowDoesNotAcceptFocus)); | - | ||||||||||||||||||||||||||||||||||||
800 | - | |||||||||||||||||||||||||||||||||||||
801 | xcb_set_wm_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||||||||||||||||||||
802 | - | |||||||||||||||||||||||||||||||||||||
803 | m_gravity = positionIncludesFrame(window()) ? | - | ||||||||||||||||||||||||||||||||||||
804 | XCB_GRAVITY_NORTH_WEST : XCB_GRAVITY_STATIC; | - | ||||||||||||||||||||||||||||||||||||
805 | - | |||||||||||||||||||||||||||||||||||||
806 | // update WM_NORMAL_HINTS | - | ||||||||||||||||||||||||||||||||||||
807 | propagateSizeHints(); | - | ||||||||||||||||||||||||||||||||||||
808 | - | |||||||||||||||||||||||||||||||||||||
809 | // update WM_TRANSIENT_FOR | - | ||||||||||||||||||||||||||||||||||||
810 | xcb_window_t transientXcbParent = 0; | - | ||||||||||||||||||||||||||||||||||||
811 | if (isTransient(window())) { | - | ||||||||||||||||||||||||||||||||||||
812 | const QWindow *tp = window()->transientParent(); | - | ||||||||||||||||||||||||||||||||||||
813 | if (tp && tp->handle()) | - | ||||||||||||||||||||||||||||||||||||
814 | transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId(); | - | ||||||||||||||||||||||||||||||||||||
815 | // Default to client leader if there is no transient parent, else modal dialogs can | - | ||||||||||||||||||||||||||||||||||||
816 | // be hidden by their parents. | - | ||||||||||||||||||||||||||||||||||||
817 | if (!transientXcbParent) | - | ||||||||||||||||||||||||||||||||||||
818 | transientXcbParent = connection()->clientLeader(); | - | ||||||||||||||||||||||||||||||||||||
819 | if (transientXcbParent) { // ICCCM 4.1.2.6 | - | ||||||||||||||||||||||||||||||||||||
820 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
821 | XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, | - | ||||||||||||||||||||||||||||||||||||
822 | 1, &transientXcbParent)); | - | ||||||||||||||||||||||||||||||||||||
823 | } | - | ||||||||||||||||||||||||||||||||||||
824 | } | - | ||||||||||||||||||||||||||||||||||||
825 | if (!transientXcbParent) | - | ||||||||||||||||||||||||||||||||||||
826 | Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, XCB_ATOM_WM_TRANSIENT_FOR)); | - | ||||||||||||||||||||||||||||||||||||
827 | - | |||||||||||||||||||||||||||||||||||||
828 | // update _MOTIF_WM_HINTS | - | ||||||||||||||||||||||||||||||||||||
829 | updateMotifWmHintsBeforeMap(); | - | ||||||||||||||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||||||||||||||
831 | // update _NET_WM_STATE | - | ||||||||||||||||||||||||||||||||||||
832 | updateNetWmStateBeforeMap(); | - | ||||||||||||||||||||||||||||||||||||
833 | } | - | ||||||||||||||||||||||||||||||||||||
834 | - | |||||||||||||||||||||||||||||||||||||
835 | if (testShowWithoutActivating(window())) | - | ||||||||||||||||||||||||||||||||||||
836 | updateNetWmUserTime(0); | - | ||||||||||||||||||||||||||||||||||||
837 | else if (connection()->time() != XCB_TIME_CURRENT_TIME) | - | ||||||||||||||||||||||||||||||||||||
838 | updateNetWmUserTime(connection()->time()); | - | ||||||||||||||||||||||||||||||||||||
839 | - | |||||||||||||||||||||||||||||||||||||
840 | if (window()->objectName() == QLatin1String("QSystemTrayIconSysWindow")) | - | ||||||||||||||||||||||||||||||||||||
841 | return; // defer showing until XEMBED_EMBEDDED_NOTIFY | - | ||||||||||||||||||||||||||||||||||||
842 | - | |||||||||||||||||||||||||||||||||||||
843 | Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); | - | ||||||||||||||||||||||||||||||||||||
844 | - | |||||||||||||||||||||||||||||||||||||
845 | if (QGuiApplication::modalWindow() == window()) | - | ||||||||||||||||||||||||||||||||||||
846 | requestActivateWindow(); | - | ||||||||||||||||||||||||||||||||||||
847 | - | |||||||||||||||||||||||||||||||||||||
848 | xcbScreen()->windowShown(this); | - | ||||||||||||||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||||||||||||||
850 | connection()->sync(); | - | ||||||||||||||||||||||||||||||||||||
851 | } | - | ||||||||||||||||||||||||||||||||||||
852 | - | |||||||||||||||||||||||||||||||||||||
853 | void QXcbWindow::hide() | - | ||||||||||||||||||||||||||||||||||||
854 | { | - | ||||||||||||||||||||||||||||||||||||
855 | Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); | - | ||||||||||||||||||||||||||||||||||||
856 | - | |||||||||||||||||||||||||||||||||||||
857 | // send synthetic UnmapNotify event according to icccm 4.1.4 | - | ||||||||||||||||||||||||||||||||||||
858 | Q_DECLARE_XCB_EVENT(event,xcb_unmap_notify_event_t );event; | - | ||||||||||||||||||||||||||||||||||||
859 | event.response_type = XCB_UNMAP_NOTIFY; | - | ||||||||||||||||||||||||||||||||||||
860 | event.event = xcbScreen()->root(); | - | ||||||||||||||||||||||||||||||||||||
861 | event.window = m_window; | - | ||||||||||||||||||||||||||||||||||||
862 | event.from_configure = false; | - | ||||||||||||||||||||||||||||||||||||
863 | Q_XCB_CALL(xcb_send_event(xcb_connection(), false, xcbScreen()->root(), | - | ||||||||||||||||||||||||||||||||||||
864 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); | - | ||||||||||||||||||||||||||||||||||||
865 | - | |||||||||||||||||||||||||||||||||||||
866 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
867 | - | |||||||||||||||||||||||||||||||||||||
868 | if (connection()->mouseGrabber() == this)
| 3-3982 | ||||||||||||||||||||||||||||||||||||
869 | connection()->setMouseGrabber(Q_NULLPTR); executed 3 times by 1 test: connection()->setMouseGrabber(nullptr); Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||
870 | if (QPlatformWindow *w = connection()->mousePressWindow()) {
| 0-3985 | ||||||||||||||||||||||||||||||||||||
871 | // Unset mousePressWindow when it (or one of its parents) is unmapped | - | ||||||||||||||||||||||||||||||||||||
872 | while (w) {
| 0 | ||||||||||||||||||||||||||||||||||||
873 | if (w == this) {
| 0 | ||||||||||||||||||||||||||||||||||||
874 | connection()->setMousePressWindow(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
875 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
876 | } | - | ||||||||||||||||||||||||||||||||||||
877 | w = w->parent(); | - | ||||||||||||||||||||||||||||||||||||
878 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
879 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
880 | - | |||||||||||||||||||||||||||||||||||||
881 | m_mapped = false; | - | ||||||||||||||||||||||||||||||||||||
882 | - | |||||||||||||||||||||||||||||||||||||
883 | // Hiding a modal window doesn't send an enter event to its transient parent when the | - | ||||||||||||||||||||||||||||||||||||
884 | // mouse is already over the parent window, so the enter event must be emulated. | - | ||||||||||||||||||||||||||||||||||||
885 | if (window()->isModal()) {
| 132-3853 | ||||||||||||||||||||||||||||||||||||
886 | // Get the cursor position at modal window screen | - | ||||||||||||||||||||||||||||||||||||
887 | const QPoint nativePos = xcbScreen()->cursor()->pos(); | - | ||||||||||||||||||||||||||||||||||||
888 | const QPoint cursorPos = QHighDpi::fromNativePixels(nativePos, xcbScreen()->screenForPosition(nativePos)->screen()); | - | ||||||||||||||||||||||||||||||||||||
889 | - | |||||||||||||||||||||||||||||||||||||
890 | // Find the top level window at cursor position. | - | ||||||||||||||||||||||||||||||||||||
891 | // Don't use QGuiApplication::topLevelAt(): search only the virtual siblings of this window's screen | - | ||||||||||||||||||||||||||||||||||||
892 | QWindow *enterWindow = Q_NULLPTR; | - | ||||||||||||||||||||||||||||||||||||
893 | foreachconst auto screens = xcbScreen()->virtualSiblings(); | - | ||||||||||||||||||||||||||||||||||||
894 | for (QPlatformScreen *screen , xcbScreen()->virtualSiblings()): screens) { | - | ||||||||||||||||||||||||||||||||||||
895 | if (screen->geometry().contains(cursorPos)) {
| 0-132 | ||||||||||||||||||||||||||||||||||||
896 | const QPoint devicePosition = QHighDpi::toNativePixels(cursorPos, screen->screen()); | - | ||||||||||||||||||||||||||||||||||||
897 | enterWindow = screen->topLevelAt(devicePosition); | - | ||||||||||||||||||||||||||||||||||||
898 | break; executed 132 times by 16 tests: break; Executed by:
| 132 | ||||||||||||||||||||||||||||||||||||
899 | } | - | ||||||||||||||||||||||||||||||||||||
900 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||
901 | - | |||||||||||||||||||||||||||||||||||||
902 | if (enterWindow && enterWindow != window()) {
| 0-126 | ||||||||||||||||||||||||||||||||||||
903 | // Find the child window at cursor position, otherwise use the top level window | - | ||||||||||||||||||||||||||||||||||||
904 | if (QWindow *childWindow = childWindowAt(enterWindow, cursorPos))
| 1-5 | ||||||||||||||||||||||||||||||||||||
905 | enterWindow = childWindow; executed 1 time by 1 test: enterWindow = childWindow; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
906 | const QPoint localPos = enterWindow->mapFromGlobal(cursorPos); | - | ||||||||||||||||||||||||||||||||||||
907 | QWindowSystemInterface::handleEnterEvent(enterWindow, localPos, cursorPos); | - | ||||||||||||||||||||||||||||||||||||
908 | } executed 6 times by 3 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||||||||||||||
909 | } executed 132 times by 16 tests: end of block Executed by:
| 132 | ||||||||||||||||||||||||||||||||||||
910 | } executed 3985 times by 130 tests: end of block Executed by:
| 3985 | ||||||||||||||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||||||||||||||
912 | static QWindow *tlWindow(QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
913 | { | - | ||||||||||||||||||||||||||||||||||||
914 | if (window && window->parent()) | - | ||||||||||||||||||||||||||||||||||||
915 | return tlWindow(window->parent()); | - | ||||||||||||||||||||||||||||||||||||
916 | return window; | - | ||||||||||||||||||||||||||||||||||||
917 | } | - | ||||||||||||||||||||||||||||||||||||
918 | - | |||||||||||||||||||||||||||||||||||||
919 | bool QXcbWindow::relayFocusToModalWindow() const | - | ||||||||||||||||||||||||||||||||||||
920 | { | - | ||||||||||||||||||||||||||||||||||||
921 | QWindow *w = tlWindow(static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver()); | - | ||||||||||||||||||||||||||||||||||||
922 | QWindow *modal_window = 0; | - | ||||||||||||||||||||||||||||||||||||
923 | if (QGuiApplicationPrivate::instance()->isWindowBlocked(w,&modal_window) && modal_window != w) { | - | ||||||||||||||||||||||||||||||||||||
924 | modal_window->requestActivate(); | - | ||||||||||||||||||||||||||||||||||||
925 | connection()->flush(); | - | ||||||||||||||||||||||||||||||||||||
926 | return true; | - | ||||||||||||||||||||||||||||||||||||
927 | } | - | ||||||||||||||||||||||||||||||||||||
928 | - | |||||||||||||||||||||||||||||||||||||
929 | return false; | - | ||||||||||||||||||||||||||||||||||||
930 | } | - | ||||||||||||||||||||||||||||||||||||
931 | - | |||||||||||||||||||||||||||||||||||||
932 | void QXcbWindow::doFocusIn() | - | ||||||||||||||||||||||||||||||||||||
933 | { | - | ||||||||||||||||||||||||||||||||||||
934 | if (relayFocusToModalWindow()) | - | ||||||||||||||||||||||||||||||||||||
935 | return; | - | ||||||||||||||||||||||||||||||||||||
936 | QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver(); | - | ||||||||||||||||||||||||||||||||||||
937 | connection()->setFocusWindow(static_cast<QXcbWindow *>(w->handle())); | - | ||||||||||||||||||||||||||||||||||||
938 | QWindowSystemInterface::handleWindowActivated(w, Qt::ActiveWindowFocusReason); | - | ||||||||||||||||||||||||||||||||||||
939 | } | - | ||||||||||||||||||||||||||||||||||||
940 | - | |||||||||||||||||||||||||||||||||||||
941 | static bool focusInPeeker(QXcbConnection *connection, xcb_generic_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
942 | { | - | ||||||||||||||||||||||||||||||||||||
943 | if (!event) { | - | ||||||||||||||||||||||||||||||||||||
944 | // FocusIn event is not in the queue, proceed with FocusOut normally. | - | ||||||||||||||||||||||||||||||||||||
945 | QWindowSystemInterface::handleWindowActivated(0, Qt::ActiveWindowFocusReason); | - | ||||||||||||||||||||||||||||||||||||
946 | return true; | - | ||||||||||||||||||||||||||||||||||||
947 | } | - | ||||||||||||||||||||||||||||||||||||
948 | uint response_type = event->response_type & ~0x80; | - | ||||||||||||||||||||||||||||||||||||
949 | if (response_type == XCB_FOCUS_IN) { | - | ||||||||||||||||||||||||||||||||||||
950 | // Ignore focus events that are being sent only because the pointer is over | - | ||||||||||||||||||||||||||||||||||||
951 | // our window, even if the input focus is in a different window. | - | ||||||||||||||||||||||||||||||||||||
952 | xcb_focus_in_event_t *e = (xcb_focus_in_event_t *) event; | - | ||||||||||||||||||||||||||||||||||||
953 | if (e->detail != XCB_NOTIFY_DETAIL_POINTER) | - | ||||||||||||||||||||||||||||||||||||
954 | return true; | - | ||||||||||||||||||||||||||||||||||||
955 | } | - | ||||||||||||||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||||||||||||||
957 | /* We are also interested in XEMBED_FOCUS_IN events */ | - | ||||||||||||||||||||||||||||||||||||
958 | if (response_type == XCB_CLIENT_MESSAGE) { | - | ||||||||||||||||||||||||||||||||||||
959 | xcb_client_message_event_t *cme = (xcb_client_message_event_t *)event; | - | ||||||||||||||||||||||||||||||||||||
960 | if (cme->type == connection->atom(QXcbAtom::_XEMBED) | - | ||||||||||||||||||||||||||||||||||||
961 | && cme->data.data32[1] == XEMBED_FOCUS_IN) | - | ||||||||||||||||||||||||||||||||||||
962 | return true; | - | ||||||||||||||||||||||||||||||||||||
963 | } | - | ||||||||||||||||||||||||||||||||||||
964 | - | |||||||||||||||||||||||||||||||||||||
965 | return false; | - | ||||||||||||||||||||||||||||||||||||
966 | } | - | ||||||||||||||||||||||||||||||||||||
967 | - | |||||||||||||||||||||||||||||||||||||
968 | void QXcbWindow::doFocusOut() | - | ||||||||||||||||||||||||||||||||||||
969 | { | - | ||||||||||||||||||||||||||||||||||||
970 | if (relayFocusToModalWindow()) | - | ||||||||||||||||||||||||||||||||||||
971 | return; | - | ||||||||||||||||||||||||||||||||||||
972 | connection()->setFocusWindow(0); | - | ||||||||||||||||||||||||||||||||||||
973 | // Do not set the active window to 0 if there is a FocusIn coming. | - | ||||||||||||||||||||||||||||||||||||
974 | // There is however no equivalent for XPutBackEvent so register a | - | ||||||||||||||||||||||||||||||||||||
975 | // callback for QXcbConnection instead. | - | ||||||||||||||||||||||||||||||||||||
976 | connection()->addPeekFunc(focusInPeeker); | - | ||||||||||||||||||||||||||||||||||||
977 | } | - | ||||||||||||||||||||||||||||||||||||
978 | - | |||||||||||||||||||||||||||||||||||||
979 | struct QtMotifWmHints { | - | ||||||||||||||||||||||||||||||||||||
980 | quint32 flags, functions, decorations; | - | ||||||||||||||||||||||||||||||||||||
981 | qint32 input_mode; | - | ||||||||||||||||||||||||||||||||||||
982 | quint32 status; | - | ||||||||||||||||||||||||||||||||||||
983 | }; | - | ||||||||||||||||||||||||||||||||||||
984 | - | |||||||||||||||||||||||||||||||||||||
985 | enum { | - | ||||||||||||||||||||||||||||||||||||
986 | MWM_HINTS_FUNCTIONS = (1L << 0), | - | ||||||||||||||||||||||||||||||||||||
987 | - | |||||||||||||||||||||||||||||||||||||
988 | MWM_FUNC_ALL = (1L << 0), | - | ||||||||||||||||||||||||||||||||||||
989 | MWM_FUNC_RESIZE = (1L << 1), | - | ||||||||||||||||||||||||||||||||||||
990 | MWM_FUNC_MOVE = (1L << 2), | - | ||||||||||||||||||||||||||||||||||||
991 | MWM_FUNC_MINIMIZE = (1L << 3), | - | ||||||||||||||||||||||||||||||||||||
992 | MWM_FUNC_MAXIMIZE = (1L << 4), | - | ||||||||||||||||||||||||||||||||||||
993 | MWM_FUNC_CLOSE = (1L << 5), | - | ||||||||||||||||||||||||||||||||||||
994 | - | |||||||||||||||||||||||||||||||||||||
995 | MWM_HINTS_DECORATIONS = (1L << 1), | - | ||||||||||||||||||||||||||||||||||||
996 | - | |||||||||||||||||||||||||||||||||||||
997 | MWM_DECOR_ALL = (1L << 0), | - | ||||||||||||||||||||||||||||||||||||
998 | MWM_DECOR_BORDER = (1L << 1), | - | ||||||||||||||||||||||||||||||||||||
999 | MWM_DECOR_RESIZEH = (1L << 2), | - | ||||||||||||||||||||||||||||||||||||
1000 | MWM_DECOR_TITLE = (1L << 3), | - | ||||||||||||||||||||||||||||||||||||
1001 | MWM_DECOR_MENU = (1L << 4), | - | ||||||||||||||||||||||||||||||||||||
1002 | MWM_DECOR_MINIMIZE = (1L << 5), | - | ||||||||||||||||||||||||||||||||||||
1003 | MWM_DECOR_MAXIMIZE = (1L << 6), | - | ||||||||||||||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||||||||||||||
1005 | MWM_HINTS_INPUT_MODE = (1L << 2), | - | ||||||||||||||||||||||||||||||||||||
1006 | - | |||||||||||||||||||||||||||||||||||||
1007 | MWM_INPUT_MODELESS = 0L, | - | ||||||||||||||||||||||||||||||||||||
1008 | MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, | - | ||||||||||||||||||||||||||||||||||||
1009 | MWM_INPUT_FULL_APPLICATION_MODAL = 3L | - | ||||||||||||||||||||||||||||||||||||
1010 | }; | - | ||||||||||||||||||||||||||||||||||||
1011 | - | |||||||||||||||||||||||||||||||||||||
1012 | static QtMotifWmHints getMotifWmHints(QXcbConnection *c, xcb_window_t window) | - | ||||||||||||||||||||||||||||||||||||
1013 | { | - | ||||||||||||||||||||||||||||||||||||
1014 | QtMotifWmHints hints; | - | ||||||||||||||||||||||||||||||||||||
1015 | - | |||||||||||||||||||||||||||||||||||||
1016 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||||||||||||||||||||
1017 | xcb_get_property_unchecked(c->xcb_connection(), 0, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS), | - | ||||||||||||||||||||||||||||||||||||
1018 | c->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20); | - | ||||||||||||||||||||||||||||||||||||
1019 | - | |||||||||||||||||||||||||||||||||||||
1020 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
1021 | xcb_get_property_reply(c->xcb_connection(), get_cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
1022 | - | |||||||||||||||||||||||||||||||||||||
1023 | if (reply && reply->format == 32 && reply->type == c->atom(QXcbAtom::_MOTIF_WM_HINTS)) { | - | ||||||||||||||||||||||||||||||||||||
1024 | hints = *((QtMotifWmHints *)xcb_get_property_value(reply)); | - | ||||||||||||||||||||||||||||||||||||
1025 | } else { | - | ||||||||||||||||||||||||||||||||||||
1026 | hints.flags = 0L; | - | ||||||||||||||||||||||||||||||||||||
1027 | hints.functions = MWM_FUNC_ALL; | - | ||||||||||||||||||||||||||||||||||||
1028 | hints.decorations = MWM_DECOR_ALL; | - | ||||||||||||||||||||||||||||||||||||
1029 | hints.input_mode = 0L; | - | ||||||||||||||||||||||||||||||||||||
1030 | hints.status = 0L; | - | ||||||||||||||||||||||||||||||||||||
1031 | } | - | ||||||||||||||||||||||||||||||||||||
1032 | - | |||||||||||||||||||||||||||||||||||||
1033 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
1034 | - | |||||||||||||||||||||||||||||||||||||
1035 | return hints; | - | ||||||||||||||||||||||||||||||||||||
1036 | } | - | ||||||||||||||||||||||||||||||||||||
1037 | - | |||||||||||||||||||||||||||||||||||||
1038 | static void setMotifWmHints(QXcbConnection *c, xcb_window_t window, const QtMotifWmHints &hints) | - | ||||||||||||||||||||||||||||||||||||
1039 | { | - | ||||||||||||||||||||||||||||||||||||
1040 | if (hints.flags != 0l) { | - | ||||||||||||||||||||||||||||||||||||
1041 | Q_XCB_CALL2(xcb_change_property(c->xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1042 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
1043 | window, | - | ||||||||||||||||||||||||||||||||||||
1044 | c->atom(QXcbAtom::_MOTIF_WM_HINTS), | - | ||||||||||||||||||||||||||||||||||||
1045 | c->atom(QXcbAtom::_MOTIF_WM_HINTS), | - | ||||||||||||||||||||||||||||||||||||
1046 | 32, | - | ||||||||||||||||||||||||||||||||||||
1047 | 5, | - | ||||||||||||||||||||||||||||||||||||
1048 | &hints), c); | - | ||||||||||||||||||||||||||||||||||||
1049 | } else { | - | ||||||||||||||||||||||||||||||||||||
1050 | Q_XCB_CALL2(xcb_delete_property(c->xcb_connection(), window, c->atom(QXcbAtom::_MOTIF_WM_HINTS)), c); | - | ||||||||||||||||||||||||||||||||||||
1051 | } | - | ||||||||||||||||||||||||||||||||||||
1052 | } | - | ||||||||||||||||||||||||||||||||||||
1053 | - | |||||||||||||||||||||||||||||||||||||
1054 | QXcbWindow::NetWmStates QXcbWindow::netWmStates() | - | ||||||||||||||||||||||||||||||||||||
1055 | { | - | ||||||||||||||||||||||||||||||||||||
1056 | NetWmStates result(0); | - | ||||||||||||||||||||||||||||||||||||
1057 | - | |||||||||||||||||||||||||||||||||||||
1058 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||||||||||||||||||||
1059 | xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), | - | ||||||||||||||||||||||||||||||||||||
1060 | XCB_ATOM_ATOM, 0, 1024); | - | ||||||||||||||||||||||||||||||||||||
1061 | - | |||||||||||||||||||||||||||||||||||||
1062 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
1063 | xcb_get_property_reply(xcb_connection(), get_cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
1064 | - | |||||||||||||||||||||||||||||||||||||
1065 | if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { | - | ||||||||||||||||||||||||||||||||||||
1066 | const xcb_atom_t *states = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); | - | ||||||||||||||||||||||||||||||||||||
1067 | const xcb_atom_t *statesEnd = states + reply->length; | - | ||||||||||||||||||||||||||||||||||||
1068 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_ABOVE))) | - | ||||||||||||||||||||||||||||||||||||
1069 | result |= NetWmStateAbove; | - | ||||||||||||||||||||||||||||||||||||
1070 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_BELOW))) | - | ||||||||||||||||||||||||||||||||||||
1071 | result |= NetWmStateBelow; | - | ||||||||||||||||||||||||||||||||||||
1072 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) | - | ||||||||||||||||||||||||||||||||||||
1073 | result |= NetWmStateFullScreen; | - | ||||||||||||||||||||||||||||||||||||
1074 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) | - | ||||||||||||||||||||||||||||||||||||
1075 | result |= NetWmStateMaximizedHorz; | - | ||||||||||||||||||||||||||||||||||||
1076 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) | - | ||||||||||||||||||||||||||||||||||||
1077 | result |= NetWmStateMaximizedVert; | - | ||||||||||||||||||||||||||||||||||||
1078 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_MODAL))) | - | ||||||||||||||||||||||||||||||||||||
1079 | result |= NetWmStateModal; | - | ||||||||||||||||||||||||||||||||||||
1080 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) | - | ||||||||||||||||||||||||||||||||||||
1081 | result |= NetWmStateStaysOnTop; | - | ||||||||||||||||||||||||||||||||||||
1082 | if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) | - | ||||||||||||||||||||||||||||||||||||
1083 | result |= NetWmStateDemandsAttention; | - | ||||||||||||||||||||||||||||||||||||
1084 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
1085 | } else { | - | ||||||||||||||||||||||||||||||||||||
1086 | #ifdef NET_WM_STATE_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1087 | printf("getting net wm state (%x), empty\n", m_window); | - | ||||||||||||||||||||||||||||||||||||
1088 | #endif | - | ||||||||||||||||||||||||||||||||||||
1089 | } | - | ||||||||||||||||||||||||||||||||||||
1090 | - | |||||||||||||||||||||||||||||||||||||
1091 | return result; | - | ||||||||||||||||||||||||||||||||||||
1092 | } | - | ||||||||||||||||||||||||||||||||||||
1093 | - | |||||||||||||||||||||||||||||||||||||
1094 | void QXcbWindow::setNetWmStates(NetWmStates states) | - | ||||||||||||||||||||||||||||||||||||
1095 | { | - | ||||||||||||||||||||||||||||||||||||
1096 | QVector<xcb_atom_t> atoms; | - | ||||||||||||||||||||||||||||||||||||
1097 | - | |||||||||||||||||||||||||||||||||||||
1098 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||||||||||||||||||||
1099 | xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), | - | ||||||||||||||||||||||||||||||||||||
1100 | XCB_ATOM_ATOM, 0, 1024); | - | ||||||||||||||||||||||||||||||||||||
1101 | - | |||||||||||||||||||||||||||||||||||||
1102 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
1103 | xcb_get_property_reply(xcb_connection(), get_cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
1104 | - | |||||||||||||||||||||||||||||||||||||
1105 | if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM && reply->value_len > 0) { | - | ||||||||||||||||||||||||||||||||||||
1106 | const xcb_atom_t *data = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); | - | ||||||||||||||||||||||||||||||||||||
1107 | atoms.resize(reply->value_len); | - | ||||||||||||||||||||||||||||||||||||
1108 | memcpy((void *)&atoms.first(), (void *)data, reply->value_len * sizeof(xcb_atom_t)); | - | ||||||||||||||||||||||||||||||||||||
1109 | } | - | ||||||||||||||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||||||||||||||
1111 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
1112 | - | |||||||||||||||||||||||||||||||||||||
1113 | if (states & NetWmStateAbove && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_ABOVE))) | - | ||||||||||||||||||||||||||||||||||||
1114 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_ABOVE)); | - | ||||||||||||||||||||||||||||||||||||
1115 | if (states & NetWmStateBelow && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_BELOW))) | - | ||||||||||||||||||||||||||||||||||||
1116 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_BELOW)); | - | ||||||||||||||||||||||||||||||||||||
1117 | if (states & NetWmStateFullScreen && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN))) | - | ||||||||||||||||||||||||||||||||||||
1118 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); | - | ||||||||||||||||||||||||||||||||||||
1119 | if (states & NetWmStateMaximizedHorz && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ))) | - | ||||||||||||||||||||||||||||||||||||
1120 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ)); | - | ||||||||||||||||||||||||||||||||||||
1121 | if (states & NetWmStateMaximizedVert && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT))) | - | ||||||||||||||||||||||||||||||||||||
1122 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); | - | ||||||||||||||||||||||||||||||||||||
1123 | if (states & NetWmStateModal && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_MODAL))) | - | ||||||||||||||||||||||||||||||||||||
1124 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_MODAL)); | - | ||||||||||||||||||||||||||||||||||||
1125 | if (states & NetWmStateStaysOnTop && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP))) | - | ||||||||||||||||||||||||||||||||||||
1126 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); | - | ||||||||||||||||||||||||||||||||||||
1127 | if (states & NetWmStateDemandsAttention && !atoms.contains(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION))) | - | ||||||||||||||||||||||||||||||||||||
1128 | atoms.push_back(atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); | - | ||||||||||||||||||||||||||||||||||||
1129 | - | |||||||||||||||||||||||||||||||||||||
1130 | if (atoms.isEmpty()) { | - | ||||||||||||||||||||||||||||||||||||
1131 | Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_STATE))); | - | ||||||||||||||||||||||||||||||||||||
1132 | } else { | - | ||||||||||||||||||||||||||||||||||||
1133 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
1134 | atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 32, | - | ||||||||||||||||||||||||||||||||||||
1135 | atoms.count(), atoms.constData())); | - | ||||||||||||||||||||||||||||||||||||
1136 | } | - | ||||||||||||||||||||||||||||||||||||
1137 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
1138 | } | - | ||||||||||||||||||||||||||||||||||||
1139 | - | |||||||||||||||||||||||||||||||||||||
1140 | void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
1141 | { | - | ||||||||||||||||||||||||||||||||||||
1142 | Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); | - | ||||||||||||||||||||||||||||||||||||
1143 | - | |||||||||||||||||||||||||||||||||||||
1144 | if (type == Qt::ToolTip)
| 16-4142 | ||||||||||||||||||||||||||||||||||||
1145 | flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint; executed 16 times by 6 tests: flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint; Executed by:
| 16 | ||||||||||||||||||||||||||||||||||||
1146 | if (type == Qt::Popup)
| 147-4011 | ||||||||||||||||||||||||||||||||||||
1147 | flags |= Qt::X11BypassWindowManagerHint; executed 147 times by 23 tests: flags |= Qt::X11BypassWindowManagerHint; Executed by:
| 147 | ||||||||||||||||||||||||||||||||||||
1148 | - | |||||||||||||||||||||||||||||||||||||
1149 | const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; | - | ||||||||||||||||||||||||||||||||||||
1150 | const quint32 values[] = { | - | ||||||||||||||||||||||||||||||||||||
1151 | // XCB_CW_OVERRIDE_REDIRECT | - | ||||||||||||||||||||||||||||||||||||
1152 | (flags & Qt::BypassWindowManagerHint) ? 1u : 0, | - | ||||||||||||||||||||||||||||||||||||
1153 | // XCB_CW_EVENT_MASK | - | ||||||||||||||||||||||||||||||||||||
1154 | (flags & Qt::WindowTransparentForInput) ? transparentForInputEventMask : defaultEventMask | - | ||||||||||||||||||||||||||||||||||||
1155 | }; | - | ||||||||||||||||||||||||||||||||||||
1156 | - | |||||||||||||||||||||||||||||||||||||
1157 | xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values); | - | ||||||||||||||||||||||||||||||||||||
1158 | - | |||||||||||||||||||||||||||||||||||||
1159 | QXcbWindowFunctions::WmWindowTypes wmWindowTypes = 0; | - | ||||||||||||||||||||||||||||||||||||
1160 | if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) {
| 154-4004 | ||||||||||||||||||||||||||||||||||||
1161 | wmWindowTypes = static_cast<QXcbWindowFunctions::WmWindowTypes>( | - | ||||||||||||||||||||||||||||||||||||
1162 | window()->property(wm_window_type_property_id).value<int>()); | - | ||||||||||||||||||||||||||||||||||||
1163 | } executed 154 times by 23 tests: end of block Executed by:
| 154 | ||||||||||||||||||||||||||||||||||||
1164 | - | |||||||||||||||||||||||||||||||||||||
1165 | setWmWindowType(wmWindowTypes, flags); | - | ||||||||||||||||||||||||||||||||||||
1166 | setNetWmStateWindowFlags(flags); | - | ||||||||||||||||||||||||||||||||||||
1167 | setMotifWindowFlags(flags); | - | ||||||||||||||||||||||||||||||||||||
1168 | - | |||||||||||||||||||||||||||||||||||||
1169 | setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput); | - | ||||||||||||||||||||||||||||||||||||
1170 | updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus); | - | ||||||||||||||||||||||||||||||||||||
1171 | } executed 4158 times by 125 tests: end of block Executed by:
| 4158 | ||||||||||||||||||||||||||||||||||||
1172 | - | |||||||||||||||||||||||||||||||||||||
1173 | void QXcbWindow::setMotifWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
1174 | { | - | ||||||||||||||||||||||||||||||||||||
1175 | Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); | - | ||||||||||||||||||||||||||||||||||||
1176 | - | |||||||||||||||||||||||||||||||||||||
1177 | QtMotifWmHints mwmhints; | - | ||||||||||||||||||||||||||||||||||||
1178 | mwmhints.flags = 0L; | - | ||||||||||||||||||||||||||||||||||||
1179 | mwmhints.functions = 0L; | - | ||||||||||||||||||||||||||||||||||||
1180 | mwmhints.decorations = 0; | - | ||||||||||||||||||||||||||||||||||||
1181 | mwmhints.input_mode = 0L; | - | ||||||||||||||||||||||||||||||||||||
1182 | mwmhints.status = 0L; | - | ||||||||||||||||||||||||||||||||||||
1183 | - | |||||||||||||||||||||||||||||||||||||
1184 | if (type != Qt::SplashScreen) { | - | ||||||||||||||||||||||||||||||||||||
1185 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||||||||||||||||||||
1186 | - | |||||||||||||||||||||||||||||||||||||
1187 | bool customize = flags & Qt::CustomizeWindowHint; | - | ||||||||||||||||||||||||||||||||||||
1188 | if (type == Qt::Window && !customize) { | - | ||||||||||||||||||||||||||||||||||||
1189 | const Qt::WindowFlags defaultFlags = Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; | - | ||||||||||||||||||||||||||||||||||||
1190 | if (!(flags & defaultFlags)) | - | ||||||||||||||||||||||||||||||||||||
1191 | flags |= defaultFlags; | - | ||||||||||||||||||||||||||||||||||||
1192 | } | - | ||||||||||||||||||||||||||||||||||||
1193 | if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) { | - | ||||||||||||||||||||||||||||||||||||
1194 | mwmhints.decorations |= MWM_DECOR_BORDER; | - | ||||||||||||||||||||||||||||||||||||
1195 | mwmhints.decorations |= MWM_DECOR_RESIZEH; | - | ||||||||||||||||||||||||||||||||||||
1196 | mwmhints.decorations |= MWM_DECOR_TITLE; | - | ||||||||||||||||||||||||||||||||||||
1197 | - | |||||||||||||||||||||||||||||||||||||
1198 | if (flags & Qt::WindowSystemMenuHint) | - | ||||||||||||||||||||||||||||||||||||
1199 | mwmhints.decorations |= MWM_DECOR_MENU; | - | ||||||||||||||||||||||||||||||||||||
1200 | - | |||||||||||||||||||||||||||||||||||||
1201 | if (flags & Qt::WindowMinimizeButtonHint) { | - | ||||||||||||||||||||||||||||||||||||
1202 | mwmhints.decorations |= MWM_DECOR_MINIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1203 | mwmhints.functions |= MWM_FUNC_MINIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1204 | } | - | ||||||||||||||||||||||||||||||||||||
1205 | - | |||||||||||||||||||||||||||||||||||||
1206 | if (flags & Qt::WindowMaximizeButtonHint) { | - | ||||||||||||||||||||||||||||||||||||
1207 | mwmhints.decorations |= MWM_DECOR_MAXIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1208 | mwmhints.functions |= MWM_FUNC_MAXIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1209 | } | - | ||||||||||||||||||||||||||||||||||||
1210 | - | |||||||||||||||||||||||||||||||||||||
1211 | if (flags & Qt::WindowCloseButtonHint) | - | ||||||||||||||||||||||||||||||||||||
1212 | mwmhints.functions |= MWM_FUNC_CLOSE; | - | ||||||||||||||||||||||||||||||||||||
1213 | } | - | ||||||||||||||||||||||||||||||||||||
1214 | } else { | - | ||||||||||||||||||||||||||||||||||||
1215 | // if type == Qt::SplashScreen | - | ||||||||||||||||||||||||||||||||||||
1216 | mwmhints.decorations = MWM_DECOR_ALL; | - | ||||||||||||||||||||||||||||||||||||
1217 | } | - | ||||||||||||||||||||||||||||||||||||
1218 | - | |||||||||||||||||||||||||||||||||||||
1219 | if (mwmhints.functions != 0) { | - | ||||||||||||||||||||||||||||||||||||
1220 | mwmhints.flags |= MWM_HINTS_FUNCTIONS; | - | ||||||||||||||||||||||||||||||||||||
1221 | mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE; | - | ||||||||||||||||||||||||||||||||||||
1222 | } else { | - | ||||||||||||||||||||||||||||||||||||
1223 | mwmhints.functions = MWM_FUNC_ALL; | - | ||||||||||||||||||||||||||||||||||||
1224 | } | - | ||||||||||||||||||||||||||||||||||||
1225 | - | |||||||||||||||||||||||||||||||||||||
1226 | if (!(flags & Qt::FramelessWindowHint) | - | ||||||||||||||||||||||||||||||||||||
1227 | && flags & Qt::CustomizeWindowHint | - | ||||||||||||||||||||||||||||||||||||
1228 | && flags & Qt::WindowTitleHint | - | ||||||||||||||||||||||||||||||||||||
1229 | && !(flags & | - | ||||||||||||||||||||||||||||||||||||
1230 | (Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||||||||||||||||||||
1231 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||||||||||||||||||||
1232 | | Qt::WindowCloseButtonHint))) | - | ||||||||||||||||||||||||||||||||||||
1233 | { | - | ||||||||||||||||||||||||||||||||||||
1234 | // a special case - only the titlebar without any button | - | ||||||||||||||||||||||||||||||||||||
1235 | mwmhints.flags = MWM_HINTS_FUNCTIONS; | - | ||||||||||||||||||||||||||||||||||||
1236 | mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE; | - | ||||||||||||||||||||||||||||||||||||
1237 | mwmhints.decorations = 0; | - | ||||||||||||||||||||||||||||||||||||
1238 | } | - | ||||||||||||||||||||||||||||||||||||
1239 | - | |||||||||||||||||||||||||||||||||||||
1240 | setMotifWmHints(connection(), m_window, mwmhints); | - | ||||||||||||||||||||||||||||||||||||
1241 | } | - | ||||||||||||||||||||||||||||||||||||
1242 | - | |||||||||||||||||||||||||||||||||||||
1243 | void QXcbWindow::changeNetWmState(bool set, xcb_atom_t one, xcb_atom_t two) | - | ||||||||||||||||||||||||||||||||||||
1244 | { | - | ||||||||||||||||||||||||||||||||||||
1245 | xcb_client_message_event_t event; | - | ||||||||||||||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||||||||||||||
1247 | event.response_type = XCB_CLIENT_MESSAGE; | - | ||||||||||||||||||||||||||||||||||||
1248 | event.format = 32; | - | ||||||||||||||||||||||||||||||||||||
1249 | event.sequence = 0; | - | ||||||||||||||||||||||||||||||||||||
1250 | event.window = m_window; | - | ||||||||||||||||||||||||||||||||||||
1251 | event.type = atom(QXcbAtom::_NET_WM_STATE); | - | ||||||||||||||||||||||||||||||||||||
1252 | event.data.data32[0] = set ? 1 : 0; | - | ||||||||||||||||||||||||||||||||||||
1253 | event.data.data32[1] = one; | - | ||||||||||||||||||||||||||||||||||||
1254 | event.data.data32[2] = two; | - | ||||||||||||||||||||||||||||||||||||
1255 | event.data.data32[3] = 0; | - | ||||||||||||||||||||||||||||||||||||
1256 | event.data.data32[4] = 0; | - | ||||||||||||||||||||||||||||||||||||
1257 | - | |||||||||||||||||||||||||||||||||||||
1258 | Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); | - | ||||||||||||||||||||||||||||||||||||
1259 | } | - | ||||||||||||||||||||||||||||||||||||
1260 | - | |||||||||||||||||||||||||||||||||||||
1261 | void QXcbWindow::setWindowState(Qt::WindowState state) | - | ||||||||||||||||||||||||||||||||||||
1262 | { | - | ||||||||||||||||||||||||||||||||||||
1263 | if (state == m_windowState) | - | ||||||||||||||||||||||||||||||||||||
1264 | return; | - | ||||||||||||||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||||||||||||||
1266 | // unset old state | - | ||||||||||||||||||||||||||||||||||||
1267 | switch (m_windowState) { | - | ||||||||||||||||||||||||||||||||||||
1268 | case Qt::WindowMinimized: | - | ||||||||||||||||||||||||||||||||||||
1269 | Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); | - | ||||||||||||||||||||||||||||||||||||
1270 | break; | - | ||||||||||||||||||||||||||||||||||||
1271 | case Qt::WindowMaximized: | - | ||||||||||||||||||||||||||||||||||||
1272 | changeNetWmState(false, | - | ||||||||||||||||||||||||||||||||||||
1273 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), | - | ||||||||||||||||||||||||||||||||||||
1274 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); | - | ||||||||||||||||||||||||||||||||||||
1275 | break; | - | ||||||||||||||||||||||||||||||||||||
1276 | case Qt::WindowFullScreen: | - | ||||||||||||||||||||||||||||||||||||
1277 | changeNetWmState(false, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); | - | ||||||||||||||||||||||||||||||||||||
1278 | break; | - | ||||||||||||||||||||||||||||||||||||
1279 | default: | - | ||||||||||||||||||||||||||||||||||||
1280 | break; | - | ||||||||||||||||||||||||||||||||||||
1281 | } | - | ||||||||||||||||||||||||||||||||||||
1282 | - | |||||||||||||||||||||||||||||||||||||
1283 | // set new state | - | ||||||||||||||||||||||||||||||||||||
1284 | switch (state) { | - | ||||||||||||||||||||||||||||||||||||
1285 | case Qt::WindowMinimized: | - | ||||||||||||||||||||||||||||||||||||
1286 | { | - | ||||||||||||||||||||||||||||||||||||
1287 | xcb_client_message_event_t event; | - | ||||||||||||||||||||||||||||||||||||
1288 | - | |||||||||||||||||||||||||||||||||||||
1289 | event.response_type = XCB_CLIENT_MESSAGE; | - | ||||||||||||||||||||||||||||||||||||
1290 | event.format = 32; | - | ||||||||||||||||||||||||||||||||||||
1291 | event.sequence = 0; | - | ||||||||||||||||||||||||||||||||||||
1292 | event.window = m_window; | - | ||||||||||||||||||||||||||||||||||||
1293 | event.type = atom(QXcbAtom::WM_CHANGE_STATE); | - | ||||||||||||||||||||||||||||||||||||
1294 | event.data.data32[0] = XCB_WM_STATE_ICONIC; | - | ||||||||||||||||||||||||||||||||||||
1295 | event.data.data32[1] = 0; | - | ||||||||||||||||||||||||||||||||||||
1296 | event.data.data32[2] = 0; | - | ||||||||||||||||||||||||||||||||||||
1297 | event.data.data32[3] = 0; | - | ||||||||||||||||||||||||||||||||||||
1298 | event.data.data32[4] = 0; | - | ||||||||||||||||||||||||||||||||||||
1299 | - | |||||||||||||||||||||||||||||||||||||
1300 | Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); | - | ||||||||||||||||||||||||||||||||||||
1301 | } | - | ||||||||||||||||||||||||||||||||||||
1302 | break; | - | ||||||||||||||||||||||||||||||||||||
1303 | case Qt::WindowMaximized: | - | ||||||||||||||||||||||||||||||||||||
1304 | changeNetWmState(true, | - | ||||||||||||||||||||||||||||||||||||
1305 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_HORZ), | - | ||||||||||||||||||||||||||||||||||||
1306 | atom(QXcbAtom::_NET_WM_STATE_MAXIMIZED_VERT)); | - | ||||||||||||||||||||||||||||||||||||
1307 | break; | - | ||||||||||||||||||||||||||||||||||||
1308 | case Qt::WindowFullScreen: | - | ||||||||||||||||||||||||||||||||||||
1309 | changeNetWmState(true, atom(QXcbAtom::_NET_WM_STATE_FULLSCREEN)); | - | ||||||||||||||||||||||||||||||||||||
1310 | break; | - | ||||||||||||||||||||||||||||||||||||
1311 | case Qt::WindowNoState: | - | ||||||||||||||||||||||||||||||||||||
1312 | break; | - | ||||||||||||||||||||||||||||||||||||
1313 | default: | - | ||||||||||||||||||||||||||||||||||||
1314 | break; | - | ||||||||||||||||||||||||||||||||||||
1315 | } | - | ||||||||||||||||||||||||||||||||||||
1316 | - | |||||||||||||||||||||||||||||||||||||
1317 | connection()->sync(); | - | ||||||||||||||||||||||||||||||||||||
1318 | - | |||||||||||||||||||||||||||||||||||||
1319 | m_windowState = state; | - | ||||||||||||||||||||||||||||||||||||
1320 | } | - | ||||||||||||||||||||||||||||||||||||
1321 | - | |||||||||||||||||||||||||||||||||||||
1322 | void QXcbWindow::updateMotifWmHintsBeforeMap() | - | ||||||||||||||||||||||||||||||||||||
1323 | { | - | ||||||||||||||||||||||||||||||||||||
1324 | QtMotifWmHints mwmhints = getMotifWmHints(connection(), m_window); | - | ||||||||||||||||||||||||||||||||||||
1325 | - | |||||||||||||||||||||||||||||||||||||
1326 | if (window()->modality() != Qt::NonModal) { | - | ||||||||||||||||||||||||||||||||||||
1327 | switch (window()->modality()) { | - | ||||||||||||||||||||||||||||||||||||
1328 | case Qt::WindowModal: | - | ||||||||||||||||||||||||||||||||||||
1329 | mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL; | - | ||||||||||||||||||||||||||||||||||||
1330 | break; | - | ||||||||||||||||||||||||||||||||||||
1331 | case Qt::ApplicationModal: | - | ||||||||||||||||||||||||||||||||||||
1332 | default: | - | ||||||||||||||||||||||||||||||||||||
1333 | mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL; | - | ||||||||||||||||||||||||||||||||||||
1334 | break; | - | ||||||||||||||||||||||||||||||||||||
1335 | } | - | ||||||||||||||||||||||||||||||||||||
1336 | mwmhints.flags |= MWM_HINTS_INPUT_MODE; | - | ||||||||||||||||||||||||||||||||||||
1337 | } else { | - | ||||||||||||||||||||||||||||||||||||
1338 | mwmhints.input_mode = MWM_INPUT_MODELESS; | - | ||||||||||||||||||||||||||||||||||||
1339 | mwmhints.flags &= ~MWM_HINTS_INPUT_MODE; | - | ||||||||||||||||||||||||||||||||||||
1340 | } | - | ||||||||||||||||||||||||||||||||||||
1341 | - | |||||||||||||||||||||||||||||||||||||
1342 | if (windowMinimumSize() == windowMaximumSize()) { | - | ||||||||||||||||||||||||||||||||||||
1343 | // fixed size, remove the resize handle (since mwm/dtwm | - | ||||||||||||||||||||||||||||||||||||
1344 | // isn't smart enough to do it itself) | - | ||||||||||||||||||||||||||||||||||||
1345 | mwmhints.flags |= MWM_HINTS_FUNCTIONS; | - | ||||||||||||||||||||||||||||||||||||
1346 | if (mwmhints.functions == MWM_FUNC_ALL) { | - | ||||||||||||||||||||||||||||||||||||
1347 | mwmhints.functions = MWM_FUNC_MOVE; | - | ||||||||||||||||||||||||||||||||||||
1348 | } else { | - | ||||||||||||||||||||||||||||||||||||
1349 | mwmhints.functions &= ~MWM_FUNC_RESIZE; | - | ||||||||||||||||||||||||||||||||||||
1350 | } | - | ||||||||||||||||||||||||||||||||||||
1351 | - | |||||||||||||||||||||||||||||||||||||
1352 | if (mwmhints.decorations == MWM_DECOR_ALL) { | - | ||||||||||||||||||||||||||||||||||||
1353 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||||||||||||||||||||
1354 | mwmhints.decorations = (MWM_DECOR_BORDER | - | ||||||||||||||||||||||||||||||||||||
1355 | | MWM_DECOR_TITLE | - | ||||||||||||||||||||||||||||||||||||
1356 | | MWM_DECOR_MENU); | - | ||||||||||||||||||||||||||||||||||||
1357 | } else { | - | ||||||||||||||||||||||||||||||||||||
1358 | mwmhints.decorations &= ~MWM_DECOR_RESIZEH; | - | ||||||||||||||||||||||||||||||||||||
1359 | } | - | ||||||||||||||||||||||||||||||||||||
1360 | } | - | ||||||||||||||||||||||||||||||||||||
1361 | - | |||||||||||||||||||||||||||||||||||||
1362 | if (window()->flags() & Qt::WindowMinimizeButtonHint) { | - | ||||||||||||||||||||||||||||||||||||
1363 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||||||||||||||||||||
1364 | mwmhints.decorations |= MWM_DECOR_MINIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1365 | mwmhints.functions |= MWM_FUNC_MINIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1366 | } | - | ||||||||||||||||||||||||||||||||||||
1367 | if (window()->flags() & Qt::WindowMaximizeButtonHint) { | - | ||||||||||||||||||||||||||||||||||||
1368 | mwmhints.flags |= MWM_HINTS_DECORATIONS; | - | ||||||||||||||||||||||||||||||||||||
1369 | mwmhints.decorations |= MWM_DECOR_MAXIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1370 | mwmhints.functions |= MWM_FUNC_MAXIMIZE; | - | ||||||||||||||||||||||||||||||||||||
1371 | } | - | ||||||||||||||||||||||||||||||||||||
1372 | if (window()->flags() & Qt::WindowCloseButtonHint) | - | ||||||||||||||||||||||||||||||||||||
1373 | mwmhints.functions |= MWM_FUNC_CLOSE; | - | ||||||||||||||||||||||||||||||||||||
1374 | - | |||||||||||||||||||||||||||||||||||||
1375 | setMotifWmHints(connection(), m_window, mwmhints); | - | ||||||||||||||||||||||||||||||||||||
1376 | } | - | ||||||||||||||||||||||||||||||||||||
1377 | - | |||||||||||||||||||||||||||||||||||||
1378 | void QXcbWindow::updateNetWmStateBeforeMap() | - | ||||||||||||||||||||||||||||||||||||
1379 | { | - | ||||||||||||||||||||||||||||||||||||
1380 | NetWmStates states(0); | - | ||||||||||||||||||||||||||||||||||||
1381 | - | |||||||||||||||||||||||||||||||||||||
1382 | const Qt::WindowFlags flags = window()->flags(); | - | ||||||||||||||||||||||||||||||||||||
1383 | if (flags & Qt::WindowStaysOnTopHint) { | - | ||||||||||||||||||||||||||||||||||||
1384 | states |= NetWmStateAbove; | - | ||||||||||||||||||||||||||||||||||||
1385 | states |= NetWmStateStaysOnTop; | - | ||||||||||||||||||||||||||||||||||||
1386 | } else if (flags & Qt::WindowStaysOnBottomHint) { | - | ||||||||||||||||||||||||||||||||||||
1387 | states |= NetWmStateBelow; | - | ||||||||||||||||||||||||||||||||||||
1388 | } | - | ||||||||||||||||||||||||||||||||||||
1389 | - | |||||||||||||||||||||||||||||||||||||
1390 | if (window()->windowState() & Qt::WindowFullScreen) | - | ||||||||||||||||||||||||||||||||||||
1391 | states |= NetWmStateFullScreen; | - | ||||||||||||||||||||||||||||||||||||
1392 | - | |||||||||||||||||||||||||||||||||||||
1393 | if (window()->windowState() & Qt::WindowMaximized) { | - | ||||||||||||||||||||||||||||||||||||
1394 | states |= NetWmStateMaximizedHorz; | - | ||||||||||||||||||||||||||||||||||||
1395 | states |= NetWmStateMaximizedVert; | - | ||||||||||||||||||||||||||||||||||||
1396 | } | - | ||||||||||||||||||||||||||||||||||||
1397 | - | |||||||||||||||||||||||||||||||||||||
1398 | if (window()->modality() != Qt::NonModal) | - | ||||||||||||||||||||||||||||||||||||
1399 | states |= NetWmStateModal; | - | ||||||||||||||||||||||||||||||||||||
1400 | - | |||||||||||||||||||||||||||||||||||||
1401 | setNetWmStates(states); | - | ||||||||||||||||||||||||||||||||||||
1402 | } | - | ||||||||||||||||||||||||||||||||||||
1403 | - | |||||||||||||||||||||||||||||||||||||
1404 | void QXcbWindow::setNetWmStateWindowFlags(Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
1405 | { | - | ||||||||||||||||||||||||||||||||||||
1406 | changeNetWmState(flags & Qt::WindowStaysOnTopHint, | - | ||||||||||||||||||||||||||||||||||||
1407 | atom(QXcbAtom::_NET_WM_STATE_ABOVE), | - | ||||||||||||||||||||||||||||||||||||
1408 | atom(QXcbAtom::_NET_WM_STATE_STAYS_ON_TOP)); | - | ||||||||||||||||||||||||||||||||||||
1409 | changeNetWmState(flags & Qt::WindowStaysOnBottomHint, | - | ||||||||||||||||||||||||||||||||||||
1410 | atom(QXcbAtom::_NET_WM_STATE_BELOW)); | - | ||||||||||||||||||||||||||||||||||||
1411 | } executed 4158 times by 125 tests: end of block Executed by:
| 4158 | ||||||||||||||||||||||||||||||||||||
1412 | - | |||||||||||||||||||||||||||||||||||||
1413 | void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) | - | ||||||||||||||||||||||||||||||||||||
1414 | { | - | ||||||||||||||||||||||||||||||||||||
1415 | xcb_window_t wid = m_window; | - | ||||||||||||||||||||||||||||||||||||
1416 | // If timestamp == 0, then it means that the window should not be | - | ||||||||||||||||||||||||||||||||||||
1417 | // initially activated. Don't update global user time for this | - | ||||||||||||||||||||||||||||||||||||
1418 | // special case. | - | ||||||||||||||||||||||||||||||||||||
1419 | if (timestamp != 0) | - | ||||||||||||||||||||||||||||||||||||
1420 | connection()->setNetWmUserTime(timestamp); | - | ||||||||||||||||||||||||||||||||||||
1421 | - | |||||||||||||||||||||||||||||||||||||
1422 | const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); | - | ||||||||||||||||||||||||||||||||||||
1423 | if (m_netWmUserTimeWindow || isSupportedByWM) { | - | ||||||||||||||||||||||||||||||||||||
1424 | if (!m_netWmUserTimeWindow) { | - | ||||||||||||||||||||||||||||||||||||
1425 | m_netWmUserTimeWindow = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
1426 | Q_XCB_CALL(xcb_create_window(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1427 | XCB_COPY_FROM_PARENT, // depth -- same as root | - | ||||||||||||||||||||||||||||||||||||
1428 | m_netWmUserTimeWindow, // window id | - | ||||||||||||||||||||||||||||||||||||
1429 | m_window, // parent window id | - | ||||||||||||||||||||||||||||||||||||
1430 | -1, -1, 1, 1, | - | ||||||||||||||||||||||||||||||||||||
1431 | 0, // border width | - | ||||||||||||||||||||||||||||||||||||
1432 | XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class | - | ||||||||||||||||||||||||||||||||||||
1433 | m_visualId, // visual | - | ||||||||||||||||||||||||||||||||||||
1434 | 0, // value mask | - | ||||||||||||||||||||||||||||||||||||
1435 | 0)); // value list | - | ||||||||||||||||||||||||||||||||||||
1436 | wid = m_netWmUserTimeWindow; | - | ||||||||||||||||||||||||||||||||||||
1437 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW), | - | ||||||||||||||||||||||||||||||||||||
1438 | XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow); | - | ||||||||||||||||||||||||||||||||||||
1439 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME)); | - | ||||||||||||||||||||||||||||||||||||
1440 | #ifndef QT_NO_DEBUG | - | ||||||||||||||||||||||||||||||||||||
1441 | QByteArray ba("Qt NET_WM user time window"); | - | ||||||||||||||||||||||||||||||||||||
1442 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1443 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
1444 | m_netWmUserTimeWindow, | - | ||||||||||||||||||||||||||||||||||||
1445 | atom(QXcbAtom::_NET_WM_NAME), | - | ||||||||||||||||||||||||||||||||||||
1446 | atom(QXcbAtom::UTF8_STRING), | - | ||||||||||||||||||||||||||||||||||||
1447 | 8, | - | ||||||||||||||||||||||||||||||||||||
1448 | ba.length(), | - | ||||||||||||||||||||||||||||||||||||
1449 | ba.constData())); | - | ||||||||||||||||||||||||||||||||||||
1450 | #endif | - | ||||||||||||||||||||||||||||||||||||
1451 | } else if (!isSupportedByWM) { | - | ||||||||||||||||||||||||||||||||||||
1452 | // WM no longer supports it, then we should remove the | - | ||||||||||||||||||||||||||||||||||||
1453 | // _NET_WM_USER_TIME_WINDOW atom. | - | ||||||||||||||||||||||||||||||||||||
1454 | xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); | - | ||||||||||||||||||||||||||||||||||||
1455 | xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow); | - | ||||||||||||||||||||||||||||||||||||
1456 | m_netWmUserTimeWindow = XCB_NONE; | - | ||||||||||||||||||||||||||||||||||||
1457 | } else { | - | ||||||||||||||||||||||||||||||||||||
1458 | wid = m_netWmUserTimeWindow; | - | ||||||||||||||||||||||||||||||||||||
1459 | } | - | ||||||||||||||||||||||||||||||||||||
1460 | } | - | ||||||||||||||||||||||||||||||||||||
1461 | xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::_NET_WM_USER_TIME), | - | ||||||||||||||||||||||||||||||||||||
1462 | XCB_ATOM_CARDINAL, 32, 1, ×tamp); | - | ||||||||||||||||||||||||||||||||||||
1463 | } | - | ||||||||||||||||||||||||||||||||||||
1464 | - | |||||||||||||||||||||||||||||||||||||
1465 | void QXcbWindow::setTransparentForMouseEvents(bool transparent) | - | ||||||||||||||||||||||||||||||||||||
1466 | { | - | ||||||||||||||||||||||||||||||||||||
1467 | if (!connection()->hasXFixes() || transparent == m_transparent) | - | ||||||||||||||||||||||||||||||||||||
1468 | return; | - | ||||||||||||||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||||||||||||||
1470 | xcb_rectangle_t rectangle; | - | ||||||||||||||||||||||||||||||||||||
1471 | - | |||||||||||||||||||||||||||||||||||||
1472 | xcb_rectangle_t *rect = 0; | - | ||||||||||||||||||||||||||||||||||||
1473 | int nrect = 0; | - | ||||||||||||||||||||||||||||||||||||
1474 | - | |||||||||||||||||||||||||||||||||||||
1475 | if (!transparent) { | - | ||||||||||||||||||||||||||||||||||||
1476 | rectangle.x = 0; | - | ||||||||||||||||||||||||||||||||||||
1477 | rectangle.y = 0; | - | ||||||||||||||||||||||||||||||||||||
1478 | rectangle.width = geometry().width(); | - | ||||||||||||||||||||||||||||||||||||
1479 | rectangle.height = geometry().height(); | - | ||||||||||||||||||||||||||||||||||||
1480 | rect = &rectangle; | - | ||||||||||||||||||||||||||||||||||||
1481 | nrect = 1; | - | ||||||||||||||||||||||||||||||||||||
1482 | } | - | ||||||||||||||||||||||||||||||||||||
1483 | - | |||||||||||||||||||||||||||||||||||||
1484 | xcb_xfixes_region_t region = xcb_generate_id(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
1485 | xcb_xfixes_create_region(xcb_connection(), region, nrect, rect); | - | ||||||||||||||||||||||||||||||||||||
1486 | xcb_xfixes_set_window_shape_region_checked(xcb_connection(), m_window, XCB_SHAPE_SK_INPUT, 0, 0, region); | - | ||||||||||||||||||||||||||||||||||||
1487 | xcb_xfixes_destroy_region(xcb_connection(), region); | - | ||||||||||||||||||||||||||||||||||||
1488 | - | |||||||||||||||||||||||||||||||||||||
1489 | m_transparent = transparent; | - | ||||||||||||||||||||||||||||||||||||
1490 | } | - | ||||||||||||||||||||||||||||||||||||
1491 | - | |||||||||||||||||||||||||||||||||||||
1492 | void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus) | - | ||||||||||||||||||||||||||||||||||||
1493 | { | - | ||||||||||||||||||||||||||||||||||||
1494 | xcb_get_property_cookie_t cookie = xcb_get_wm_hints_unchecked(xcb_connection(), m_window); | - | ||||||||||||||||||||||||||||||||||||
1495 | - | |||||||||||||||||||||||||||||||||||||
1496 | xcb_wm_hints_t hints; | - | ||||||||||||||||||||||||||||||||||||
1497 | if (!xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, NULL)) { | - | ||||||||||||||||||||||||||||||||||||
1498 | return; | - | ||||||||||||||||||||||||||||||||||||
1499 | } | - | ||||||||||||||||||||||||||||||||||||
1500 | - | |||||||||||||||||||||||||||||||||||||
1501 | xcb_wm_hints_set_input(&hints, !doesNotAcceptFocus); | - | ||||||||||||||||||||||||||||||||||||
1502 | xcb_set_wm_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||||||||||||||||||||
1503 | } | - | ||||||||||||||||||||||||||||||||||||
1504 | - | |||||||||||||||||||||||||||||||||||||
1505 | WId QXcbWindow::winId() const | - | ||||||||||||||||||||||||||||||||||||
1506 | { | - | ||||||||||||||||||||||||||||||||||||
1507 | return m_window; | - | ||||||||||||||||||||||||||||||||||||
1508 | } | - | ||||||||||||||||||||||||||||||||||||
1509 | - | |||||||||||||||||||||||||||||||||||||
1510 | void QXcbWindow::setParent(const QPlatformWindow *parent) | - | ||||||||||||||||||||||||||||||||||||
1511 | { | - | ||||||||||||||||||||||||||||||||||||
1512 | QPoint topLeft = geometry().topLeft(); | - | ||||||||||||||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||||||||||||||
1514 | xcb_window_t xcb_parent_id; | - | ||||||||||||||||||||||||||||||||||||
1515 | if (parent) { | - | ||||||||||||||||||||||||||||||||||||
1516 | const QXcbWindow *qXcbParent = static_cast<const QXcbWindow *>(parent); | - | ||||||||||||||||||||||||||||||||||||
1517 | xcb_parent_id = qXcbParent->xcb_window(); | - | ||||||||||||||||||||||||||||||||||||
1518 | m_embedded = qXcbParent->window()->type() == Qt::ForeignWindow; | - | ||||||||||||||||||||||||||||||||||||
1519 | } else { | - | ||||||||||||||||||||||||||||||||||||
1520 | xcb_parent_id = xcbScreen()->root(); | - | ||||||||||||||||||||||||||||||||||||
1521 | m_embedded = false; | - | ||||||||||||||||||||||||||||||||||||
1522 | } | - | ||||||||||||||||||||||||||||||||||||
1523 | Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), xcb_parent_id, topLeft.x(), topLeft.y())); | - | ||||||||||||||||||||||||||||||||||||
1524 | } | - | ||||||||||||||||||||||||||||||||||||
1525 | - | |||||||||||||||||||||||||||||||||||||
1526 | void QXcbWindow::setWindowTitle(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
1527 | { | - | ||||||||||||||||||||||||||||||||||||
1528 | const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH | - | ||||||||||||||||||||||||||||||||||||
1529 | const QByteArray ba = fullTitle.toUtf8(); | - | ||||||||||||||||||||||||||||||||||||
1530 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1531 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
1532 | m_window, | - | ||||||||||||||||||||||||||||||||||||
1533 | atom(QXcbAtom::_NET_WM_NAME), | - | ||||||||||||||||||||||||||||||||||||
1534 | atom(QXcbAtom::UTF8_STRING), | - | ||||||||||||||||||||||||||||||||||||
1535 | 8, | - | ||||||||||||||||||||||||||||||||||||
1536 | ba.length(), | - | ||||||||||||||||||||||||||||||||||||
1537 | ba.constData())); | - | ||||||||||||||||||||||||||||||||||||
1538 | - | |||||||||||||||||||||||||||||||||||||
1539 | #ifdef XCB_USE_XLIB | - | ||||||||||||||||||||||||||||||||||||
1540 | XTextProperty *text = qstringToXTP(DISPLAY_FROM_XCB(this), title); | - | ||||||||||||||||||||||||||||||||||||
1541 | if (text) | - | ||||||||||||||||||||||||||||||||||||
1542 | XSetWMName(DISPLAY_FROM_XCB(this), m_window, text); | - | ||||||||||||||||||||||||||||||||||||
1543 | #endif | - | ||||||||||||||||||||||||||||||||||||
1544 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
1545 | } | - | ||||||||||||||||||||||||||||||||||||
1546 | - | |||||||||||||||||||||||||||||||||||||
1547 | void QXcbWindow::setWindowIconText(const QString &title) | - | ||||||||||||||||||||||||||||||||||||
1548 | { | - | ||||||||||||||||||||||||||||||||||||
1549 | const QByteArray ba = title.toUtf8(); | - | ||||||||||||||||||||||||||||||||||||
1550 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1551 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
1552 | m_window, | - | ||||||||||||||||||||||||||||||||||||
1553 | atom(QXcbAtom::_NET_WM_ICON_NAME), | - | ||||||||||||||||||||||||||||||||||||
1554 | atom(QXcbAtom::UTF8_STRING), | - | ||||||||||||||||||||||||||||||||||||
1555 | 8, | - | ||||||||||||||||||||||||||||||||||||
1556 | ba.length(), | - | ||||||||||||||||||||||||||||||||||||
1557 | ba.constData())); | - | ||||||||||||||||||||||||||||||||||||
1558 | } | - | ||||||||||||||||||||||||||||||||||||
1559 | - | |||||||||||||||||||||||||||||||||||||
1560 | void QXcbWindow::setWindowIcon(const QIcon &icon) | - | ||||||||||||||||||||||||||||||||||||
1561 | { | - | ||||||||||||||||||||||||||||||||||||
1562 | QVector<quint32> icon_data; | - | ||||||||||||||||||||||||||||||||||||
1563 | if (!icon.isNull()) { | - | ||||||||||||||||||||||||||||||||||||
1564 | QList<QSize> availableSizes = icon.availableSizes(); | - | ||||||||||||||||||||||||||||||||||||
1565 | if (availableSizes.isEmpty()) { | - | ||||||||||||||||||||||||||||||||||||
1566 | // try to use default sizes since the icon can be a scalable image like svg. | - | ||||||||||||||||||||||||||||||||||||
1567 | availableSizes.push_back(QSize(16,16)); | - | ||||||||||||||||||||||||||||||||||||
1568 | availableSizes.push_back(QSize(32,32)); | - | ||||||||||||||||||||||||||||||||||||
1569 | availableSizes.push_back(QSize(64,64)); | - | ||||||||||||||||||||||||||||||||||||
1570 | availableSizes.push_back(QSize(128,128)); | - | ||||||||||||||||||||||||||||||||||||
1571 | } | - | ||||||||||||||||||||||||||||||||||||
1572 | for (int i = 0; i < availableSizes.size(); ++i) { | - | ||||||||||||||||||||||||||||||||||||
1573 | QSize size = availableSizes.at(i); | - | ||||||||||||||||||||||||||||||||||||
1574 | QPixmap pixmap = icon.pixmap(size); | - | ||||||||||||||||||||||||||||||||||||
1575 | if (!pixmap.isNull()) { | - | ||||||||||||||||||||||||||||||||||||
1576 | QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); | - | ||||||||||||||||||||||||||||||||||||
1577 | int pos = icon_data.size(); | - | ||||||||||||||||||||||||||||||||||||
1578 | icon_data.resize(pos + 2 + image.width()*image.height()); | - | ||||||||||||||||||||||||||||||||||||
1579 | icon_data[pos++] = image.width(); | - | ||||||||||||||||||||||||||||||||||||
1580 | icon_data[pos++] = image.height(); | - | ||||||||||||||||||||||||||||||||||||
1581 | memcpy(icon_data.data() + pos, image.bits(), image.width()*image.height()*4); | - | ||||||||||||||||||||||||||||||||||||
1582 | } | - | ||||||||||||||||||||||||||||||||||||
1583 | } | - | ||||||||||||||||||||||||||||||||||||
1584 | } | - | ||||||||||||||||||||||||||||||||||||
1585 | - | |||||||||||||||||||||||||||||||||||||
1586 | if (!icon_data.isEmpty()) { | - | ||||||||||||||||||||||||||||||||||||
1587 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1588 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
1589 | m_window, | - | ||||||||||||||||||||||||||||||||||||
1590 | atom(QXcbAtom::_NET_WM_ICON), | - | ||||||||||||||||||||||||||||||||||||
1591 | atom(QXcbAtom::CARDINAL), | - | ||||||||||||||||||||||||||||||||||||
1592 | 32, | - | ||||||||||||||||||||||||||||||||||||
1593 | icon_data.size(), | - | ||||||||||||||||||||||||||||||||||||
1594 | (unsigned char *) icon_data.data())); | - | ||||||||||||||||||||||||||||||||||||
1595 | } else { | - | ||||||||||||||||||||||||||||||||||||
1596 | Q_XCB_CALL(xcb_delete_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
1597 | m_window, | - | ||||||||||||||||||||||||||||||||||||
1598 | atom(QXcbAtom::_NET_WM_ICON))); | - | ||||||||||||||||||||||||||||||||||||
1599 | } | - | ||||||||||||||||||||||||||||||||||||
1600 | } | - | ||||||||||||||||||||||||||||||||||||
1601 | - | |||||||||||||||||||||||||||||||||||||
1602 | void QXcbWindow::raise() | - | ||||||||||||||||||||||||||||||||||||
1603 | { | - | ||||||||||||||||||||||||||||||||||||
1604 | const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE; | - | ||||||||||||||||||||||||||||||||||||
1605 | const quint32 values[] = { XCB_STACK_MODE_ABOVE }; | - | ||||||||||||||||||||||||||||||||||||
1606 | Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); | - | ||||||||||||||||||||||||||||||||||||
1607 | } | - | ||||||||||||||||||||||||||||||||||||
1608 | - | |||||||||||||||||||||||||||||||||||||
1609 | void QXcbWindow::lower() | - | ||||||||||||||||||||||||||||||||||||
1610 | { | - | ||||||||||||||||||||||||||||||||||||
1611 | const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE; | - | ||||||||||||||||||||||||||||||||||||
1612 | const quint32 values[] = { XCB_STACK_MODE_BELOW }; | - | ||||||||||||||||||||||||||||||||||||
1613 | Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); | - | ||||||||||||||||||||||||||||||||||||
1614 | } | - | ||||||||||||||||||||||||||||||||||||
1615 | - | |||||||||||||||||||||||||||||||||||||
1616 | // Adapt the geometry to match the WM expection with regards | - | ||||||||||||||||||||||||||||||||||||
1617 | // to gravity. | - | ||||||||||||||||||||||||||||||||||||
1618 | QRect QXcbWindow::windowToWmGeometry(QRect r) const | - | ||||||||||||||||||||||||||||||||||||
1619 | { | - | ||||||||||||||||||||||||||||||||||||
1620 | if (m_dirtyFrameMargins || m_frameMargins.isNull()) | - | ||||||||||||||||||||||||||||||||||||
1621 | return r; | - | ||||||||||||||||||||||||||||||||||||
1622 | const bool frameInclusive = positionIncludesFrame(window()); | - | ||||||||||||||||||||||||||||||||||||
1623 | // XCB_GRAVITY_STATIC requires the inner geometry, whereas | - | ||||||||||||||||||||||||||||||||||||
1624 | // XCB_GRAVITY_NORTH_WEST requires the frame geometry | - | ||||||||||||||||||||||||||||||||||||
1625 | if (frameInclusive && m_gravity == XCB_GRAVITY_STATIC) { | - | ||||||||||||||||||||||||||||||||||||
1626 | r.translate(m_frameMargins.left(), m_frameMargins.top()); | - | ||||||||||||||||||||||||||||||||||||
1627 | } else if (!frameInclusive && m_gravity == XCB_GRAVITY_NORTH_WEST) { | - | ||||||||||||||||||||||||||||||||||||
1628 | r.translate(-m_frameMargins.left(), -m_frameMargins.top()); | - | ||||||||||||||||||||||||||||||||||||
1629 | } | - | ||||||||||||||||||||||||||||||||||||
1630 | return r; | - | ||||||||||||||||||||||||||||||||||||
1631 | } | - | ||||||||||||||||||||||||||||||||||||
1632 | - | |||||||||||||||||||||||||||||||||||||
1633 | void QXcbWindow::propagateSizeHints() | - | ||||||||||||||||||||||||||||||||||||
1634 | { | - | ||||||||||||||||||||||||||||||||||||
1635 | // update WM_NORMAL_HINTS | - | ||||||||||||||||||||||||||||||||||||
1636 | xcb_size_hints_t hints; | - | ||||||||||||||||||||||||||||||||||||
1637 | memset(&hints, 0, sizeof(hints)); | - | ||||||||||||||||||||||||||||||||||||
1638 | - | |||||||||||||||||||||||||||||||||||||
1639 | const QRect xRect = windowToWmGeometry(geometry()); | - | ||||||||||||||||||||||||||||||||||||
1640 | - | |||||||||||||||||||||||||||||||||||||
1641 | QWindow *win = window(); | - | ||||||||||||||||||||||||||||||||||||
1642 | - | |||||||||||||||||||||||||||||||||||||
1643 | if (!qt_window_private(win)->positionAutomatic) | - | ||||||||||||||||||||||||||||||||||||
1644 | xcb_size_hints_set_position(&hints, true, xRect.x(), xRect.y()); | - | ||||||||||||||||||||||||||||||||||||
1645 | if (xRect.width() < QWINDOWSIZE_MAX || xRect.height() < QWINDOWSIZE_MAX) | - | ||||||||||||||||||||||||||||||||||||
1646 | xcb_size_hints_set_size(&hints, true, xRect.width(), xRect.height()); | - | ||||||||||||||||||||||||||||||||||||
1647 | xcb_size_hints_set_win_gravity(&hints, m_gravity); | - | ||||||||||||||||||||||||||||||||||||
1648 | - | |||||||||||||||||||||||||||||||||||||
1649 | QSize minimumSize = windowMinimumSize(); | - | ||||||||||||||||||||||||||||||||||||
1650 | QSize maximumSize = windowMaximumSize(); | - | ||||||||||||||||||||||||||||||||||||
1651 | QSize baseSize = windowBaseSize(); | - | ||||||||||||||||||||||||||||||||||||
1652 | QSize sizeIncrement = windowSizeIncrement(); | - | ||||||||||||||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||||||||||||||
1654 | if (minimumSize.width() > 0 || minimumSize.height() > 0) | - | ||||||||||||||||||||||||||||||||||||
1655 | xcb_size_hints_set_min_size(&hints, | - | ||||||||||||||||||||||||||||||||||||
1656 | qMin(XCOORD_MAX,minimumSize.width()), | - | ||||||||||||||||||||||||||||||||||||
1657 | qMin(XCOORD_MAX,minimumSize.height())); | - | ||||||||||||||||||||||||||||||||||||
1658 | - | |||||||||||||||||||||||||||||||||||||
1659 | if (maximumSize.width() < QWINDOWSIZE_MAX || maximumSize.height() < QWINDOWSIZE_MAX) | - | ||||||||||||||||||||||||||||||||||||
1660 | xcb_size_hints_set_max_size(&hints, | - | ||||||||||||||||||||||||||||||||||||
1661 | qMin(XCOORD_MAX, maximumSize.width()), | - | ||||||||||||||||||||||||||||||||||||
1662 | qMin(XCOORD_MAX, maximumSize.height())); | - | ||||||||||||||||||||||||||||||||||||
1663 | - | |||||||||||||||||||||||||||||||||||||
1664 | if (sizeIncrement.width() > 0 || sizeIncrement.height() > 0) { | - | ||||||||||||||||||||||||||||||||||||
1665 | xcb_size_hints_set_base_size(&hints, baseSize.width(), baseSize.height()); | - | ||||||||||||||||||||||||||||||||||||
1666 | xcb_size_hints_set_resize_inc(&hints, sizeIncrement.width(), sizeIncrement.height()); | - | ||||||||||||||||||||||||||||||||||||
1667 | } | - | ||||||||||||||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||||||||||||||
1669 | xcb_set_wm_normal_hints(xcb_connection(), m_window, &hints); | - | ||||||||||||||||||||||||||||||||||||
1670 | } | - | ||||||||||||||||||||||||||||||||||||
1671 | - | |||||||||||||||||||||||||||||||||||||
1672 | void QXcbWindow::requestActivateWindow() | - | ||||||||||||||||||||||||||||||||||||
1673 | { | - | ||||||||||||||||||||||||||||||||||||
1674 | /* Never activate embedded windows; doing that would prevent the container | - | ||||||||||||||||||||||||||||||||||||
1675 | * to re-gain the keyboard focus later. */ | - | ||||||||||||||||||||||||||||||||||||
1676 | if (m_embedded) {
| 0-1383 | ||||||||||||||||||||||||||||||||||||
1677 | QPlatformWindow::requestActivateWindow(); | - | ||||||||||||||||||||||||||||||||||||
1678 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
1679 | } | - | ||||||||||||||||||||||||||||||||||||
1680 | - | |||||||||||||||||||||||||||||||||||||
1681 | if (!m_mapped|| !xcbScreen())) {
| 650-733 | ||||||||||||||||||||||||||||||||||||
1682 | m_deferredActivation = true; | - | ||||||||||||||||||||||||||||||||||||
1683 | return; executed 733 times by 58 tests: return; Executed by:
| 733 | ||||||||||||||||||||||||||||||||||||
1684 | } | - | ||||||||||||||||||||||||||||||||||||
1685 | m_deferredActivation = false; | - | ||||||||||||||||||||||||||||||||||||
1686 | - | |||||||||||||||||||||||||||||||||||||
1687 | updateNetWmUserTime(connection()->time()); | - | ||||||||||||||||||||||||||||||||||||
1688 | QWindow *focusWindow = QGuiApplication::focusWindow(); | - | ||||||||||||||||||||||||||||||||||||
1689 | - | |||||||||||||||||||||||||||||||||||||
1690 | if (window()->isTopLevel()
| 4-646 | ||||||||||||||||||||||||||||||||||||
1691 | && !(window()->flags() & Qt::X11BypassWindowManagerHint)
| 15-631 | ||||||||||||||||||||||||||||||||||||
1692 | && (!focusWindow || !window()->isAncestorOf(focusWindow))
| 11-363 | ||||||||||||||||||||||||||||||||||||
1693 | && connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_ACTIVE_WINDOW))) {
| 0-620 | ||||||||||||||||||||||||||||||||||||
1694 | xcb_client_message_event_t event; | - | ||||||||||||||||||||||||||||||||||||
1695 | - | |||||||||||||||||||||||||||||||||||||
1696 | event.response_type = XCB_CLIENT_MESSAGE; | - | ||||||||||||||||||||||||||||||||||||
1697 | event.format = 32; | - | ||||||||||||||||||||||||||||||||||||
1698 | event.sequence = 0; | - | ||||||||||||||||||||||||||||||||||||
1699 | event.window = m_window; | - | ||||||||||||||||||||||||||||||||||||
1700 | event.type = atom(QXcbAtom::_NET_ACTIVE_WINDOW); | - | ||||||||||||||||||||||||||||||||||||
1701 | event.data.data32[0] = 1; | - | ||||||||||||||||||||||||||||||||||||
1702 | event.data.data32[1] = connection()->time(); | - | ||||||||||||||||||||||||||||||||||||
1703 | event.data.data32[2] = focusWindow ? focusWindow->winId() : XCB_NONE;
| 257-363 | ||||||||||||||||||||||||||||||||||||
1704 | event.data.data32[3] = 0; | - | ||||||||||||||||||||||||||||||||||||
1705 | event.data.data32[4] = 0; | - | ||||||||||||||||||||||||||||||||||||
1706 | - | |||||||||||||||||||||||||||||||||||||
1707 | Q_XCB_CALL(xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); | - | ||||||||||||||||||||||||||||||||||||
1708 | } else { executed 620 times by 59 tests: end of block Executed by:
| 620 | ||||||||||||||||||||||||||||||||||||
1709 | Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time())); | - | ||||||||||||||||||||||||||||||||||||
1710 | } executed 30 times by 11 tests: end of block Executed by:
| 30 | ||||||||||||||||||||||||||||||||||||
1711 | - | |||||||||||||||||||||||||||||||||||||
1712 | connection()->sync(); | - | ||||||||||||||||||||||||||||||||||||
1713 | } executed 650 times by 59 tests: end of block Executed by:
| 650 | ||||||||||||||||||||||||||||||||||||
1714 | - | |||||||||||||||||||||||||||||||||||||
1715 | QSurfaceFormat QXcbWindow::format() const | - | ||||||||||||||||||||||||||||||||||||
1716 | { | - | ||||||||||||||||||||||||||||||||||||
1717 | return m_format; | - | ||||||||||||||||||||||||||||||||||||
1718 | } | - | ||||||||||||||||||||||||||||||||||||
1719 | - | |||||||||||||||||||||||||||||||||||||
1720 | void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes) | - | ||||||||||||||||||||||||||||||||||||
1721 | { | - | ||||||||||||||||||||||||||||||||||||
1722 | window->setProperty(wm_window_type_property_id, QVariant::fromValue(static_cast<int>(windowTypes))); | - | ||||||||||||||||||||||||||||||||||||
1723 | - | |||||||||||||||||||||||||||||||||||||
1724 | if (window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1725 | static_cast<QXcbWindow *>(window->handle())->setWmWindowType(windowTypes, window->flags()); | - | ||||||||||||||||||||||||||||||||||||
1726 | } | - | ||||||||||||||||||||||||||||||||||||
1727 | - | |||||||||||||||||||||||||||||||||||||
1728 | void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text) | - | ||||||||||||||||||||||||||||||||||||
1729 | { | - | ||||||||||||||||||||||||||||||||||||
1730 | if (window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1731 | static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text); | - | ||||||||||||||||||||||||||||||||||||
1732 | } | - | ||||||||||||||||||||||||||||||||||||
1733 | - | |||||||||||||||||||||||||||||||||||||
1734 | void QXcbWindow::setWmWindowRoleStatic(QWindow *window, const QByteArray &role) | - | ||||||||||||||||||||||||||||||||||||
1735 | { | - | ||||||||||||||||||||||||||||||||||||
1736 | if (window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1737 | static_cast<QXcbWindow *>(window->handle())->setWmWindowRole(role); | - | ||||||||||||||||||||||||||||||||||||
1738 | else | - | ||||||||||||||||||||||||||||||||||||
1739 | window->setProperty(wm_window_role_property_id, role); | - | ||||||||||||||||||||||||||||||||||||
1740 | } | - | ||||||||||||||||||||||||||||||||||||
1741 | - | |||||||||||||||||||||||||||||||||||||
1742 | uint QXcbWindow::visualIdStatic(QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
1743 | { | - | ||||||||||||||||||||||||||||||||||||
1744 | if (window && window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1745 | return static_cast<QXcbWindow *>(window->handle())->visualId(); | - | ||||||||||||||||||||||||||||||||||||
1746 | return UINT_MAX; | - | ||||||||||||||||||||||||||||||||||||
1747 | } | - | ||||||||||||||||||||||||||||||||||||
1748 | - | |||||||||||||||||||||||||||||||||||||
1749 | QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const | - | ||||||||||||||||||||||||||||||||||||
1750 | { | - | ||||||||||||||||||||||||||||||||||||
1751 | QXcbWindowFunctions::WmWindowTypes result(0); | - | ||||||||||||||||||||||||||||||||||||
1752 | - | |||||||||||||||||||||||||||||||||||||
1753 | xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||||||||||||||||||||
1754 | xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), | - | ||||||||||||||||||||||||||||||||||||
1755 | XCB_ATOM_ATOM, 0, 1024); | - | ||||||||||||||||||||||||||||||||||||
1756 | - | |||||||||||||||||||||||||||||||||||||
1757 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
1758 | xcb_get_property_reply(xcb_connection(), get_cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
1759 | - | |||||||||||||||||||||||||||||||||||||
1760 | if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { | - | ||||||||||||||||||||||||||||||||||||
1761 | const xcb_atom_t *types = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply)); | - | ||||||||||||||||||||||||||||||||||||
1762 | const xcb_atom_t *types_end = types + reply->length; | - | ||||||||||||||||||||||||||||||||||||
1763 | for (; types != types_end; types++) { | - | ||||||||||||||||||||||||||||||||||||
1764 | QXcbAtom::Atom type = connection()->qatom(*types); | - | ||||||||||||||||||||||||||||||||||||
1765 | switch (type) { | - | ||||||||||||||||||||||||||||||||||||
1766 | case QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL: | - | ||||||||||||||||||||||||||||||||||||
1767 | result |= QXcbWindowFunctions::Normal; | - | ||||||||||||||||||||||||||||||||||||
1768 | break; | - | ||||||||||||||||||||||||||||||||||||
1769 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP: | - | ||||||||||||||||||||||||||||||||||||
1770 | result |= QXcbWindowFunctions::Desktop; | - | ||||||||||||||||||||||||||||||||||||
1771 | break; | - | ||||||||||||||||||||||||||||||||||||
1772 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK: | - | ||||||||||||||||||||||||||||||||||||
1773 | result |= QXcbWindowFunctions::Dock; | - | ||||||||||||||||||||||||||||||||||||
1774 | break; | - | ||||||||||||||||||||||||||||||||||||
1775 | case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR: | - | ||||||||||||||||||||||||||||||||||||
1776 | result |= QXcbWindowFunctions::Toolbar; | - | ||||||||||||||||||||||||||||||||||||
1777 | break; | - | ||||||||||||||||||||||||||||||||||||
1778 | case QXcbAtom::_NET_WM_WINDOW_TYPE_MENU: | - | ||||||||||||||||||||||||||||||||||||
1779 | result |= QXcbWindowFunctions::Menu; | - | ||||||||||||||||||||||||||||||||||||
1780 | break; | - | ||||||||||||||||||||||||||||||||||||
1781 | case QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY: | - | ||||||||||||||||||||||||||||||||||||
1782 | result |= QXcbWindowFunctions::Utility; | - | ||||||||||||||||||||||||||||||||||||
1783 | break; | - | ||||||||||||||||||||||||||||||||||||
1784 | case QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH: | - | ||||||||||||||||||||||||||||||||||||
1785 | result |= QXcbWindowFunctions::Splash; | - | ||||||||||||||||||||||||||||||||||||
1786 | break; | - | ||||||||||||||||||||||||||||||||||||
1787 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG: | - | ||||||||||||||||||||||||||||||||||||
1788 | result |= QXcbWindowFunctions::Dialog; | - | ||||||||||||||||||||||||||||||||||||
1789 | break; | - | ||||||||||||||||||||||||||||||||||||
1790 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU: | - | ||||||||||||||||||||||||||||||||||||
1791 | result |= QXcbWindowFunctions::DropDownMenu; | - | ||||||||||||||||||||||||||||||||||||
1792 | break; | - | ||||||||||||||||||||||||||||||||||||
1793 | case QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU: | - | ||||||||||||||||||||||||||||||||||||
1794 | result |= QXcbWindowFunctions::PopupMenu; | - | ||||||||||||||||||||||||||||||||||||
1795 | break; | - | ||||||||||||||||||||||||||||||||||||
1796 | case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP: | - | ||||||||||||||||||||||||||||||||||||
1797 | result |= QXcbWindowFunctions::Tooltip; | - | ||||||||||||||||||||||||||||||||||||
1798 | break; | - | ||||||||||||||||||||||||||||||||||||
1799 | case QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION: | - | ||||||||||||||||||||||||||||||||||||
1800 | result |= QXcbWindowFunctions::Notification; | - | ||||||||||||||||||||||||||||||||||||
1801 | break; | - | ||||||||||||||||||||||||||||||||||||
1802 | case QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO: | - | ||||||||||||||||||||||||||||||||||||
1803 | result |= QXcbWindowFunctions::Combo; | - | ||||||||||||||||||||||||||||||||||||
1804 | break; | - | ||||||||||||||||||||||||||||||||||||
1805 | case QXcbAtom::_NET_WM_WINDOW_TYPE_DND: | - | ||||||||||||||||||||||||||||||||||||
1806 | result |= QXcbWindowFunctions::Dnd; | - | ||||||||||||||||||||||||||||||||||||
1807 | break; | - | ||||||||||||||||||||||||||||||||||||
1808 | case QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE: | - | ||||||||||||||||||||||||||||||||||||
1809 | result |= QXcbWindowFunctions::KdeOverride; | - | ||||||||||||||||||||||||||||||||||||
1810 | break; | - | ||||||||||||||||||||||||||||||||||||
1811 | default: | - | ||||||||||||||||||||||||||||||||||||
1812 | break; | - | ||||||||||||||||||||||||||||||||||||
1813 | } | - | ||||||||||||||||||||||||||||||||||||
1814 | } | - | ||||||||||||||||||||||||||||||||||||
1815 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
1816 | } | - | ||||||||||||||||||||||||||||||||||||
1817 | return result; | - | ||||||||||||||||||||||||||||||||||||
1818 | } | - | ||||||||||||||||||||||||||||||||||||
1819 | - | |||||||||||||||||||||||||||||||||||||
1820 | void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags) | - | ||||||||||||||||||||||||||||||||||||
1821 | { | - | ||||||||||||||||||||||||||||||||||||
1822 | QVector<xcb_atom_t> atoms; | - | ||||||||||||||||||||||||||||||||||||
1823 | - | |||||||||||||||||||||||||||||||||||||
1824 | // manual selection 1 (these are never set by Qt and take precedence) | - | ||||||||||||||||||||||||||||||||||||
1825 | if (types & QXcbWindowFunctions::Normal) | - | ||||||||||||||||||||||||||||||||||||
1826 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); | - | ||||||||||||||||||||||||||||||||||||
1827 | if (types & QXcbWindowFunctions::Desktop) | - | ||||||||||||||||||||||||||||||||||||
1828 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP)); | - | ||||||||||||||||||||||||||||||||||||
1829 | if (types & QXcbWindowFunctions::Dock) | - | ||||||||||||||||||||||||||||||||||||
1830 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK)); | - | ||||||||||||||||||||||||||||||||||||
1831 | if (types & QXcbWindowFunctions::Notification) | - | ||||||||||||||||||||||||||||||||||||
1832 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION)); | - | ||||||||||||||||||||||||||||||||||||
1833 | - | |||||||||||||||||||||||||||||||||||||
1834 | // manual selection 2 (Qt uses these during auto selection); | - | ||||||||||||||||||||||||||||||||||||
1835 | if (types & QXcbWindowFunctions::Utility) | - | ||||||||||||||||||||||||||||||||||||
1836 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); | - | ||||||||||||||||||||||||||||||||||||
1837 | if (types & QXcbWindowFunctions::Splash) | - | ||||||||||||||||||||||||||||||||||||
1838 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); | - | ||||||||||||||||||||||||||||||||||||
1839 | if (types & QXcbWindowFunctions::Dialog) | - | ||||||||||||||||||||||||||||||||||||
1840 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); | - | ||||||||||||||||||||||||||||||||||||
1841 | if (types & QXcbWindowFunctions::Tooltip) | - | ||||||||||||||||||||||||||||||||||||
1842 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); | - | ||||||||||||||||||||||||||||||||||||
1843 | if (types & QXcbWindowFunctions::KdeOverride) | - | ||||||||||||||||||||||||||||||||||||
1844 | atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); | - | ||||||||||||||||||||||||||||||||||||
1845 | - | |||||||||||||||||||||||||||||||||||||
1846 | // manual selection 3 (these can be set by Qt, but don't have a | - | ||||||||||||||||||||||||||||||||||||
1847 | // corresponding Qt::WindowType). note that order of the *MENU | - | ||||||||||||||||||||||||||||||||||||
1848 | // atoms is important | - | ||||||||||||||||||||||||||||||||||||
1849 | if (types & QXcbWindowFunctions::Menu) | - | ||||||||||||||||||||||||||||||||||||
1850 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_MENU)); | - | ||||||||||||||||||||||||||||||||||||
1851 | if (types & QXcbWindowFunctions::DropDownMenu) | - | ||||||||||||||||||||||||||||||||||||
1852 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)); | - | ||||||||||||||||||||||||||||||||||||
1853 | if (types & QXcbWindowFunctions::PopupMenu) | - | ||||||||||||||||||||||||||||||||||||
1854 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU)); | - | ||||||||||||||||||||||||||||||||||||
1855 | if (types & QXcbWindowFunctions::Toolbar) | - | ||||||||||||||||||||||||||||||||||||
1856 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR)); | - | ||||||||||||||||||||||||||||||||||||
1857 | if (types & QXcbWindowFunctions::Combo) | - | ||||||||||||||||||||||||||||||||||||
1858 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO)); | - | ||||||||||||||||||||||||||||||||||||
1859 | if (types & QXcbWindowFunctions::Dnd) | - | ||||||||||||||||||||||||||||||||||||
1860 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DND)); | - | ||||||||||||||||||||||||||||||||||||
1861 | - | |||||||||||||||||||||||||||||||||||||
1862 | // automatic selection | - | ||||||||||||||||||||||||||||||||||||
1863 | Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); | - | ||||||||||||||||||||||||||||||||||||
1864 | switch (type) { | - | ||||||||||||||||||||||||||||||||||||
1865 | case Qt::Dialog: | - | ||||||||||||||||||||||||||||||||||||
1866 | case Qt::Sheet: | - | ||||||||||||||||||||||||||||||||||||
1867 | if (!(types & QXcbWindowFunctions::Dialog)) | - | ||||||||||||||||||||||||||||||||||||
1868 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); | - | ||||||||||||||||||||||||||||||||||||
1869 | break; | - | ||||||||||||||||||||||||||||||||||||
1870 | case Qt::Tool: | - | ||||||||||||||||||||||||||||||||||||
1871 | case Qt::Drawer: | - | ||||||||||||||||||||||||||||||||||||
1872 | if (!(types & QXcbWindowFunctions::Utility)) | - | ||||||||||||||||||||||||||||||||||||
1873 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); | - | ||||||||||||||||||||||||||||||||||||
1874 | break; | - | ||||||||||||||||||||||||||||||||||||
1875 | case Qt::ToolTip: | - | ||||||||||||||||||||||||||||||||||||
1876 | if (!(types & QXcbWindowFunctions::Tooltip)) | - | ||||||||||||||||||||||||||||||||||||
1877 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); | - | ||||||||||||||||||||||||||||||||||||
1878 | break; | - | ||||||||||||||||||||||||||||||||||||
1879 | case Qt::SplashScreen: | - | ||||||||||||||||||||||||||||||||||||
1880 | if (!(types & QXcbWindowFunctions::Splash)) | - | ||||||||||||||||||||||||||||||||||||
1881 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); | - | ||||||||||||||||||||||||||||||||||||
1882 | break; | - | ||||||||||||||||||||||||||||||||||||
1883 | default: | - | ||||||||||||||||||||||||||||||||||||
1884 | break; | - | ||||||||||||||||||||||||||||||||||||
1885 | } | - | ||||||||||||||||||||||||||||||||||||
1886 | - | |||||||||||||||||||||||||||||||||||||
1887 | if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) { | - | ||||||||||||||||||||||||||||||||||||
1888 | // override netwm type - quick and easy for KDE noborder | - | ||||||||||||||||||||||||||||||||||||
1889 | atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); | - | ||||||||||||||||||||||||||||||||||||
1890 | } | - | ||||||||||||||||||||||||||||||||||||
1891 | - | |||||||||||||||||||||||||||||||||||||
1892 | if (atoms.size() == 1 && atoms.first() == atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)) | - | ||||||||||||||||||||||||||||||||||||
1893 | atoms.clear(); | - | ||||||||||||||||||||||||||||||||||||
1894 | else | - | ||||||||||||||||||||||||||||||||||||
1895 | atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); | - | ||||||||||||||||||||||||||||||||||||
1896 | - | |||||||||||||||||||||||||||||||||||||
1897 | if (atoms.isEmpty()) { | - | ||||||||||||||||||||||||||||||||||||
1898 | Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE))); | - | ||||||||||||||||||||||||||||||||||||
1899 | } else { | - | ||||||||||||||||||||||||||||||||||||
1900 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
1901 | atom(QXcbAtom::_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, | - | ||||||||||||||||||||||||||||||||||||
1902 | atoms.count(), atoms.constData())); | - | ||||||||||||||||||||||||||||||||||||
1903 | } | - | ||||||||||||||||||||||||||||||||||||
1904 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
1905 | } | - | ||||||||||||||||||||||||||||||||||||
1906 | - | |||||||||||||||||||||||||||||||||||||
1907 | void QXcbWindow::setWmWindowRole(const QByteArray &role) | - | ||||||||||||||||||||||||||||||||||||
1908 | { | - | ||||||||||||||||||||||||||||||||||||
1909 | Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, | - | ||||||||||||||||||||||||||||||||||||
1910 | atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8, | - | ||||||||||||||||||||||||||||||||||||
1911 | role.size(), role.constData())); | - | ||||||||||||||||||||||||||||||||||||
1912 | } | - | ||||||||||||||||||||||||||||||||||||
1913 | - | |||||||||||||||||||||||||||||||||||||
1914 | void QXcbWindow::setParentRelativeBackPixmapStatic(QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
1915 | { | - | ||||||||||||||||||||||||||||||||||||
1916 | if (window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1917 | static_cast<QXcbWindow *>(window->handle())->setParentRelativeBackPixmap(); | - | ||||||||||||||||||||||||||||||||||||
1918 | } | - | ||||||||||||||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||||||||||||||
1920 | void QXcbWindow::setParentRelativeBackPixmap() | - | ||||||||||||||||||||||||||||||||||||
1921 | { | - | ||||||||||||||||||||||||||||||||||||
1922 | const quint32 mask = XCB_CW_BACK_PIXMAP; | - | ||||||||||||||||||||||||||||||||||||
1923 | const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE }; | - | ||||||||||||||||||||||||||||||||||||
1924 | Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); | - | ||||||||||||||||||||||||||||||||||||
1925 | } | - | ||||||||||||||||||||||||||||||||||||
1926 | - | |||||||||||||||||||||||||||||||||||||
1927 | bool QXcbWindow::requestSystemTrayWindowDockStatic(const QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
1928 | { | - | ||||||||||||||||||||||||||||||||||||
1929 | if (window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1930 | return static_cast<QXcbWindow *>(window->handle())->requestSystemTrayWindowDock(); | - | ||||||||||||||||||||||||||||||||||||
1931 | return false; | - | ||||||||||||||||||||||||||||||||||||
1932 | } | - | ||||||||||||||||||||||||||||||||||||
1933 | - | |||||||||||||||||||||||||||||||||||||
1934 | bool QXcbWindow::requestSystemTrayWindowDock() const | - | ||||||||||||||||||||||||||||||||||||
1935 | { | - | ||||||||||||||||||||||||||||||||||||
1936 | if (!connection()->systemTrayTracker()) | - | ||||||||||||||||||||||||||||||||||||
1937 | return false; | - | ||||||||||||||||||||||||||||||||||||
1938 | connection()->systemTrayTracker()->requestSystemTrayWindowDock(m_window); | - | ||||||||||||||||||||||||||||||||||||
1939 | return true; | - | ||||||||||||||||||||||||||||||||||||
1940 | } | - | ||||||||||||||||||||||||||||||||||||
1941 | - | |||||||||||||||||||||||||||||||||||||
1942 | QRect QXcbWindow::systemTrayWindowGlobalGeometryStatic(const QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
1943 | { | - | ||||||||||||||||||||||||||||||||||||
1944 | if (window->handle()) | - | ||||||||||||||||||||||||||||||||||||
1945 | return static_cast<QXcbWindow *>(window->handle())->systemTrayWindowGlobalGeometry(); | - | ||||||||||||||||||||||||||||||||||||
1946 | return QRect(); | - | ||||||||||||||||||||||||||||||||||||
1947 | } | - | ||||||||||||||||||||||||||||||||||||
1948 | - | |||||||||||||||||||||||||||||||||||||
1949 | QRect QXcbWindow::systemTrayWindowGlobalGeometry() const | - | ||||||||||||||||||||||||||||||||||||
1950 | { | - | ||||||||||||||||||||||||||||||||||||
1951 | if (!connection()->systemTrayTracker()) | - | ||||||||||||||||||||||||||||||||||||
1952 | return QRect(); | - | ||||||||||||||||||||||||||||||||||||
1953 | return connection()->systemTrayTracker()->systemTrayWindowGlobalGeometry(m_window); | - | ||||||||||||||||||||||||||||||||||||
1954 | } | - | ||||||||||||||||||||||||||||||||||||
1955 | - | |||||||||||||||||||||||||||||||||||||
1956 | class ExposeCompressor | - | ||||||||||||||||||||||||||||||||||||
1957 | { | - | ||||||||||||||||||||||||||||||||||||
1958 | public: | - | ||||||||||||||||||||||||||||||||||||
1959 | ExposeCompressor(xcb_window_t window, QRegion *region) | - | ||||||||||||||||||||||||||||||||||||
1960 | : m_window(window) | - | ||||||||||||||||||||||||||||||||||||
1961 | , m_region(region) | - | ||||||||||||||||||||||||||||||||||||
1962 | , m_pending(true) | - | ||||||||||||||||||||||||||||||||||||
1963 | { | - | ||||||||||||||||||||||||||||||||||||
1964 | } | - | ||||||||||||||||||||||||||||||||||||
1965 | - | |||||||||||||||||||||||||||||||||||||
1966 | bool checkEvent(xcb_generic_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
1967 | { | - | ||||||||||||||||||||||||||||||||||||
1968 | if (!event) | - | ||||||||||||||||||||||||||||||||||||
1969 | return false; | - | ||||||||||||||||||||||||||||||||||||
1970 | if ((event->response_type & ~0x80) != XCB_EXPOSE) | - | ||||||||||||||||||||||||||||||||||||
1971 | return false; | - | ||||||||||||||||||||||||||||||||||||
1972 | xcb_expose_event_t *expose = (xcb_expose_event_t *)event; | - | ||||||||||||||||||||||||||||||||||||
1973 | if (expose->window != m_window) | - | ||||||||||||||||||||||||||||||||||||
1974 | return false; | - | ||||||||||||||||||||||||||||||||||||
1975 | if (expose->count == 0) | - | ||||||||||||||||||||||||||||||||||||
1976 | m_pending = false; | - | ||||||||||||||||||||||||||||||||||||
1977 | *m_region |= QRect(expose->x, expose->y, expose->width, expose->height); | - | ||||||||||||||||||||||||||||||||||||
1978 | return true; | - | ||||||||||||||||||||||||||||||||||||
1979 | } | - | ||||||||||||||||||||||||||||||||||||
1980 | - | |||||||||||||||||||||||||||||||||||||
1981 | bool pending() const | - | ||||||||||||||||||||||||||||||||||||
1982 | { | - | ||||||||||||||||||||||||||||||||||||
1983 | return m_pending; | - | ||||||||||||||||||||||||||||||||||||
1984 | } | - | ||||||||||||||||||||||||||||||||||||
1985 | - | |||||||||||||||||||||||||||||||||||||
1986 | private: | - | ||||||||||||||||||||||||||||||||||||
1987 | xcb_window_t m_window; | - | ||||||||||||||||||||||||||||||||||||
1988 | QRegion *m_region; | - | ||||||||||||||||||||||||||||||||||||
1989 | bool m_pending; | - | ||||||||||||||||||||||||||||||||||||
1990 | }; | - | ||||||||||||||||||||||||||||||||||||
1991 | - | |||||||||||||||||||||||||||||||||||||
1992 | bool QXcbWindow::compressExposeEvent(QRegion &exposeRegion) | - | ||||||||||||||||||||||||||||||||||||
1993 | { | - | ||||||||||||||||||||||||||||||||||||
1994 | ExposeCompressor compressor(m_window, &exposeRegion); | - | ||||||||||||||||||||||||||||||||||||
1995 | xcb_generic_event_t *filter = 0; | - | ||||||||||||||||||||||||||||||||||||
1996 | do { | - | ||||||||||||||||||||||||||||||||||||
1997 | filter = connection()->checkEvent(compressor); | - | ||||||||||||||||||||||||||||||||||||
1998 | free(filter); | - | ||||||||||||||||||||||||||||||||||||
1999 | } while (filter); | - | ||||||||||||||||||||||||||||||||||||
2000 | return compressor.pending(); | - | ||||||||||||||||||||||||||||||||||||
2001 | } | - | ||||||||||||||||||||||||||||||||||||
2002 | - | |||||||||||||||||||||||||||||||||||||
2003 | bool QXcbWindow::handleGenericEvent(xcb_generic_event_t *event, long *result) | - | ||||||||||||||||||||||||||||||||||||
2004 | { | - | ||||||||||||||||||||||||||||||||||||
2005 | return QWindowSystemInterface::handleNativeEvent(window(), | - | ||||||||||||||||||||||||||||||||||||
2006 | connection()->nativeInterface()->genericEventFilterType(), | - | ||||||||||||||||||||||||||||||||||||
2007 | event, | - | ||||||||||||||||||||||||||||||||||||
2008 | result); | - | ||||||||||||||||||||||||||||||||||||
2009 | } | - | ||||||||||||||||||||||||||||||||||||
2010 | - | |||||||||||||||||||||||||||||||||||||
2011 | void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2012 | { | - | ||||||||||||||||||||||||||||||||||||
2013 | QRect rect(event->x, event->y, event->width, event->height); | - | ||||||||||||||||||||||||||||||||||||
2014 | - | |||||||||||||||||||||||||||||||||||||
2015 | if (m_exposeRegion.isEmpty()) | - | ||||||||||||||||||||||||||||||||||||
2016 | m_exposeRegion = rect; | - | ||||||||||||||||||||||||||||||||||||
2017 | else | - | ||||||||||||||||||||||||||||||||||||
2018 | m_exposeRegion |= rect; | - | ||||||||||||||||||||||||||||||||||||
2019 | - | |||||||||||||||||||||||||||||||||||||
2020 | bool pending = compressExposeEvent(m_exposeRegion); | - | ||||||||||||||||||||||||||||||||||||
2021 | - | |||||||||||||||||||||||||||||||||||||
2022 | // if count is non-zero there are more expose events pending | - | ||||||||||||||||||||||||||||||||||||
2023 | if (event->count == 0 || !pending) { | - | ||||||||||||||||||||||||||||||||||||
2024 | QWindowSystemInterface::handleExposeEvent(window(), m_exposeRegion); | - | ||||||||||||||||||||||||||||||||||||
2025 | m_exposeRegion = QRegion(); | - | ||||||||||||||||||||||||||||||||||||
2026 | } | - | ||||||||||||||||||||||||||||||||||||
2027 | } | - | ||||||||||||||||||||||||||||||||||||
2028 | - | |||||||||||||||||||||||||||||||||||||
2029 | void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2030 | { | - | ||||||||||||||||||||||||||||||||||||
2031 | if (event->format != 32) | - | ||||||||||||||||||||||||||||||||||||
2032 | return; | - | ||||||||||||||||||||||||||||||||||||
2033 | - | |||||||||||||||||||||||||||||||||||||
2034 | if (event->type == atom(QXcbAtom::WM_PROTOCOLS)) { | - | ||||||||||||||||||||||||||||||||||||
2035 | if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) { | - | ||||||||||||||||||||||||||||||||||||
2036 | QWindowSystemInterface::handleCloseEvent(window()); | - | ||||||||||||||||||||||||||||||||||||
2037 | } else if (event->data.data32[0] == atom(QXcbAtom::WM_TAKE_FOCUS)) { | - | ||||||||||||||||||||||||||||||||||||
2038 | connection()->setTime(event->data.data32[1]); | - | ||||||||||||||||||||||||||||||||||||
2039 | relayFocusToModalWindow(); | - | ||||||||||||||||||||||||||||||||||||
2040 | return; | - | ||||||||||||||||||||||||||||||||||||
2041 | } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) { | - | ||||||||||||||||||||||||||||||||||||
2042 | if (event->window == xcbScreen()->root()) | - | ||||||||||||||||||||||||||||||||||||
2043 | return; | - | ||||||||||||||||||||||||||||||||||||
2044 | - | |||||||||||||||||||||||||||||||||||||
2045 | xcb_client_message_event_t reply = *event; | - | ||||||||||||||||||||||||||||||||||||
2046 | - | |||||||||||||||||||||||||||||||||||||
2047 | reply.response_type = XCB_CLIENT_MESSAGE; | - | ||||||||||||||||||||||||||||||||||||
2048 | reply.window = xcbScreen()->root(); | - | ||||||||||||||||||||||||||||||||||||
2049 | - | |||||||||||||||||||||||||||||||||||||
2050 | xcb_send_event(xcb_connection(), 0, xcbScreen()->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); | - | ||||||||||||||||||||||||||||||||||||
2051 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
2052 | } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_SYNC_REQUEST)) { | - | ||||||||||||||||||||||||||||||||||||
2053 | connection()->setTime(event->data.data32[1]); | - | ||||||||||||||||||||||||||||||||||||
2054 | m_syncValue.lo = event->data.data32[2]; | - | ||||||||||||||||||||||||||||||||||||
2055 | m_syncValue.hi = event->data.data32[3]; | - | ||||||||||||||||||||||||||||||||||||
2056 | if (m_usingSyncProtocol) | - | ||||||||||||||||||||||||||||||||||||
2057 | m_syncState = SyncReceived; | - | ||||||||||||||||||||||||||||||||||||
2058 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||||||||||||||
2059 | } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_CONTEXT_HELP)) { | - | ||||||||||||||||||||||||||||||||||||
2060 | QWindowSystemInterface::handleEnterWhatsThisEvent(); | - | ||||||||||||||||||||||||||||||||||||
2061 | #endif | - | ||||||||||||||||||||||||||||||||||||
2062 | } else { | - | ||||||||||||||||||||||||||||||||||||
2063 | qWarning() << "QXcbWindow: Unhandled WM_PROTOCOLS message:" << connection()->atomName(event->data.data32[0]); | - | ||||||||||||||||||||||||||||||||||||
2064 | } | - | ||||||||||||||||||||||||||||||||||||
2065 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||||||||||||||||||||
2066 | } else if (event->type == atom(QXcbAtom::XdndEnter)) { | - | ||||||||||||||||||||||||||||||||||||
2067 | connection()->drag()->handleEnter(this, event); | - | ||||||||||||||||||||||||||||||||||||
2068 | } else if (event->type == atom(QXcbAtom::XdndPosition)) { | - | ||||||||||||||||||||||||||||||||||||
2069 | connection()->drag()->handlePosition(this, event); | - | ||||||||||||||||||||||||||||||||||||
2070 | } else if (event->type == atom(QXcbAtom::XdndLeave)) { | - | ||||||||||||||||||||||||||||||||||||
2071 | connection()->drag()->handleLeave(this, event); | - | ||||||||||||||||||||||||||||||||||||
2072 | } else if (event->type == atom(QXcbAtom::XdndDrop)) { | - | ||||||||||||||||||||||||||||||||||||
2073 | connection()->drag()->handleDrop(this, event); | - | ||||||||||||||||||||||||||||||||||||
2074 | #endif | - | ||||||||||||||||||||||||||||||||||||
2075 | } else if (event->type == atom(QXcbAtom::_XEMBED)) { | - | ||||||||||||||||||||||||||||||||||||
2076 | handleXEmbedMessage(event); | - | ||||||||||||||||||||||||||||||||||||
2077 | } else if (event->type == atom(QXcbAtom::_NET_ACTIVE_WINDOW)) { | - | ||||||||||||||||||||||||||||||||||||
2078 | doFocusIn(); | - | ||||||||||||||||||||||||||||||||||||
2079 | } else if (event->type == atom(QXcbAtom::MANAGER) | - | ||||||||||||||||||||||||||||||||||||
2080 | || event->type == atom(QXcbAtom::_NET_WM_STATE) | - | ||||||||||||||||||||||||||||||||||||
2081 | || event->type == atom(QXcbAtom::WM_CHANGE_STATE)) { | - | ||||||||||||||||||||||||||||||||||||
2082 | // Ignore _NET_WM_STATE, MANAGER which are relate to tray icons | - | ||||||||||||||||||||||||||||||||||||
2083 | // and other messages. | - | ||||||||||||||||||||||||||||||||||||
2084 | } else if (event->type == atom(QXcbAtom::_COMPIZ_DECOR_PENDING) | - | ||||||||||||||||||||||||||||||||||||
2085 | || event->type == atom(QXcbAtom::_COMPIZ_DECOR_REQUEST) | - | ||||||||||||||||||||||||||||||||||||
2086 | || event->type == atom(QXcbAtom::_COMPIZ_DECOR_DELETE_PIXMAP) | - | ||||||||||||||||||||||||||||||||||||
2087 | || event->type == atom(QXcbAtom::_COMPIZ_TOOLKIT_ACTION) | - | ||||||||||||||||||||||||||||||||||||
2088 | || event->type == atom(QXcbAtom::_GTK_LOAD_ICONTHEMES)) { | - | ||||||||||||||||||||||||||||||||||||
2089 | //silence the _COMPIZ and _GTK messages for now | - | ||||||||||||||||||||||||||||||||||||
2090 | } else { | - | ||||||||||||||||||||||||||||||||||||
2091 | qWarning() << "QXcbWindow: Unhandled client message:" << connection()->atomName(event->type); | - | ||||||||||||||||||||||||||||||||||||
2092 | } | - | ||||||||||||||||||||||||||||||||||||
2093 | } | - | ||||||||||||||||||||||||||||||||||||
2094 | - | |||||||||||||||||||||||||||||||||||||
2095 | void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2096 | { | - | ||||||||||||||||||||||||||||||||||||
2097 | bool fromSendEvent = (event->response_type & 0x80); | - | ||||||||||||||||||||||||||||||||||||
2098 | QPoint pos(event->x, event->y); | - | ||||||||||||||||||||||||||||||||||||
2099 | if (!parent() && !fromSendEvent) {
| 23-5733 | ||||||||||||||||||||||||||||||||||||
2100 | // Do not trust the position, query it instead. | - | ||||||||||||||||||||||||||||||||||||
2101 | xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(), | - | ||||||||||||||||||||||||||||||||||||
2102 | xcbScreen()->root(), 0, 0); | - | ||||||||||||||||||||||||||||||||||||
2103 | xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
2104 | if (reply) {
| 0-3467 | ||||||||||||||||||||||||||||||||||||
2105 | pos.setX(reply->dst_x); | - | ||||||||||||||||||||||||||||||||||||
2106 | pos.setY(reply->dst_y); | - | ||||||||||||||||||||||||||||||||||||
2107 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
2108 | } executed 3467 times by 109 tests: end of block Executed by:
| 3467 | ||||||||||||||||||||||||||||||||||||
2109 | } executed 3467 times by 109 tests: end of block Executed by:
| 3467 | ||||||||||||||||||||||||||||||||||||
2110 | - | |||||||||||||||||||||||||||||||||||||
2111 | const QRect actualGeometry = QRect(pos, QSize(event->width, event->height)); | - | ||||||||||||||||||||||||||||||||||||
2112 | QPlatformScreen *newScreen = parent() ? parent()->screen() : screenForGeometry(actualGeometry);
| 23-5733 | ||||||||||||||||||||||||||||||||||||
2113 | if (!newScreen)
| 0-5756 | ||||||||||||||||||||||||||||||||||||
2114 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
2115 | - | |||||||||||||||||||||||||||||||||||||
2116 | // Persist the actual geometry so that QWindow::geometry() can | - | ||||||||||||||||||||||||||||||||||||
2117 | // be queried in the resize event. | - | ||||||||||||||||||||||||||||||||||||
2118 | QPlatformWindow::setGeometry(actualGeometry); | - | ||||||||||||||||||||||||||||||||||||
2119 | - | |||||||||||||||||||||||||||||||||||||
2120 | // FIXME: In the case of the requestedGeometry not matching the actualGeometry due | - | ||||||||||||||||||||||||||||||||||||
2121 | // to e.g. the window manager applying restrictions to the geometry, the application | - | ||||||||||||||||||||||||||||||||||||
2122 | // will never see a move/resize event if the actualGeometry is the same as the current | - | ||||||||||||||||||||||||||||||||||||
2123 | // geometry, and may think the requested geometry was fulfilled. | - | ||||||||||||||||||||||||||||||||||||
2124 | QWindowSystemInterface::handleGeometryChange(window(), actualGeometry); | - | ||||||||||||||||||||||||||||||||||||
2125 | - | |||||||||||||||||||||||||||||||||||||
2126 | // QPlatformScreen::screen() is updated asynchronously, so we can't compare it | - | ||||||||||||||||||||||||||||||||||||
2127 | // with the newScreen. Just send the WindowScreenChanged event and QGuiApplication | - | ||||||||||||||||||||||||||||||||||||
2128 | // will make the comparison later. | - | ||||||||||||||||||||||||||||||||||||
2129 | QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); | - | ||||||||||||||||||||||||||||||||||||
2130 | - | |||||||||||||||||||||||||||||||||||||
2131 | // Send the synthetic expose event on resize only when the window is shrinked, | - | ||||||||||||||||||||||||||||||||||||
2132 | // because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically. | - | ||||||||||||||||||||||||||||||||||||
2133 |
| 2394-3362 | ||||||||||||||||||||||||||||||||||||
2134 | && (actualGeometry.width() < m_oldWindowSize.width()
| 97-3265 | ||||||||||||||||||||||||||||||||||||
2135 | || actualGeometry.height() < m_oldWindowSize.height())) {
| 12-3253 | ||||||||||||||||||||||||||||||||||||
2136 | QWindowSystemInterface::handleExposeEvent(window(), QRegion(0, 0, actualGeometry.width(), actualGeometry.height())); | - | ||||||||||||||||||||||||||||||||||||
2137 | } executed 109 times by 11 tests: end of block Executed by:
| 109 | ||||||||||||||||||||||||||||||||||||
2138 | m_oldWindowSize = actualGeometry.size(); | - | ||||||||||||||||||||||||||||||||||||
2139 | - | |||||||||||||||||||||||||||||||||||||
2140 | if (m_usingSyncProtocol && m_syncState == SyncReceived)
| 0-5756 | ||||||||||||||||||||||||||||||||||||
2141 | m_syncState = SyncAndConfigureReceived; never executed: m_syncState = SyncAndConfigureReceived; | 0 | ||||||||||||||||||||||||||||||||||||
2142 | - | |||||||||||||||||||||||||||||||||||||
2143 | m_dirtyFrameMargins = true; | - | ||||||||||||||||||||||||||||||||||||
2144 | } executed 5756 times by 109 tests: end of block Executed by:
| 5756 | ||||||||||||||||||||||||||||||||||||
2145 | - | |||||||||||||||||||||||||||||||||||||
2146 | bool QXcbWindow::isExposed() const | - | ||||||||||||||||||||||||||||||||||||
2147 | { | - | ||||||||||||||||||||||||||||||||||||
2148 | return m_mapped; | - | ||||||||||||||||||||||||||||||||||||
2149 | } | - | ||||||||||||||||||||||||||||||||||||
2150 | - | |||||||||||||||||||||||||||||||||||||
2151 | bool QXcbWindow::isEmbedded(const QPlatformWindow *parentWindow) const | - | ||||||||||||||||||||||||||||||||||||
2152 | { | - | ||||||||||||||||||||||||||||||||||||
2153 | if (!m_embedded) | - | ||||||||||||||||||||||||||||||||||||
2154 | return false; | - | ||||||||||||||||||||||||||||||||||||
2155 | - | |||||||||||||||||||||||||||||||||||||
2156 | return parentWindow ? (parentWindow == parent()) : true; | - | ||||||||||||||||||||||||||||||||||||
2157 | } | - | ||||||||||||||||||||||||||||||||||||
2158 | - | |||||||||||||||||||||||||||||||||||||
2159 | QPoint QXcbWindow::mapToGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
2160 | { | - | ||||||||||||||||||||||||||||||||||||
2161 | if (!m_embedded) | - | ||||||||||||||||||||||||||||||||||||
2162 | return pos; | - | ||||||||||||||||||||||||||||||||||||
2163 | - | |||||||||||||||||||||||||||||||||||||
2164 | QPoint ret; | - | ||||||||||||||||||||||||||||||||||||
2165 | xcb_translate_coordinates_cookie_t cookie = | - | ||||||||||||||||||||||||||||||||||||
2166 | xcb_translate_coordinates(xcb_connection(), xcb_window(), xcbScreen()->root(), | - | ||||||||||||||||||||||||||||||||||||
2167 | pos.x(), pos.y()); | - | ||||||||||||||||||||||||||||||||||||
2168 | xcb_translate_coordinates_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
2169 | xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
2170 | if (reply) { | - | ||||||||||||||||||||||||||||||||||||
2171 | ret.setX(reply->dst_x); | - | ||||||||||||||||||||||||||||||||||||
2172 | ret.setY(reply->dst_y); | - | ||||||||||||||||||||||||||||||||||||
2173 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
2174 | } | - | ||||||||||||||||||||||||||||||||||||
2175 | - | |||||||||||||||||||||||||||||||||||||
2176 | return ret; | - | ||||||||||||||||||||||||||||||||||||
2177 | } | - | ||||||||||||||||||||||||||||||||||||
2178 | - | |||||||||||||||||||||||||||||||||||||
2179 | QPoint QXcbWindow::mapFromGlobal(const QPoint &pos) const | - | ||||||||||||||||||||||||||||||||||||
2180 | { | - | ||||||||||||||||||||||||||||||||||||
2181 | if (!m_embedded) | - | ||||||||||||||||||||||||||||||||||||
2182 | return pos; | - | ||||||||||||||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||||||||||||||
2184 | QPoint ret; | - | ||||||||||||||||||||||||||||||||||||
2185 | xcb_translate_coordinates_cookie_t cookie = | - | ||||||||||||||||||||||||||||||||||||
2186 | xcb_translate_coordinates(xcb_connection(), xcbScreen()->root(), xcb_window(), | - | ||||||||||||||||||||||||||||||||||||
2187 | pos.x(), pos.y()); | - | ||||||||||||||||||||||||||||||||||||
2188 | xcb_translate_coordinates_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
2189 | xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
2190 | if (reply) { | - | ||||||||||||||||||||||||||||||||||||
2191 | ret.setX(reply->dst_x); | - | ||||||||||||||||||||||||||||||||||||
2192 | ret.setY(reply->dst_y); | - | ||||||||||||||||||||||||||||||||||||
2193 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
2194 | } | - | ||||||||||||||||||||||||||||||||||||
2195 | - | |||||||||||||||||||||||||||||||||||||
2196 | return ret; | - | ||||||||||||||||||||||||||||||||||||
2197 | } | - | ||||||||||||||||||||||||||||||||||||
2198 | - | |||||||||||||||||||||||||||||||||||||
2199 | void QXcbWindow::handleMapNotifyEvent(const xcb_map_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2200 | { | - | ||||||||||||||||||||||||||||||||||||
2201 | if (event->window == m_window) {
| 0-2478 | ||||||||||||||||||||||||||||||||||||
2202 | m_mapped = true; | - | ||||||||||||||||||||||||||||||||||||
2203 | if (m_deferredActivation)
| 388-2090 | ||||||||||||||||||||||||||||||||||||
2204 | requestActivateWindow(); executed 388 times by 53 tests: requestActivateWindow(); Executed by:
| 388 | ||||||||||||||||||||||||||||||||||||
2205 | - | |||||||||||||||||||||||||||||||||||||
2206 | QRegion exposeRegion =QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()); | - | ||||||||||||||||||||||||||||||||||||
compressExposeEvent(exposeRegion); | ||||||||||||||||||||||||||||||||||||||
QWindowSystemInterface::handleExposeEvent(window(), exposeRegion);())); | ||||||||||||||||||||||||||||||||||||||
2207 | } executed 2478 times by 104 tests: end of block Executed by:
| 2478 | ||||||||||||||||||||||||||||||||||||
2208 | } executed 2478 times by 104 tests: end of block Executed by:
| 2478 | ||||||||||||||||||||||||||||||||||||
2209 | - | |||||||||||||||||||||||||||||||||||||
2210 | void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2211 | { | - | ||||||||||||||||||||||||||||||||||||
2212 | if (event->window == m_window) { | - | ||||||||||||||||||||||||||||||||||||
2213 | m_mapped = false; | - | ||||||||||||||||||||||||||||||||||||
2214 | QWindowSystemInterface::handleExposeEvent(window(), QRegion()); | - | ||||||||||||||||||||||||||||||||||||
2215 | } | - | ||||||||||||||||||||||||||||||||||||
2216 | } | - | ||||||||||||||||||||||||||||||||||||
2217 | - | |||||||||||||||||||||||||||||||||||||
2218 | void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||||||||||||||||||||
2219 | int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) | - | ||||||||||||||||||||||||||||||||||||
2220 | { | - | ||||||||||||||||||||||||||||||||||||
2221 | const bool isWheel = detail >= 4 && detail <= 7; | - | ||||||||||||||||||||||||||||||||||||
2222 | if (!isWheel && window() != QGuiApplication::focusWindow()) { | - | ||||||||||||||||||||||||||||||||||||
2223 | QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver(); | - | ||||||||||||||||||||||||||||||||||||
2224 | if (!(w->flags() & (Qt::WindowDoesNotAcceptFocus | Qt::BypassWindowManagerHint)) | - | ||||||||||||||||||||||||||||||||||||
2225 | && w->type() != Qt::ToolTip | - | ||||||||||||||||||||||||||||||||||||
2226 | && w->type() != Qt::Popup) { | - | ||||||||||||||||||||||||||||||||||||
2227 | w->requestActivate(); | - | ||||||||||||||||||||||||||||||||||||
2228 | } | - | ||||||||||||||||||||||||||||||||||||
2229 | } | - | ||||||||||||||||||||||||||||||||||||
2230 | - | |||||||||||||||||||||||||||||||||||||
2231 | updateNetWmUserTime(timestamp); | - | ||||||||||||||||||||||||||||||||||||
2232 | - | |||||||||||||||||||||||||||||||||||||
2233 | if (m_embedded) { | - | ||||||||||||||||||||||||||||||||||||
2234 | if (window() != QGuiApplication::focusWindow()) { | - | ||||||||||||||||||||||||||||||||||||
2235 | const QXcbWindow *container = static_cast<const QXcbWindow *>(parent()); | - | ||||||||||||||||||||||||||||||||||||
2236 | Q_ASSERT(container != 0); | - | ||||||||||||||||||||||||||||||||||||
2237 | - | |||||||||||||||||||||||||||||||||||||
2238 | sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS); | - | ||||||||||||||||||||||||||||||||||||
2239 | } | - | ||||||||||||||||||||||||||||||||||||
2240 | } | - | ||||||||||||||||||||||||||||||||||||
2241 | QPoint local(event_x, event_y); | - | ||||||||||||||||||||||||||||||||||||
2242 | QPoint global(root_x, root_y); | - | ||||||||||||||||||||||||||||||||||||
2243 | - | |||||||||||||||||||||||||||||||||||||
2244 | if (isWheel) { | - | ||||||||||||||||||||||||||||||||||||
2245 | if (!connection()->isAtLeastXI21()) { | - | ||||||||||||||||||||||||||||||||||||
2246 | // Logic borrowed from qapplication_x11.cpp | - | ||||||||||||||||||||||||||||||||||||
2247 | int delta = 120 * ((detail == 4 || detail == 6) ? 1 : -1); | - | ||||||||||||||||||||||||||||||||||||
2248 | bool hor = (((detail == 4 || detail == 5) | - | ||||||||||||||||||||||||||||||||||||
2249 | && (modifiers & Qt::AltModifier)) | - | ||||||||||||||||||||||||||||||||||||
2250 | || (detail == 6 || detail == 7)); | - | ||||||||||||||||||||||||||||||||||||
2251 | - | |||||||||||||||||||||||||||||||||||||
2252 | QWindowSystemInterface::handleWheelEvent(window(), timestamp, | - | ||||||||||||||||||||||||||||||||||||
2253 | local, global, delta, hor ? Qt::Horizontal : Qt::Vertical, modifiers); | - | ||||||||||||||||||||||||||||||||||||
2254 | } | - | ||||||||||||||||||||||||||||||||||||
2255 | return; | - | ||||||||||||||||||||||||||||||||||||
2256 | } | - | ||||||||||||||||||||||||||||||||||||
2257 | - | |||||||||||||||||||||||||||||||||||||
2258 | connection()->setMousePressWindow(this); | - | ||||||||||||||||||||||||||||||||||||
2259 | - | |||||||||||||||||||||||||||||||||||||
2260 | handleMouseEvent(timestamp, local, global, modifiers, source); | - | ||||||||||||||||||||||||||||||||||||
2261 | } | - | ||||||||||||||||||||||||||||||||||||
2262 | - | |||||||||||||||||||||||||||||||||||||
2263 | void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||||||||||||||||||||
2264 | int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) | - | ||||||||||||||||||||||||||||||||||||
2265 | { | - | ||||||||||||||||||||||||||||||||||||
2266 | QPoint local(event_x, event_y); | - | ||||||||||||||||||||||||||||||||||||
2267 | QPoint global(root_x, root_y); | - | ||||||||||||||||||||||||||||||||||||
2268 | - | |||||||||||||||||||||||||||||||||||||
2269 | if (detail >= 4 && detail <= 7) { | - | ||||||||||||||||||||||||||||||||||||
2270 | // mouse wheel, handled in handleButtonPressEvent() | - | ||||||||||||||||||||||||||||||||||||
2271 | return; | - | ||||||||||||||||||||||||||||||||||||
2272 | } | - | ||||||||||||||||||||||||||||||||||||
2273 | - | |||||||||||||||||||||||||||||||||||||
2274 | if (connection()->buttons() == Qt::NoButton) | - | ||||||||||||||||||||||||||||||||||||
2275 | connection()->setMousePressWindow(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
2276 | - | |||||||||||||||||||||||||||||||||||||
2277 | handleMouseEvent(timestamp, local, global, modifiers, source); | - | ||||||||||||||||||||||||||||||||||||
2278 | } | - | ||||||||||||||||||||||||||||||||||||
2279 | - | |||||||||||||||||||||||||||||||||||||
2280 | static inline bool doCheckUnGrabAncestor(QXcbConnection *conn) | - | ||||||||||||||||||||||||||||||||||||
2281 | { | - | ||||||||||||||||||||||||||||||||||||
2282 | /* Checking for XCB_NOTIFY_MODE_GRAB and XCB_NOTIFY_DETAIL_ANCESTOR prevents unwanted | - | ||||||||||||||||||||||||||||||||||||
2283 | * enter/leave events on AwesomeWM on mouse button press. It also ignores duplicated | - | ||||||||||||||||||||||||||||||||||||
2284 | * enter/leave events on Alt+Tab switching on some WMs with XInput2 events. | - | ||||||||||||||||||||||||||||||||||||
2285 | * Without XInput2 events the (Un)grabAncestor cannot be checked when mouse button is | - | ||||||||||||||||||||||||||||||||||||
2286 | * not pressed, otherwise (e.g. on Alt+Tab) it can igonre important enter/leave events. | - | ||||||||||||||||||||||||||||||||||||
2287 | */ | - | ||||||||||||||||||||||||||||||||||||
2288 | if (conn) { | - | ||||||||||||||||||||||||||||||||||||
2289 | const bool mouseButtonsPressed = (conn->buttons() != Qt::NoButton); | - | ||||||||||||||||||||||||||||||||||||
2290 | #ifdef XCB_USE_XINPUT22 | - | ||||||||||||||||||||||||||||||||||||
2291 | return mouseButtonsPressed || (conn->isAtLeastXI22() && conn->xi2MouseEvents()); | - | ||||||||||||||||||||||||||||||||||||
2292 | #else | - | ||||||||||||||||||||||||||||||||||||
2293 | return mouseButtonsPressed; | - | ||||||||||||||||||||||||||||||||||||
2294 | #endif | - | ||||||||||||||||||||||||||||||||||||
2295 | } | - | ||||||||||||||||||||||||||||||||||||
2296 | return true; | - | ||||||||||||||||||||||||||||||||||||
2297 | } | - | ||||||||||||||||||||||||||||||||||||
2298 | - | |||||||||||||||||||||||||||||||||||||
2299 | static bool ignoreLeaveEvent(quint8 mode, quint8 detail, QXcbConnection *conn = Q_NULLPTR) | - | ||||||||||||||||||||||||||||||||||||
2300 | { | - | ||||||||||||||||||||||||||||||||||||
2301 | return ((doCheckUnGrabAncestor(conn) | - | ||||||||||||||||||||||||||||||||||||
2302 | && mode == XCB_NOTIFY_MODE_GRAB && detail == XCB_NOTIFY_DETAIL_ANCESTOR) | - | ||||||||||||||||||||||||||||||||||||
2303 | || (mode == XCB_NOTIFY_MODE_UNGRAB && detail == XCB_NOTIFY_DETAIL_INFERIOR) | - | ||||||||||||||||||||||||||||||||||||
2304 | || detail == XCB_NOTIFY_DETAIL_VIRTUAL | - | ||||||||||||||||||||||||||||||||||||
2305 | || detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL); | - | ||||||||||||||||||||||||||||||||||||
2306 | } | - | ||||||||||||||||||||||||||||||||||||
2307 | - | |||||||||||||||||||||||||||||||||||||
2308 | static bool ignoreEnterEvent(quint8 mode, quint8 detail, QXcbConnection *conn = Q_NULLPTR) | - | ||||||||||||||||||||||||||||||||||||
2309 | { | - | ||||||||||||||||||||||||||||||||||||
2310 | return ((doCheckUnGrabAncestor(conn) | - | ||||||||||||||||||||||||||||||||||||
2311 | && mode == XCB_NOTIFY_MODE_UNGRAB && detail == XCB_NOTIFY_DETAIL_ANCESTOR) | - | ||||||||||||||||||||||||||||||||||||
2312 | || (mode != XCB_NOTIFY_MODE_NORMAL && mode != XCB_NOTIFY_MODE_UNGRAB) | - | ||||||||||||||||||||||||||||||||||||
2313 | || detail == XCB_NOTIFY_DETAIL_VIRTUAL | - | ||||||||||||||||||||||||||||||||||||
2314 | || detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL); | - | ||||||||||||||||||||||||||||||||||||
2315 | } | - | ||||||||||||||||||||||||||||||||||||
2316 | - | |||||||||||||||||||||||||||||||||||||
2317 | class EnterEventChecker | - | ||||||||||||||||||||||||||||||||||||
2318 | { | - | ||||||||||||||||||||||||||||||||||||
2319 | public: | - | ||||||||||||||||||||||||||||||||||||
2320 | bool checkEvent(xcb_generic_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2321 | { | - | ||||||||||||||||||||||||||||||||||||
2322 | if (!event) | - | ||||||||||||||||||||||||||||||||||||
2323 | return false; | - | ||||||||||||||||||||||||||||||||||||
2324 | if ((event->response_type & ~0x80) != XCB_ENTER_NOTIFY) | - | ||||||||||||||||||||||||||||||||||||
2325 | return false; | - | ||||||||||||||||||||||||||||||||||||
2326 | - | |||||||||||||||||||||||||||||||||||||
2327 | xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)event; | - | ||||||||||||||||||||||||||||||||||||
2328 | if (ignoreEnterEvent(enter->mode, enter->detail)) | - | ||||||||||||||||||||||||||||||||||||
2329 | return false; | - | ||||||||||||||||||||||||||||||||||||
2330 | - | |||||||||||||||||||||||||||||||||||||
2331 | return true; | - | ||||||||||||||||||||||||||||||||||||
2332 | } | - | ||||||||||||||||||||||||||||||||||||
2333 | }; | - | ||||||||||||||||||||||||||||||||||||
2334 | - | |||||||||||||||||||||||||||||||||||||
2335 | void QXcbWindow::handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||||||||||||||||||||
2336 | quint8 mode, quint8 detail, xcb_timestamp_t timestamp) | - | ||||||||||||||||||||||||||||||||||||
2337 | { | - | ||||||||||||||||||||||||||||||||||||
2338 | connection()->setTime(timestamp); | - | ||||||||||||||||||||||||||||||||||||
2339 | #ifdef XCB_USE_XINPUT21 | - | ||||||||||||||||||||||||||||||||||||
2340 | connection()->handleEnterEvent(); | - | ||||||||||||||||||||||||||||||||||||
2341 | #endif | - | ||||||||||||||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||||||||||||||
2343 | const QPoint global = QPoint(root_x, root_y); | - | ||||||||||||||||||||||||||||||||||||
2344 | - | |||||||||||||||||||||||||||||||||||||
2345 | if (ignoreEnterEvent(mode, detail, connection()) || connection()->mousePressWindow()) | - | ||||||||||||||||||||||||||||||||||||
2346 | return; | - | ||||||||||||||||||||||||||||||||||||
2347 | - | |||||||||||||||||||||||||||||||||||||
2348 | const QPoint local(event_x, event_y); | - | ||||||||||||||||||||||||||||||||||||
2349 | QWindowSystemInterface::handleEnterEvent(window(), local, global); | - | ||||||||||||||||||||||||||||||||||||
2350 | } | - | ||||||||||||||||||||||||||||||||||||
2351 | - | |||||||||||||||||||||||||||||||||||||
2352 | void QXcbWindow::handleLeaveNotifyEvent(int root_x, int root_y, | - | ||||||||||||||||||||||||||||||||||||
2353 | quint8 mode, quint8 detail, xcb_timestamp_t timestamp) | - | ||||||||||||||||||||||||||||||||||||
2354 | { | - | ||||||||||||||||||||||||||||||||||||
2355 | connection()->setTime(timestamp); | - | ||||||||||||||||||||||||||||||||||||
2356 | - | |||||||||||||||||||||||||||||||||||||
2357 | if (ignoreLeaveEvent(mode, detail, connection()) || connection()->mousePressWindow()) | - | ||||||||||||||||||||||||||||||||||||
2358 | return; | - | ||||||||||||||||||||||||||||||||||||
2359 | - | |||||||||||||||||||||||||||||||||||||
2360 | EnterEventChecker checker; | - | ||||||||||||||||||||||||||||||||||||
2361 | xcb_enter_notify_event_t *enter = (xcb_enter_notify_event_t *)connection()->checkEvent(checker); | - | ||||||||||||||||||||||||||||||||||||
2362 | QXcbWindow *enterWindow = enter ? connection()->platformWindowFromId(enter->event) : 0; | - | ||||||||||||||||||||||||||||||||||||
2363 | - | |||||||||||||||||||||||||||||||||||||
2364 | if (enterWindow) { | - | ||||||||||||||||||||||||||||||||||||
2365 | QPoint local(enter->event_x, enter->event_y); | - | ||||||||||||||||||||||||||||||||||||
2366 | QPoint global = QPoint(root_x, root_y); | - | ||||||||||||||||||||||||||||||||||||
2367 | QWindowSystemInterface::handleEnterLeaveEvent(enterWindow->window(), window(), local, global); | - | ||||||||||||||||||||||||||||||||||||
2368 | } else { | - | ||||||||||||||||||||||||||||||||||||
2369 | QWindowSystemInterface::handleLeaveEvent(window()); | - | ||||||||||||||||||||||||||||||||||||
2370 | } | - | ||||||||||||||||||||||||||||||||||||
2371 | - | |||||||||||||||||||||||||||||||||||||
2372 | free(enter); | - | ||||||||||||||||||||||||||||||||||||
2373 | } | - | ||||||||||||||||||||||||||||||||||||
2374 | - | |||||||||||||||||||||||||||||||||||||
2375 | void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y, | - | ||||||||||||||||||||||||||||||||||||
2376 | Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp, Qt::MouseEventSource source) | - | ||||||||||||||||||||||||||||||||||||
2377 | { | - | ||||||||||||||||||||||||||||||||||||
2378 | QPoint local(event_x, event_y); | - | ||||||||||||||||||||||||||||||||||||
2379 | QPoint global(root_x, root_y); | - | ||||||||||||||||||||||||||||||||||||
2380 | - | |||||||||||||||||||||||||||||||||||||
2381 | // "mousePressWindow" can be NULL i.e. if a window will be grabbed or unmapped, so set it again here. | - | ||||||||||||||||||||||||||||||||||||
2382 | // Unset "mousePressWindow" when mouse button isn't pressed - in some cases the release event won't arrive. | - | ||||||||||||||||||||||||||||||||||||
2383 | const bool isMouseButtonPressed = (connection()->buttons() != Qt::NoButton); | - | ||||||||||||||||||||||||||||||||||||
2384 | const bool hasMousePressWindow = (connection()->mousePressWindow() != Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
2385 | if (isMouseButtonPressed && !hasMousePressWindow) | - | ||||||||||||||||||||||||||||||||||||
2386 | connection()->setMousePressWindow(this); | - | ||||||||||||||||||||||||||||||||||||
2387 | else if (hasMousePressWindow && !isMouseButtonPressed) | - | ||||||||||||||||||||||||||||||||||||
2388 | connection()->setMousePressWindow(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
2389 | - | |||||||||||||||||||||||||||||||||||||
2390 | handleMouseEvent(timestamp, local, global, modifiers, source); | - | ||||||||||||||||||||||||||||||||||||
2391 | } | - | ||||||||||||||||||||||||||||||||||||
2392 | - | |||||||||||||||||||||||||||||||||||||
2393 | // Handlers for plain xcb events. Used only when XI 2.2 or newer is not available. | - | ||||||||||||||||||||||||||||||||||||
2394 | void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2395 | { | - | ||||||||||||||||||||||||||||||||||||
2396 | Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); | - | ||||||||||||||||||||||||||||||||||||
2397 | handleButtonPressEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail, | - | ||||||||||||||||||||||||||||||||||||
2398 | modifiers, event->time); | - | ||||||||||||||||||||||||||||||||||||
2399 | } | - | ||||||||||||||||||||||||||||||||||||
2400 | - | |||||||||||||||||||||||||||||||||||||
2401 | void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2402 | { | - | ||||||||||||||||||||||||||||||||||||
2403 | Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); | - | ||||||||||||||||||||||||||||||||||||
2404 | handleButtonReleaseEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail, | - | ||||||||||||||||||||||||||||||||||||
2405 | modifiers, event->time); | - | ||||||||||||||||||||||||||||||||||||
2406 | } | - | ||||||||||||||||||||||||||||||||||||
2407 | - | |||||||||||||||||||||||||||||||||||||
2408 | void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2409 | { | - | ||||||||||||||||||||||||||||||||||||
2410 | Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state); | - | ||||||||||||||||||||||||||||||||||||
2411 | handleMotionNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, modifiers, event->time); | - | ||||||||||||||||||||||||||||||||||||
2412 | } | - | ||||||||||||||||||||||||||||||||||||
2413 | - | |||||||||||||||||||||||||||||||||||||
2414 | #ifdef XCB_USE_XINPUT22 | - | ||||||||||||||||||||||||||||||||||||
2415 | static inline int fixed1616ToInt(FP1616 val) | - | ||||||||||||||||||||||||||||||||||||
2416 | { | - | ||||||||||||||||||||||||||||||||||||
2417 | return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF); | - | ||||||||||||||||||||||||||||||||||||
2418 | } | - | ||||||||||||||||||||||||||||||||||||
2419 | - | |||||||||||||||||||||||||||||||||||||
2420 | // With XI 2.2+ press/release/motion comes here instead of the above handlers. | - | ||||||||||||||||||||||||||||||||||||
2421 | void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) | - | ||||||||||||||||||||||||||||||||||||
2422 | { | - | ||||||||||||||||||||||||||||||||||||
2423 | QXcbConnection *conn = connection(); | - | ||||||||||||||||||||||||||||||||||||
2424 | xXIDeviceEvent *ev = reinterpret_cast<xXIDeviceEvent *>(event); | - | ||||||||||||||||||||||||||||||||||||
2425 | const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective_mods); | - | ||||||||||||||||||||||||||||||||||||
2426 | const int event_x = fixed1616ToInt(ev->event_x); | - | ||||||||||||||||||||||||||||||||||||
2427 | const int event_y = fixed1616ToInt(ev->event_y); | - | ||||||||||||||||||||||||||||||||||||
2428 | const int root_x = fixed1616ToInt(ev->root_x); | - | ||||||||||||||||||||||||||||||||||||
2429 | const int root_y = fixed1616ToInt(ev->root_y); | - | ||||||||||||||||||||||||||||||||||||
2430 | - | |||||||||||||||||||||||||||||||||||||
2431 | conn->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group); | - | ||||||||||||||||||||||||||||||||||||
2432 | - | |||||||||||||||||||||||||||||||||||||
2433 | const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail); | - | ||||||||||||||||||||||||||||||||||||
2434 | - | |||||||||||||||||||||||||||||||||||||
2435 | if (ev->buttons_len > 0) { | - | ||||||||||||||||||||||||||||||||||||
2436 | unsigned char *buttonMask = (unsigned char *) &ev[1]; | - | ||||||||||||||||||||||||||||||||||||
2437 | for (int i = 1; i <= 15; ++i) | - | ||||||||||||||||||||||||||||||||||||
2438 | conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i)); | - | ||||||||||||||||||||||||||||||||||||
2439 | } | - | ||||||||||||||||||||||||||||||||||||
2440 | - | |||||||||||||||||||||||||||||||||||||
2441 | const char *sourceName = 0; | - | ||||||||||||||||||||||||||||||||||||
2442 | if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) { | - | ||||||||||||||||||||||||||||||||||||
2443 | const QMetaObject *metaObject = qt_getEnumMetaObject(source); | - | ||||||||||||||||||||||||||||||||||||
2444 | const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source))); | - | ||||||||||||||||||||||||||||||||||||
2445 | sourceName = me.valueToKey(source); | - | ||||||||||||||||||||||||||||||||||||
2446 | } | - | ||||||||||||||||||||||||||||||||||||
2447 | - | |||||||||||||||||||||||||||||||||||||
2448 | switch (ev->evtype) { | - | ||||||||||||||||||||||||||||||||||||
2449 | case XI_ButtonPress: | - | ||||||||||||||||||||||||||||||||||||
2450 | if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) | - | ||||||||||||||||||||||||||||||||||||
2451 | qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); | - | ||||||||||||||||||||||||||||||||||||
2452 | conn->setButton(button, true); | - | ||||||||||||||||||||||||||||||||||||
2453 | handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); | - | ||||||||||||||||||||||||||||||||||||
2454 | break; | - | ||||||||||||||||||||||||||||||||||||
2455 | case XI_ButtonRelease: | - | ||||||||||||||||||||||||||||||||||||
2456 | if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) | - | ||||||||||||||||||||||||||||||||||||
2457 | qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); | - | ||||||||||||||||||||||||||||||||||||
2458 | conn->setButton(button, false); | - | ||||||||||||||||||||||||||||||||||||
2459 | handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); | - | ||||||||||||||||||||||||||||||||||||
2460 | break; | - | ||||||||||||||||||||||||||||||||||||
2461 | case XI_Motion: | - | ||||||||||||||||||||||||||||||||||||
2462 | if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) | - | ||||||||||||||||||||||||||||||||||||
2463 | qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); | - | ||||||||||||||||||||||||||||||||||||
2464 | handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); | - | ||||||||||||||||||||||||||||||||||||
2465 | break; | - | ||||||||||||||||||||||||||||||||||||
2466 | default: | - | ||||||||||||||||||||||||||||||||||||
2467 | qWarning() << "Unrecognized XI2 mouse event" << ev->evtype; | - | ||||||||||||||||||||||||||||||||||||
2468 | break; | - | ||||||||||||||||||||||||||||||||||||
2469 | } | - | ||||||||||||||||||||||||||||||||||||
2470 | } | - | ||||||||||||||||||||||||||||||||||||
2471 | - | |||||||||||||||||||||||||||||||||||||
2472 | // With XI 2.2+ enter/leave comes here and are blocked in plain xcb events | - | ||||||||||||||||||||||||||||||||||||
2473 | void QXcbWindow::handleXIEnterLeave(xcb_ge_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2474 | { | - | ||||||||||||||||||||||||||||||||||||
2475 | xXIEnterEvent *ev = reinterpret_cast<xXIEnterEvent *>(event); | - | ||||||||||||||||||||||||||||||||||||
2476 | - | |||||||||||||||||||||||||||||||||||||
2477 | // Compare the window with current mouse grabber to prevent deliver events to any other windows. | - | ||||||||||||||||||||||||||||||||||||
2478 | // If leave event occurs and the window is under mouse - allow to deliver the leave event. | - | ||||||||||||||||||||||||||||||||||||
2479 | QXcbWindow *mouseGrabber = connection()->mouseGrabber(); | - | ||||||||||||||||||||||||||||||||||||
2480 | if (mouseGrabber && mouseGrabber != this | - | ||||||||||||||||||||||||||||||||||||
2481 | && (ev->evtype != XI_Leave || QGuiApplicationPrivate::currentMouseWindow != window())) { | - | ||||||||||||||||||||||||||||||||||||
2482 | return; | - | ||||||||||||||||||||||||||||||||||||
2483 | } | - | ||||||||||||||||||||||||||||||||||||
2484 | - | |||||||||||||||||||||||||||||||||||||
2485 | const int root_x = fixed1616ToInt(ev->root_x); | - | ||||||||||||||||||||||||||||||||||||
2486 | const int root_y = fixed1616ToInt(ev->root_y); | - | ||||||||||||||||||||||||||||||||||||
2487 | - | |||||||||||||||||||||||||||||||||||||
2488 | switch (ev->evtype) { | - | ||||||||||||||||||||||||||||||||||||
2489 | case XI_Enter: { | - | ||||||||||||||||||||||||||||||||||||
2490 | const int event_x = fixed1616ToInt(ev->event_x); | - | ||||||||||||||||||||||||||||||||||||
2491 | const int event_y = fixed1616ToInt(ev->event_y); | - | ||||||||||||||||||||||||||||||||||||
2492 | qCDebug(lcQpaXInput, "XI2 mouse enter %d,%d, mode %d, detail %d, time %d", event_x, event_y, ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||||||||||||||||||||
2493 | handleEnterNotifyEvent(event_x, event_y, root_x, root_y, ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||||||||||||||||||||
2494 | break; | - | ||||||||||||||||||||||||||||||||||||
2495 | } | - | ||||||||||||||||||||||||||||||||||||
2496 | case XI_Leave: | - | ||||||||||||||||||||||||||||||||||||
2497 | qCDebug(lcQpaXInput, "XI2 mouse leave, mode %d, detail %d, time %d", ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||||||||||||||||||||
2498 | connection()->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group); | - | ||||||||||||||||||||||||||||||||||||
2499 | handleLeaveNotifyEvent(root_x, root_y, ev->mode, ev->detail, ev->time); | - | ||||||||||||||||||||||||||||||||||||
2500 | break; | - | ||||||||||||||||||||||||||||||||||||
2501 | } | - | ||||||||||||||||||||||||||||||||||||
2502 | } | - | ||||||||||||||||||||||||||||||||||||
2503 | #endif | - | ||||||||||||||||||||||||||||||||||||
2504 | - | |||||||||||||||||||||||||||||||||||||
2505 | QXcbWindow *QXcbWindow::toWindow() { return this; } | - | ||||||||||||||||||||||||||||||||||||
2506 | - | |||||||||||||||||||||||||||||||||||||
2507 | void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, | - | ||||||||||||||||||||||||||||||||||||
2508 | Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source) | - | ||||||||||||||||||||||||||||||||||||
2509 | { | - | ||||||||||||||||||||||||||||||||||||
2510 | connection()->setTime(time); | - | ||||||||||||||||||||||||||||||||||||
2511 | QWindowSystemInterface::handleMouseEvent(window(), time, local, global, connection()->buttons(), modifiers, source); | - | ||||||||||||||||||||||||||||||||||||
2512 | } | - | ||||||||||||||||||||||||||||||||||||
2513 | - | |||||||||||||||||||||||||||||||||||||
2514 | void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2515 | { | - | ||||||||||||||||||||||||||||||||||||
2516 | handleEnterNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->mode, event->detail, event->time); | - | ||||||||||||||||||||||||||||||||||||
2517 | } | - | ||||||||||||||||||||||||||||||||||||
2518 | - | |||||||||||||||||||||||||||||||||||||
2519 | void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2520 | { | - | ||||||||||||||||||||||||||||||||||||
2521 | handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time); | - | ||||||||||||||||||||||||||||||||||||
2522 | } | - | ||||||||||||||||||||||||||||||||||||
2523 | - | |||||||||||||||||||||||||||||||||||||
2524 | void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2525 | { | - | ||||||||||||||||||||||||||||||||||||
2526 | connection()->setTime(event->time); | - | ||||||||||||||||||||||||||||||||||||
2527 | - | |||||||||||||||||||||||||||||||||||||
2528 | const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE; | - | ||||||||||||||||||||||||||||||||||||
2529 | - | |||||||||||||||||||||||||||||||||||||
2530 | if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) { | - | ||||||||||||||||||||||||||||||||||||
2531 | if (propertyDeleted) | - | ||||||||||||||||||||||||||||||||||||
2532 | return; | - | ||||||||||||||||||||||||||||||||||||
2533 | - | |||||||||||||||||||||||||||||||||||||
2534 | Qt::WindowState newState = Qt::WindowNoState; | - | ||||||||||||||||||||||||||||||||||||
2535 | if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'. | - | ||||||||||||||||||||||||||||||||||||
2536 | const xcb_get_property_cookie_t get_cookie = | - | ||||||||||||||||||||||||||||||||||||
2537 | xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE), | - | ||||||||||||||||||||||||||||||||||||
2538 | XCB_ATOM_ANY, 0, 1024); | - | ||||||||||||||||||||||||||||||||||||
2539 | - | |||||||||||||||||||||||||||||||||||||
2540 | xcb_get_property_reply_t *reply = | - | ||||||||||||||||||||||||||||||||||||
2541 | xcb_get_property_reply(xcb_connection(), get_cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
2542 | - | |||||||||||||||||||||||||||||||||||||
2543 | if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { | - | ||||||||||||||||||||||||||||||||||||
2544 | const quint32 *data = (const quint32 *)xcb_get_property_value(reply); | - | ||||||||||||||||||||||||||||||||||||
2545 | if (reply->length != 0) { | - | ||||||||||||||||||||||||||||||||||||
2546 | if (data[0] == XCB_WM_STATE_ICONIC | - | ||||||||||||||||||||||||||||||||||||
2547 | || (data[0] == XCB_WM_STATE_WITHDRAWN | - | ||||||||||||||||||||||||||||||||||||
2548 | && m_lastWindowStateEvent == Qt::WindowMinimized)) { | - | ||||||||||||||||||||||||||||||||||||
2549 | newState = Qt::WindowMinimized; | - | ||||||||||||||||||||||||||||||||||||
2550 | } | - | ||||||||||||||||||||||||||||||||||||
2551 | } | - | ||||||||||||||||||||||||||||||||||||
2552 | } | - | ||||||||||||||||||||||||||||||||||||
2553 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
2554 | } else { // _NET_WM_STATE can't change minimized state | - | ||||||||||||||||||||||||||||||||||||
2555 | if (m_lastWindowStateEvent == Qt::WindowMinimized) | - | ||||||||||||||||||||||||||||||||||||
2556 | newState = Qt::WindowMinimized; | - | ||||||||||||||||||||||||||||||||||||
2557 | } | - | ||||||||||||||||||||||||||||||||||||
2558 | - | |||||||||||||||||||||||||||||||||||||
2559 | if (newState != Qt::WindowMinimized) { // Something else changed, get _NET_WM_STATE. | - | ||||||||||||||||||||||||||||||||||||
2560 | const NetWmStates states = netWmStates(); | - | ||||||||||||||||||||||||||||||||||||
2561 | if (states & NetWmStateFullScreen) | - | ||||||||||||||||||||||||||||||||||||
2562 | newState = Qt::WindowFullScreen; | - | ||||||||||||||||||||||||||||||||||||
2563 | else if ((states & NetWmStateMaximizedHorz) && (states & NetWmStateMaximizedVert)) | - | ||||||||||||||||||||||||||||||||||||
2564 | newState = Qt::WindowMaximized; | - | ||||||||||||||||||||||||||||||||||||
2565 | } | - | ||||||||||||||||||||||||||||||||||||
2566 | // Send Window state, compress events in case other flags (modality, etc) are changed. | - | ||||||||||||||||||||||||||||||||||||
2567 | if (m_lastWindowStateEvent != newState) { | - | ||||||||||||||||||||||||||||||||||||
2568 | QWindowSystemInterface::handleWindowStateChanged(window(), newState); | - | ||||||||||||||||||||||||||||||||||||
2569 | m_lastWindowStateEvent = newState; | - | ||||||||||||||||||||||||||||||||||||
2570 | m_windowState = newState; | - | ||||||||||||||||||||||||||||||||||||
2571 | if (m_windowState == Qt::WindowMinimized && connection()->mouseGrabber() == this) | - | ||||||||||||||||||||||||||||||||||||
2572 | connection()->setMouseGrabber(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
2573 | } | - | ||||||||||||||||||||||||||||||||||||
2574 | return; | - | ||||||||||||||||||||||||||||||||||||
2575 | } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) { | - | ||||||||||||||||||||||||||||||||||||
2576 | m_dirtyFrameMargins = true; | - | ||||||||||||||||||||||||||||||||||||
2577 | } | - | ||||||||||||||||||||||||||||||||||||
2578 | } | - | ||||||||||||||||||||||||||||||||||||
2579 | - | |||||||||||||||||||||||||||||||||||||
2580 | void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2581 | { | - | ||||||||||||||||||||||||||||||||||||
2582 | // Ignore focus events that are being sent only because the pointer is over | - | ||||||||||||||||||||||||||||||||||||
2583 | // our window, even if the input focus is in a different window. | - | ||||||||||||||||||||||||||||||||||||
2584 | if (event->detail == XCB_NOTIFY_DETAIL_POINTER) | - | ||||||||||||||||||||||||||||||||||||
2585 | return; | - | ||||||||||||||||||||||||||||||||||||
2586 | doFocusIn(); | - | ||||||||||||||||||||||||||||||||||||
2587 | } | - | ||||||||||||||||||||||||||||||||||||
2588 | - | |||||||||||||||||||||||||||||||||||||
2589 | - | |||||||||||||||||||||||||||||||||||||
2590 | void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2591 | { | - | ||||||||||||||||||||||||||||||||||||
2592 | // Ignore focus events that are being sent only because the pointer is over | - | ||||||||||||||||||||||||||||||||||||
2593 | // our window, even if the input focus is in a different window. | - | ||||||||||||||||||||||||||||||||||||
2594 | if (event->detail == XCB_NOTIFY_DETAIL_POINTER) | - | ||||||||||||||||||||||||||||||||||||
2595 | return; | - | ||||||||||||||||||||||||||||||||||||
2596 | doFocusOut(); | - | ||||||||||||||||||||||||||||||||||||
2597 | } | - | ||||||||||||||||||||||||||||||||||||
2598 | - | |||||||||||||||||||||||||||||||||||||
2599 | void QXcbWindow::updateSyncRequestCounter() | - | ||||||||||||||||||||||||||||||||||||
2600 | { | - | ||||||||||||||||||||||||||||||||||||
2601 | if (m_syncState != SyncAndConfigureReceived) { | - | ||||||||||||||||||||||||||||||||||||
2602 | // window manager does not expect a sync event yet. | - | ||||||||||||||||||||||||||||||||||||
2603 | return; | - | ||||||||||||||||||||||||||||||||||||
2604 | } | - | ||||||||||||||||||||||||||||||||||||
2605 | if (m_usingSyncProtocol && (m_syncValue.lo != 0 || m_syncValue.hi != 0)) { | - | ||||||||||||||||||||||||||||||||||||
2606 | Q_XCB_CALL(xcb_sync_set_counter(xcb_connection(), m_syncCounter, m_syncValue)); | - | ||||||||||||||||||||||||||||||||||||
2607 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
2608 | - | |||||||||||||||||||||||||||||||||||||
2609 | m_syncValue.lo = 0; | - | ||||||||||||||||||||||||||||||||||||
2610 | m_syncValue.hi = 0; | - | ||||||||||||||||||||||||||||||||||||
2611 | m_syncState = NoSyncNeeded; | - | ||||||||||||||||||||||||||||||||||||
2612 | } | - | ||||||||||||||||||||||||||||||||||||
2613 | } | - | ||||||||||||||||||||||||||||||||||||
2614 | - | |||||||||||||||||||||||||||||||||||||
2615 | const xcb_visualtype_t *QXcbWindow::createVisual() | - | ||||||||||||||||||||||||||||||||||||
2616 | { | - | ||||||||||||||||||||||||||||||||||||
2617 | return xcbScreen() ? xcbScreen()->visualForFormat(m_format) executed 133 times by 12 tests: return xcbScreen() ? xcbScreen()->visualForFormat(m_format) : nullptr; Executed by:
| 133 | ||||||||||||||||||||||||||||||||||||
2618 | : nullptr; executed 133 times by 12 tests: return xcbScreen() ? xcbScreen()->visualForFormat(m_format) : nullptr; Executed by:
| 133 | ||||||||||||||||||||||||||||||||||||
2619 | } | - | ||||||||||||||||||||||||||||||||||||
2620 | - | |||||||||||||||||||||||||||||||||||||
2621 | bool QXcbWindow::setKeyboardGrabEnabled(bool grab) | - | ||||||||||||||||||||||||||||||||||||
2622 | { | - | ||||||||||||||||||||||||||||||||||||
2623 | if (grab && !connection()->canGrab()) | - | ||||||||||||||||||||||||||||||||||||
2624 | return false; | - | ||||||||||||||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||||||||||||||
2626 | if (!grab) { | - | ||||||||||||||||||||||||||||||||||||
2627 | xcb_ungrab_keyboard(xcb_connection(), XCB_TIME_CURRENT_TIME); | - | ||||||||||||||||||||||||||||||||||||
2628 | return true; | - | ||||||||||||||||||||||||||||||||||||
2629 | } | - | ||||||||||||||||||||||||||||||||||||
2630 | xcb_grab_keyboard_cookie_t cookie = xcb_grab_keyboard(xcb_connection(), false, | - | ||||||||||||||||||||||||||||||||||||
2631 | m_window, XCB_TIME_CURRENT_TIME, | - | ||||||||||||||||||||||||||||||||||||
2632 | XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); | - | ||||||||||||||||||||||||||||||||||||
2633 | xcb_grab_keyboard_reply_t *reply = xcb_grab_keyboard_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
2634 | bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); | - | ||||||||||||||||||||||||||||||||||||
2635 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
2636 | return result; | - | ||||||||||||||||||||||||||||||||||||
2637 | } | - | ||||||||||||||||||||||||||||||||||||
2638 | - | |||||||||||||||||||||||||||||||||||||
2639 | bool QXcbWindow::setMouseGrabEnabled(bool grab) | - | ||||||||||||||||||||||||||||||||||||
2640 | { | - | ||||||||||||||||||||||||||||||||||||
2641 | if (!grab && connection()->mouseGrabber() == this) | - | ||||||||||||||||||||||||||||||||||||
2642 | connection()->setMouseGrabber(Q_NULLPTR); | - | ||||||||||||||||||||||||||||||||||||
2643 | #ifdef XCB_USE_XINPUT22 | - | ||||||||||||||||||||||||||||||||||||
2644 | if (connection()->isAtLeastXI22() && connection()->xi2MouseEvents()) { | - | ||||||||||||||||||||||||||||||||||||
2645 | bool result = connection()->xi2SetMouseGrabEnabled(m_window, grab); | - | ||||||||||||||||||||||||||||||||||||
2646 | if (grab && result) | - | ||||||||||||||||||||||||||||||||||||
2647 | connection()->setMouseGrabber(this); | - | ||||||||||||||||||||||||||||||||||||
2648 | return result; | - | ||||||||||||||||||||||||||||||||||||
2649 | } | - | ||||||||||||||||||||||||||||||||||||
2650 | #endif | - | ||||||||||||||||||||||||||||||||||||
2651 | if (grab && !connection()->canGrab()) | - | ||||||||||||||||||||||||||||||||||||
2652 | return false; | - | ||||||||||||||||||||||||||||||||||||
2653 | - | |||||||||||||||||||||||||||||||||||||
2654 | if (!grab) { | - | ||||||||||||||||||||||||||||||||||||
2655 | xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME); | - | ||||||||||||||||||||||||||||||||||||
2656 | return true; | - | ||||||||||||||||||||||||||||||||||||
2657 | } | - | ||||||||||||||||||||||||||||||||||||
2658 | xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer(xcb_connection(), false, m_window, | - | ||||||||||||||||||||||||||||||||||||
2659 | (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | - | ||||||||||||||||||||||||||||||||||||
2660 | | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | - | ||||||||||||||||||||||||||||||||||||
2661 | | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION), | - | ||||||||||||||||||||||||||||||||||||
2662 | XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, | - | ||||||||||||||||||||||||||||||||||||
2663 | XCB_WINDOW_NONE, XCB_CURSOR_NONE, | - | ||||||||||||||||||||||||||||||||||||
2664 | XCB_TIME_CURRENT_TIME); | - | ||||||||||||||||||||||||||||||||||||
2665 | xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||||||||||||||||||||||||||
2666 | bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); | - | ||||||||||||||||||||||||||||||||||||
2667 | free(reply); | - | ||||||||||||||||||||||||||||||||||||
2668 | if (result) | - | ||||||||||||||||||||||||||||||||||||
2669 | connection()->setMouseGrabber(this); | - | ||||||||||||||||||||||||||||||||||||
2670 | return result; | - | ||||||||||||||||||||||||||||||||||||
2671 | } | - | ||||||||||||||||||||||||||||||||||||
2672 | - | |||||||||||||||||||||||||||||||||||||
2673 | void QXcbWindow::setCursor(xcb_cursor_t cursor, bool isBitmapCursor) | - | ||||||||||||||||||||||||||||||||||||
2674 | { | - | ||||||||||||||||||||||||||||||||||||
2675 | xcb_connection_t *conn = xcb_connection(); | - | ||||||||||||||||||||||||||||||||||||
2676 | - | |||||||||||||||||||||||||||||||||||||
2677 | xcb_change_window_attributes(conn, m_window, XCB_CW_CURSOR, &cursor); | - | ||||||||||||||||||||||||||||||||||||
2678 | xcb_flush(conn); | - | ||||||||||||||||||||||||||||||||||||
2679 | - | |||||||||||||||||||||||||||||||||||||
2680 | if (m_currentBitmapCursor != XCB_CURSOR_NONE) { | - | ||||||||||||||||||||||||||||||||||||
2681 | xcb_free_cursor(conn, m_currentBitmapCursor); | - | ||||||||||||||||||||||||||||||||||||
2682 | } | - | ||||||||||||||||||||||||||||||||||||
2683 | - | |||||||||||||||||||||||||||||||||||||
2684 | if (isBitmapCursor) { | - | ||||||||||||||||||||||||||||||||||||
2685 | m_currentBitmapCursor = cursor; | - | ||||||||||||||||||||||||||||||||||||
2686 | } else { | - | ||||||||||||||||||||||||||||||||||||
2687 | m_currentBitmapCursor = XCB_CURSOR_NONE; | - | ||||||||||||||||||||||||||||||||||||
2688 | } | - | ||||||||||||||||||||||||||||||||||||
2689 | } | - | ||||||||||||||||||||||||||||||||||||
2690 | - | |||||||||||||||||||||||||||||||||||||
2691 | void QXcbWindow::windowEvent(QEvent *event) | - | ||||||||||||||||||||||||||||||||||||
2692 | { | - | ||||||||||||||||||||||||||||||||||||
2693 | switch (event->type()) { | - | ||||||||||||||||||||||||||||||||||||
2694 | case QEvent::FocusIn: | - | ||||||||||||||||||||||||||||||||||||
2695 | if (m_embedded && !event->spontaneous()) { | - | ||||||||||||||||||||||||||||||||||||
2696 | QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event); | - | ||||||||||||||||||||||||||||||||||||
2697 | switch (focusEvent->reason()) { | - | ||||||||||||||||||||||||||||||||||||
2698 | case Qt::TabFocusReason: | - | ||||||||||||||||||||||||||||||||||||
2699 | case Qt::BacktabFocusReason: | - | ||||||||||||||||||||||||||||||||||||
2700 | { | - | ||||||||||||||||||||||||||||||||||||
2701 | const QXcbWindow *container = | - | ||||||||||||||||||||||||||||||||||||
2702 | static_cast<const QXcbWindow *>(parent()); | - | ||||||||||||||||||||||||||||||||||||
2703 | sendXEmbedMessage(container->xcb_window(), | - | ||||||||||||||||||||||||||||||||||||
2704 | focusEvent->reason() == Qt::TabFocusReason ? | - | ||||||||||||||||||||||||||||||||||||
2705 | XEMBED_FOCUS_NEXT : XEMBED_FOCUS_PREV); | - | ||||||||||||||||||||||||||||||||||||
2706 | event->accept(); | - | ||||||||||||||||||||||||||||||||||||
2707 | } | - | ||||||||||||||||||||||||||||||||||||
2708 | break; | - | ||||||||||||||||||||||||||||||||||||
2709 | default: | - | ||||||||||||||||||||||||||||||||||||
2710 | break; | - | ||||||||||||||||||||||||||||||||||||
2711 | } | - | ||||||||||||||||||||||||||||||||||||
2712 | } | - | ||||||||||||||||||||||||||||||||||||
2713 | break; | - | ||||||||||||||||||||||||||||||||||||
2714 | default: | - | ||||||||||||||||||||||||||||||||||||
2715 | break; | - | ||||||||||||||||||||||||||||||||||||
2716 | } | - | ||||||||||||||||||||||||||||||||||||
2717 | QPlatformWindow::windowEvent(event); | - | ||||||||||||||||||||||||||||||||||||
2718 | } | - | ||||||||||||||||||||||||||||||||||||
2719 | - | |||||||||||||||||||||||||||||||||||||
2720 | bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) | - | ||||||||||||||||||||||||||||||||||||
2721 | { | - | ||||||||||||||||||||||||||||||||||||
2722 | const xcb_atom_t moveResize = connection()->atom(QXcbAtom::_NET_WM_MOVERESIZE); | - | ||||||||||||||||||||||||||||||||||||
2723 | if (!connection()->wmSupport()->isSupportedByWM(moveResize)) | - | ||||||||||||||||||||||||||||||||||||
2724 | return false; | - | ||||||||||||||||||||||||||||||||||||
2725 | xcb_client_message_event_t xev; | - | ||||||||||||||||||||||||||||||||||||
2726 | xev.response_type = XCB_CLIENT_MESSAGE; | - | ||||||||||||||||||||||||||||||||||||
2727 | xev.type = moveResize; | - | ||||||||||||||||||||||||||||||||||||
2728 | xev.sequence = 0; | - | ||||||||||||||||||||||||||||||||||||
2729 | xev.window = xcb_window(); | - | ||||||||||||||||||||||||||||||||||||
2730 | xev.format = 32; | - | ||||||||||||||||||||||||||||||||||||
2731 | const QPoint globalPos = window()->mapToGlobal(pos); | - | ||||||||||||||||||||||||||||||||||||
2732 | xev.data.data32[0] = globalPos.x(); | - | ||||||||||||||||||||||||||||||||||||
2733 | xev.data.data32[1] = globalPos.y(); | - | ||||||||||||||||||||||||||||||||||||
2734 | const bool bottom = corner == Qt::BottomRightCorner || corner == Qt::BottomLeftCorner; | - | ||||||||||||||||||||||||||||||||||||
2735 | const bool left = corner == Qt::BottomLeftCorner || corner == Qt::TopLeftCorner; | - | ||||||||||||||||||||||||||||||||||||
2736 | if (bottom) | - | ||||||||||||||||||||||||||||||||||||
2737 | xev.data.data32[2] = left ? 6 : 4; // bottomleft/bottomright | - | ||||||||||||||||||||||||||||||||||||
2738 | else | - | ||||||||||||||||||||||||||||||||||||
2739 | xev.data.data32[2] = left ? 0 : 2; // topleft/topright | - | ||||||||||||||||||||||||||||||||||||
2740 | xev.data.data32[3] = XCB_BUTTON_INDEX_1; | - | ||||||||||||||||||||||||||||||||||||
2741 | xev.data.data32[4] = 0; | - | ||||||||||||||||||||||||||||||||||||
2742 | xcb_ungrab_pointer(connection()->xcb_connection(), XCB_CURRENT_TIME); | - | ||||||||||||||||||||||||||||||||||||
2743 | xcb_send_event(connection()->xcb_connection(), false, xcbScreen()->root(), | - | ||||||||||||||||||||||||||||||||||||
2744 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, | - | ||||||||||||||||||||||||||||||||||||
2745 | (const char *)&xev); | - | ||||||||||||||||||||||||||||||||||||
2746 | return true; | - | ||||||||||||||||||||||||||||||||||||
2747 | } | - | ||||||||||||||||||||||||||||||||||||
2748 | - | |||||||||||||||||||||||||||||||||||||
2749 | // Sends an XEmbed message. | - | ||||||||||||||||||||||||||||||||||||
2750 | void QXcbWindow::sendXEmbedMessage(xcb_window_t window, quint32 message, | - | ||||||||||||||||||||||||||||||||||||
2751 | quint32 detail, quint32 data1, quint32 data2) | - | ||||||||||||||||||||||||||||||||||||
2752 | { | - | ||||||||||||||||||||||||||||||||||||
2753 | xcb_client_message_event_t event; | - | ||||||||||||||||||||||||||||||||||||
2754 | - | |||||||||||||||||||||||||||||||||||||
2755 | event.response_type = XCB_CLIENT_MESSAGE; | - | ||||||||||||||||||||||||||||||||||||
2756 | event.format = 32; | - | ||||||||||||||||||||||||||||||||||||
2757 | event.sequence = 0; | - | ||||||||||||||||||||||||||||||||||||
2758 | event.window = window; | - | ||||||||||||||||||||||||||||||||||||
2759 | event.type = atom(QXcbAtom::_XEMBED); | - | ||||||||||||||||||||||||||||||||||||
2760 | event.data.data32[0] = connection()->time(); | - | ||||||||||||||||||||||||||||||||||||
2761 | event.data.data32[1] = message; | - | ||||||||||||||||||||||||||||||||||||
2762 | event.data.data32[2] = detail; | - | ||||||||||||||||||||||||||||||||||||
2763 | event.data.data32[3] = data1; | - | ||||||||||||||||||||||||||||||||||||
2764 | event.data.data32[4] = data2; | - | ||||||||||||||||||||||||||||||||||||
2765 | Q_XCB_CALL(xcb_send_event(xcb_connection(), false, window, | - | ||||||||||||||||||||||||||||||||||||
2766 | XCB_EVENT_MASK_NO_EVENT, (const char *)&event)); | - | ||||||||||||||||||||||||||||||||||||
2767 | } | - | ||||||||||||||||||||||||||||||||||||
2768 | - | |||||||||||||||||||||||||||||||||||||
2769 | static bool activeWindowChangeQueued(const QWindow *window) | - | ||||||||||||||||||||||||||||||||||||
2770 | { | - | ||||||||||||||||||||||||||||||||||||
2771 | /* Check from window system event queue if the next queued activation | - | ||||||||||||||||||||||||||||||||||||
2772 | * targets a window other than @window. | - | ||||||||||||||||||||||||||||||||||||
2773 | */ | - | ||||||||||||||||||||||||||||||||||||
2774 | QWindowSystemInterfacePrivate::ActivatedWindowEvent *systemEvent = | - | ||||||||||||||||||||||||||||||||||||
2775 | static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *> | - | ||||||||||||||||||||||||||||||||||||
2776 | (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::ActivatedWindow)); | - | ||||||||||||||||||||||||||||||||||||
2777 | return systemEvent && systemEvent->activated != window; | - | ||||||||||||||||||||||||||||||||||||
2778 | } | - | ||||||||||||||||||||||||||||||||||||
2779 | - | |||||||||||||||||||||||||||||||||||||
2780 | void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event) | - | ||||||||||||||||||||||||||||||||||||
2781 | { | - | ||||||||||||||||||||||||||||||||||||
2782 | connection()->setTime(event->data.data32[0]); | - | ||||||||||||||||||||||||||||||||||||
2783 | switch (event->data.data32[1]) { | - | ||||||||||||||||||||||||||||||||||||
2784 | case XEMBED_WINDOW_ACTIVATE: | - | ||||||||||||||||||||||||||||||||||||
2785 | case XEMBED_WINDOW_DEACTIVATE: | - | ||||||||||||||||||||||||||||||||||||
2786 | break; | - | ||||||||||||||||||||||||||||||||||||
2787 | case XEMBED_EMBEDDED_NOTIFY: | - | ||||||||||||||||||||||||||||||||||||
2788 | Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); | - | ||||||||||||||||||||||||||||||||||||
2789 | xcbScreen()->windowShown(this); | - | ||||||||||||||||||||||||||||||||||||
2790 | // Without Qt::WA_TranslucentBackground, we use a ParentRelative BackPixmap. | - | ||||||||||||||||||||||||||||||||||||
2791 | // Clear the whole tray icon window to its background color as early as possible | - | ||||||||||||||||||||||||||||||||||||
2792 | // so that we can get a clean result from grabWindow() later. | - | ||||||||||||||||||||||||||||||||||||
2793 | Q_XCB_CALL(xcb_clear_area(xcb_connection(), false, m_window, 0, 0, geometry().width(), geometry().height())); | - | ||||||||||||||||||||||||||||||||||||
2794 | xcb_flush(xcb_connection()); | - | ||||||||||||||||||||||||||||||||||||
2795 | break; | - | ||||||||||||||||||||||||||||||||||||
2796 | case XEMBED_FOCUS_IN: | - | ||||||||||||||||||||||||||||||||||||
2797 | Qt::FocusReason reason; | - | ||||||||||||||||||||||||||||||||||||
2798 | switch (event->data.data32[2]) { | - | ||||||||||||||||||||||||||||||||||||
2799 | case XEMBED_FOCUS_FIRST: | - | ||||||||||||||||||||||||||||||||||||
2800 | reason = Qt::TabFocusReason; | - | ||||||||||||||||||||||||||||||||||||
2801 | break; | - | ||||||||||||||||||||||||||||||||||||
2802 | case XEMBED_FOCUS_LAST: | - | ||||||||||||||||||||||||||||||||||||
2803 | reason = Qt::BacktabFocusReason; | - | ||||||||||||||||||||||||||||||||||||
2804 | break; | - | ||||||||||||||||||||||||||||||||||||
2805 | case XEMBED_FOCUS_CURRENT: | - | ||||||||||||||||||||||||||||||||||||
2806 | default: | - | ||||||||||||||||||||||||||||||||||||
2807 | reason = Qt::OtherFocusReason; | - | ||||||||||||||||||||||||||||||||||||
2808 | break; | - | ||||||||||||||||||||||||||||||||||||
2809 | } | - | ||||||||||||||||||||||||||||||||||||
2810 | connection()->setFocusWindow(static_cast<QXcbWindow*>(window()->handle())); | - | ||||||||||||||||||||||||||||||||||||
2811 | QWindowSystemInterface::handleWindowActivated(window(), reason); | - | ||||||||||||||||||||||||||||||||||||
2812 | break; | - | ||||||||||||||||||||||||||||||||||||
2813 | case XEMBED_FOCUS_OUT: | - | ||||||||||||||||||||||||||||||||||||
2814 | if (window() == QGuiApplication::focusWindow() | - | ||||||||||||||||||||||||||||||||||||
2815 | && !activeWindowChangeQueued(window())) { | - | ||||||||||||||||||||||||||||||||||||
2816 | connection()->setFocusWindow(0); | - | ||||||||||||||||||||||||||||||||||||
2817 | QWindowSystemInterface::handleWindowActivated(0); | - | ||||||||||||||||||||||||||||||||||||
2818 | } | - | ||||||||||||||||||||||||||||||||||||
2819 | break; | - | ||||||||||||||||||||||||||||||||||||
2820 | } | - | ||||||||||||||||||||||||||||||||||||
2821 | } | - | ||||||||||||||||||||||||||||||||||||
2822 | - | |||||||||||||||||||||||||||||||||||||
2823 | static inline xcb_rectangle_t qRectToXCBRectangle(const QRect &r) | - | ||||||||||||||||||||||||||||||||||||
2824 | { | - | ||||||||||||||||||||||||||||||||||||
2825 | xcb_rectangle_t result; | - | ||||||||||||||||||||||||||||||||||||
2826 | result.x = qMax(SHRT_MIN, r.x()); | - | ||||||||||||||||||||||||||||||||||||
2827 | result.y = qMax(SHRT_MIN, r.y()); | - | ||||||||||||||||||||||||||||||||||||
2828 | result.width = qMin((int)USHRT_MAX, r.width()); | - | ||||||||||||||||||||||||||||||||||||
2829 | result.height = qMin((int)USHRT_MAX, r.height()); | - | ||||||||||||||||||||||||||||||||||||
2830 | return result; | - | ||||||||||||||||||||||||||||||||||||
2831 | } | - | ||||||||||||||||||||||||||||||||||||
2832 | - | |||||||||||||||||||||||||||||||||||||
2833 | void QXcbWindow::setOpacity(qreal level) | - | ||||||||||||||||||||||||||||||||||||
2834 | { | - | ||||||||||||||||||||||||||||||||||||
2835 | if (!m_window) | - | ||||||||||||||||||||||||||||||||||||
2836 | return; | - | ||||||||||||||||||||||||||||||||||||
2837 | - | |||||||||||||||||||||||||||||||||||||
2838 | quint32 value = qRound64(qBound(qreal(0), level, qreal(1)) * 0xffffffff); | - | ||||||||||||||||||||||||||||||||||||
2839 | - | |||||||||||||||||||||||||||||||||||||
2840 | Q_XCB_CALL(xcb_change_property(xcb_connection(), | - | ||||||||||||||||||||||||||||||||||||
2841 | XCB_PROP_MODE_REPLACE, | - | ||||||||||||||||||||||||||||||||||||
2842 | m_window, | - | ||||||||||||||||||||||||||||||||||||
2843 | atom(QXcbAtom::_NET_WM_WINDOW_OPACITY), | - | ||||||||||||||||||||||||||||||||||||
2844 | XCB_ATOM_CARDINAL, | - | ||||||||||||||||||||||||||||||||||||
2845 | 32, | - | ||||||||||||||||||||||||||||||||||||
2846 | 1, | - | ||||||||||||||||||||||||||||||||||||
2847 | (uchar *)&value)); | - | ||||||||||||||||||||||||||||||||||||
2848 | } | - | ||||||||||||||||||||||||||||||||||||
2849 | - | |||||||||||||||||||||||||||||||||||||
2850 | void QXcbWindow::setMask(const QRegion ®ion) | - | ||||||||||||||||||||||||||||||||||||
2851 | { | - | ||||||||||||||||||||||||||||||||||||
2852 | if (!connection()->hasXShape()) | - | ||||||||||||||||||||||||||||||||||||
2853 | return; | - | ||||||||||||||||||||||||||||||||||||
2854 | if (region.isEmpty()) { | - | ||||||||||||||||||||||||||||||||||||
2855 | xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET, | - | ||||||||||||||||||||||||||||||||||||
2856 | XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE); | - | ||||||||||||||||||||||||||||||||||||
2857 | } else { | - | ||||||||||||||||||||||||||||||||||||
2858 | QVector<xcb_rectangle_t> rects; | - | ||||||||||||||||||||||||||||||||||||
2859 | const QVector<QRect> regionRects = region.rects(); | - | ||||||||||||||||||||||||||||||||||||
2860 | rects.reserve(regionRects.count()); | - | ||||||||||||||||||||||||||||||||||||
2861 | foreach (const QRect &r, regionRects) | - | ||||||||||||||||||||||||||||||||||||
2862 | rects.push_back(qRectToXCBRectangle(r)); | - | ||||||||||||||||||||||||||||||||||||
2863 | xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET, | - | ||||||||||||||||||||||||||||||||||||
2864 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | - | ||||||||||||||||||||||||||||||||||||
2865 | xcb_window(), 0, 0, rects.size(), &rects[0]); | - | ||||||||||||||||||||||||||||||||||||
2866 | } | - | ||||||||||||||||||||||||||||||||||||
2867 | } | - | ||||||||||||||||||||||||||||||||||||
2868 | - | |||||||||||||||||||||||||||||||||||||
2869 | void QXcbWindow::setAlertState(bool enabled) | - | ||||||||||||||||||||||||||||||||||||
2870 | { | - | ||||||||||||||||||||||||||||||||||||
2871 | if (m_alertState == enabled) | - | ||||||||||||||||||||||||||||||||||||
2872 | return; | - | ||||||||||||||||||||||||||||||||||||
2873 | - | |||||||||||||||||||||||||||||||||||||
2874 | m_alertState = enabled; | - | ||||||||||||||||||||||||||||||||||||
2875 | - | |||||||||||||||||||||||||||||||||||||
2876 | changeNetWmState(enabled, atom(QXcbAtom::_NET_WM_STATE_DEMANDS_ATTENTION)); | - | ||||||||||||||||||||||||||||||||||||
2877 | } | - | ||||||||||||||||||||||||||||||||||||
2878 | - | |||||||||||||||||||||||||||||||||||||
2879 | uint QXcbWindow::visualId() const | - | ||||||||||||||||||||||||||||||||||||
2880 | { | - | ||||||||||||||||||||||||||||||||||||
2881 | return m_visualId; | - | ||||||||||||||||||||||||||||||||||||
2882 | } | - | ||||||||||||||||||||||||||||||||||||
2883 | - | |||||||||||||||||||||||||||||||||||||
2884 | bool QXcbWindow::needsSync() const | - | ||||||||||||||||||||||||||||||||||||
2885 | { | - | ||||||||||||||||||||||||||||||||||||
2886 | return m_syncState == SyncAndConfigureReceived; | - | ||||||||||||||||||||||||||||||||||||
2887 | } | - | ||||||||||||||||||||||||||||||||||||
2888 | - | |||||||||||||||||||||||||||||||||||||
2889 | void QXcbWindow::postSyncWindowRequest() | - | ||||||||||||||||||||||||||||||||||||
2890 | { | - | ||||||||||||||||||||||||||||||||||||
2891 | if (!m_pendingSyncRequest) { | - | ||||||||||||||||||||||||||||||||||||
2892 | QXcbSyncWindowRequest *e = new QXcbSyncWindowRequest(this); | - | ||||||||||||||||||||||||||||||||||||
2893 | m_pendingSyncRequest = e; | - | ||||||||||||||||||||||||||||||||||||
2894 | QCoreApplication::postEvent(xcbScreen()->connection(), e); | - | ||||||||||||||||||||||||||||||||||||
2895 | } | - | ||||||||||||||||||||||||||||||||||||
2896 | } | - | ||||||||||||||||||||||||||||||||||||
2897 | - | |||||||||||||||||||||||||||||||||||||
2898 | QXcbScreen *QXcbWindow::xcbScreen() const | - | ||||||||||||||||||||||||||||||||||||
2899 | { | - | ||||||||||||||||||||||||||||||||||||
2900 | return static_cast<QXcbScreen *>(screen()); | - | ||||||||||||||||||||||||||||||||||||
2901 | } | - | ||||||||||||||||||||||||||||||||||||
2902 | - | |||||||||||||||||||||||||||||||||||||
2903 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||||||||||||||
2904 | - | |||||||||||||||||||||||||||||||||||||
Source code | Switch to Preprocessed file |