Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qxcbwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qxcbwindow.h"
5
6#include <QtDebug>
7#include <QMetaEnum>
8#include <QScreen>
9#include <QtGui/QIcon>
10#include <QtGui/QRegion>
11#include <QtGui/private/qhighdpiscaling_p.h>
12
13#include "qxcbintegration.h"
14#include "qxcbconnection.h"
15#include "qxcbscreen.h"
16#if QT_CONFIG(draganddrop)
17#include "qxcbdrag.h"
18#endif
19#include "qxcbkeyboard.h"
20#include "qxcbimage.h"
21#include "qxcbwmsupport.h"
22#include "qxcbimage.h"
23#include "qxcbnativeinterface.h"
25
26#include <qpa/qplatformintegration.h>
27#include <qpa/qplatformcursor.h>
28
29#include <algorithm>
30
31#include <xcb/xcb_icccm.h>
32#include <xcb/xfixes.h>
33#include <xcb/shape.h>
34#include <xcb/xinput.h>
35
36#include <private/qguiapplication_p.h>
37#include <private/qwindow_p.h>
38
39#include <qpa/qplatformbackingstore.h>
40#include <qpa/qwindowsysteminterface.h>
41
42#include <stdio.h>
43
44#if QT_CONFIG(xcb_xlib)
45#define register /* C++17 deprecated register */
46#include <X11/Xlib.h>
47#include <X11/Xutil.h>
48#undef register
49#endif
50
51#define XCOORD_MAX 32767
52enum {
55};
56
58
59using namespace Qt::StringLiterals;
60
61Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window");
62
64
65#undef FocusIn
66
71};
72
74 XEMBED_MAPPED = (1 << 0),
75};
76
91};
92
94
96{
97 return parent() ? static_cast<QXcbWindow*>(parent())->parentScreen() : xcbScreen();
98}
99
101{
102 // Resolve initial screen via QWindowPrivate::screenForGeometry(),
103 // which works in platform independent coordinates, as opposed to
104 // QPlatformWindow::screenForGeometry() that uses native coordinates.
105 QWindowPrivate *windowPrivate = qt_window_private(window());
106 QScreen *screen = windowPrivate->screenForGeometry(window()->geometry());
107 return static_cast<QXcbScreen*>(screen->handle());
108}
109
110// Returns \c true if we should set WM_TRANSIENT_FOR on \a w
111static inline bool isTransient(const QWindow *w)
112{
113 return w->type() == Qt::Dialog
114 || w->type() == Qt::Sheet
115 || w->type() == Qt::Tool
116 || w->type() == Qt::SplashScreen
117 || w->type() == Qt::ToolTip
118 || w->type() == Qt::Drawer
119 || w->type() == Qt::Popup;
120}
121
122void QXcbWindow::setImageFormatForVisual(const xcb_visualtype_t *visual)
123{
125 return;
126
127 switch (m_depth) {
128 case 32:
129 case 24:
130 qWarning("Using RGB32 fallback, if this works your X11 server is reporting a bad screen format.");
132 break;
133 case 16:
134 qWarning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format.");
136 default:
137 break;
138 }
139}
140
141#if QT_CONFIG(xcb_xlib)
142static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s)
143{
144 #include <X11/Xatom.h>
145
146 static XTextProperty tp = { nullptr, 0, 0, 0 };
147 static bool free_prop = true; // we can't free tp.value in case it references
148 // the data of the static QByteArray below.
149 if (tp.value) {
150 if (free_prop)
151 XFree(tp.value);
152 tp.value = nullptr;
153 free_prop = true;
154 }
155
156 int errCode = 0;
157 QByteArray mapped = s.toLocal8Bit(); // should always be utf-8
158 char* tl[2];
159 tl[0] = mapped.data();
160 tl[1] = nullptr;
161 errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp);
162 if (errCode < 0)
163 qCDebug(lcQpaXcb, "XmbTextListToTextProperty result code %d", errCode);
164
165 if (errCode < 0) {
166 static QByteArray qcs;
167 qcs = s.toLatin1();
168 tp.value = (uchar*)qcs.data();
169 tp.encoding = XA_STRING;
170 tp.format = 8;
171 tp.nitems = qcs.size();
172 free_prop = false;
173 }
174 return &tp;
175}
176#endif // QT_CONFIG(xcb_xlib)
177
178// TODO move this into a utility function in QWindow or QGuiApplication
180{
181 for (QObject *obj : win->children()) {
182 if (obj->isWindowType()) {
183 QWindow *childWin = static_cast<QWindow *>(obj);
184 if (childWin->isVisible()) {
185 if (QWindow *recurse = childWindowAt(childWin, p))
186 return recurse;
187 }
188 }
189 }
190 if (!win->isTopLevel()
191 && !(win->flags() & Qt::WindowTransparentForInput)
192 && win->geometry().contains(win->parent()->mapFromGlobal(p))) {
193 return win;
194 }
195 return nullptr;
196}
197
198static const char *wm_window_type_property_id = "_q_xcb_wm_window_type";
199static const char *wm_window_role_property_id = "_q_xcb_wm_window_role";
200
203{
205}
206
207enum : quint32 {
209 = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY
210 | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_FOCUS_CHANGE,
211
213 | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE
214 | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
215 | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW
216 | XCB_EVENT_MASK_POINTER_MOTION,
217
219 | XCB_EVENT_MASK_VISIBILITY_CHANGE
220 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT
221 | XCB_EVENT_MASK_COLOR_MAP_CHANGE | XCB_EVENT_MASK_OWNER_GRAB_BUTTON
223
225{
226 destroy();
227
230
231 Qt::WindowType type = window()->type();
232
233 QXcbScreen *currentScreen = xcbScreen();
234 QXcbScreen *platformScreen = parent() ? parentScreen() : initialScreen();
235 QRect rect = parent()
236 ? QHighDpi::toNativeLocalPosition(window()->geometry(), platformScreen)
237 : QHighDpi::toNativePixels(window()->geometry(), platformScreen);
238
239 if (type == Qt::Desktop) {
240 m_window = platformScreen->root();
241 m_depth = platformScreen->screen()->root_depth;
242 m_visualId = platformScreen->screen()->root_visual;
243 const xcb_visualtype_t *visual = nullptr;
244 if (connection()->hasDefaultVisualId()) {
245 visual = platformScreen->visualForId(connection()->defaultVisualId());
246 if (visual)
248 if (!visual)
249 qWarning("Could not use default visual id. Falling back to root_visual for screen.");
250 }
251 if (!visual)
252 visual = platformScreen->visualForId(m_visualId);
255 return;
256 }
257
258 const QSize minimumSize = windowMinimumSize();
259 if (rect.width() > 0 || rect.height() > 0) {
260 rect.setWidth(qBound(1, rect.width(), XCOORD_MAX));
261 rect.setHeight(qBound(1, rect.height(), XCOORD_MAX));
262 } else if (minimumSize.width() > 0 || minimumSize.height() > 0) {
263 rect.setSize(minimumSize);
264 } else {
265 rect.setWidth(QHighDpi::toNativePixels(int(defaultWindowWidth), platformScreen->QPlatformScreen::screen()));
266 rect.setHeight(QHighDpi::toNativePixels(int(defaultWindowHeight), platformScreen->QPlatformScreen::screen()));
267 }
268
270
271 if (platformScreen != currentScreen)
272 QWindowSystemInterface::handleWindowScreenChanged(window(), platformScreen->QPlatformScreen::screen());
273
274 xcb_window_t xcb_parent_id = platformScreen->root();
275 if (parent()) {
276 xcb_parent_id = static_cast<QXcbWindow *>(parent())->xcb_window();
278
279 QSurfaceFormat parentFormat = parent()->window()->requestedFormat();
280 if (window()->surfaceType() != QSurface::OpenGLSurface && parentFormat.hasAlpha()) {
281 window()->setFormat(parentFormat);
282 }
283 }
284
285 resolveFormat(platformScreen->surfaceFormatFor(window()->requestedFormat()));
286
287 const xcb_visualtype_t *visual = nullptr;
288
290 visual = platformScreen->visualForId(connection()->systemTrayTracker()->visualId());
291 } else if (connection()->hasDefaultVisualId()) {
292 visual = platformScreen->visualForId(connection()->defaultVisualId());
293 if (!visual)
294 qWarning() << "Failed to use requested visual id.";
295 }
296
297 if (parent()) {
298 // When using a Vulkan QWindow via QWidget::createWindowContainer() we
299 // must make sure the visuals are compatible. Now, the parent will be
300 // of RasterGLSurface which typically chooses a GLX/EGL compatible
301 // visual which may not be what the Vulkan window would choose.
302 // Therefore, take the parent's visual.
303 if (window()->surfaceType() == QSurface::VulkanSurface
304 && parent()->window()->surfaceType() != QSurface::VulkanSurface)
305 {
306 visual = platformScreen->visualForId(static_cast<QXcbWindow *>(parent())->visualId());
307 }
308 }
309
310 if (!visual)
311 visual = createVisual();
312
313 if (!visual) {
314 qWarning() << "Falling back to using screens root_visual.";
315 visual = platformScreen->visualForId(platformScreen->screen()->root_visual);
316 }
317
318 Q_ASSERT(visual);
319
320 m_visualId = visual->visual_id;
321 m_depth = platformScreen->depthOfVisual(m_visualId);
323
324 quint32 mask = XCB_CW_BACK_PIXMAP
325 | XCB_CW_BORDER_PIXEL
326 | XCB_CW_BIT_GRAVITY
327 | XCB_CW_OVERRIDE_REDIRECT
328 | XCB_CW_SAVE_UNDER
329 | XCB_CW_EVENT_MASK
330 | XCB_CW_COLORMAP;
331
332 quint32 values[] = {
333 XCB_BACK_PIXMAP_NONE,
334 platformScreen->screen()->black_pixel,
335 XCB_GRAVITY_NORTH_WEST,
339 platformScreen->colormapForVisual(m_visualId)
340 };
341
342 m_window = xcb_generate_id(xcb_connection());
343 xcb_create_window(xcb_connection(),
344 m_depth,
345 m_window, // window id
346 xcb_parent_id, // parent window id
347 rect.x(),
348 rect.y(),
349 rect.width(),
350 rect.height(),
351 0, // border width
352 XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
353 m_visualId, // visual
354 mask,
355 values);
356
358
360
361 xcb_atom_t properties[5];
362 int propertyCount = 0;
364 properties[propertyCount++] = atom(QXcbAtom::AtomWM_TAKE_FOCUS);
365 properties[propertyCount++] = atom(QXcbAtom::Atom_NET_WM_PING);
366
367 if (connection()->hasXSync())
369
372
373 xcb_change_property(xcb_connection(),
374 XCB_PROP_MODE_REPLACE,
375 m_window,
377 XCB_ATOM_ATOM,
378 32,
379 propertyCount,
380 properties);
381 m_syncValue.hi = 0;
382 m_syncValue.lo = 0;
383
384 const QByteArray wmClass = QXcbIntegration::instance()->wmClass();
385 if (!wmClass.isEmpty()) {
386 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE,
388 XCB_ATOM_STRING, 8, wmClass.size(), wmClass.constData());
389 }
390
391 if (connection()->hasXSync()) {
392 m_syncCounter = xcb_generate_id(xcb_connection());
393 xcb_sync_create_counter(xcb_connection(), m_syncCounter, m_syncValue);
394
395 xcb_change_property(xcb_connection(),
396 XCB_PROP_MODE_REPLACE,
397 m_window,
399 XCB_ATOM_CARDINAL,
400 32,
401 1,
403 }
404
405 // set the PID to let the WM kill the application if unresponsive
406 quint32 pid = getpid();
407 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
408 atom(QXcbAtom::Atom_NET_WM_PID), XCB_ATOM_CARDINAL, 32,
409 1, &pid);
410
411 const QByteArray clientMachine = QSysInfo::machineHostName().toLocal8Bit();
412 if (!clientMachine.isEmpty()) {
413 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
414 atom(QXcbAtom::AtomWM_CLIENT_MACHINE), XCB_ATOM_STRING, 8,
415 clientMachine.size(), clientMachine.constData());
416 }
417
418 // Create WM_HINTS property on the window, so we can xcb_icccm_get_wm_hints*()
419 // from various setter functions for adjusting the hints.
420 xcb_icccm_wm_hints_t hints;
421 memset(&hints, 0, sizeof(hints));
422 hints.flags = XCB_ICCCM_WM_HINT_WINDOW_GROUP;
423 hints.window_group = connection()->clientLeader();
424 xcb_icccm_set_wm_hints(xcb_connection(), m_window, &hints);
425
426 xcb_window_t leader = connection()->clientLeader();
427 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
428 atom(QXcbAtom::AtomWM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32,
429 1, &leader);
430
431 /* Add XEMBED info; this operation doesn't initiate the embedding. */
433 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
436 32, 2, (void *)data);
437
438 if (connection()->hasXInput2())
440
441 setWindowState(window()->windowStates());
444
445 // force sync to read outstanding requests - see QTBUG-29106
446 connection()->sync();
447
448#if QT_CONFIG(draganddrop)
449 connection()->drag()->dndEnable(this, true);
450#endif
451
452 const qreal opacity = qt_window_private(window())->opacity;
453 if (!qFuzzyCompare(opacity, qreal(1.0)))
454 setOpacity(opacity);
455
457
458 if (window()->isTopLevel())
460
461 if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) {
463 setWindowRole(QString::fromLatin1(wmWindowRole));
464 }
465
468}
469
471{
472 destroy();
473}
474
476{
477 // Clear window so that destroy() does not affect it
478 m_window = 0;
479
480 if (connection()->mouseGrabber() == this)
481 connection()->setMouseGrabber(nullptr);
482 if (connection()->mousePressWindow() == this)
484}
485
487{
488 if (connection()->focusWindow() == this)
489 doFocusOut();
490 if (connection()->mouseGrabber() == this)
491 connection()->setMouseGrabber(nullptr);
492
493 if (m_syncCounter && connection()->hasXSync())
494 xcb_sync_destroy_counter(xcb_connection(), m_syncCounter);
495 if (m_window) {
498 // Some window managers, like metacity, do XSelectInput on the _NET_WM_USER_TIME_WINDOW window,
499 // without trapping BadWindow (which crashes when the user time window is destroyed).
500 connection()->sync();
501 xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow);
502 m_netWmUserTimeWindow = XCB_NONE;
503 }
505 xcb_destroy_window(xcb_connection(), m_window);
506 m_window = 0;
507 }
508
509 m_mapped = false;
511
514}
515
517{
519
521
523
524 QXcbScreen *currentScreen = xcbScreen();
525 QXcbScreen *newScreen = parent() ? parentScreen() : static_cast<QXcbScreen*>(screenForGeometry(rect));
526
527 if (!newScreen)
528 newScreen = xcbScreen();
529
530 if (newScreen != currentScreen)
531 QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
532
533 if (qt_window_private(window())->positionAutomatic) {
534 const quint32 mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
535 const qint32 values[] = {
536 qBound<qint32>(1, rect.width(), XCOORD_MAX),
537 qBound<qint32>(1, rect.height(), XCOORD_MAX),
538 };
539 xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast<const quint32*>(values));
540 } else {
541 const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
542 const qint32 values[] = {
543 qBound<qint32>(-XCOORD_MAX, rect.x(), XCOORD_MAX),
544 qBound<qint32>(-XCOORD_MAX, rect.y(), XCOORD_MAX),
545 qBound<qint32>(1, rect.width(), XCOORD_MAX),
546 qBound<qint32>(1, rect.height(), XCOORD_MAX),
547 };
548 xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast<const quint32*>(values));
549 if (window()->parent() && !window()->transientParent()) {
550 // Wait for server reply for parented windows to ensure that a few window
551 // moves will come as a one event. This is important when native widget is
552 // moved a few times in X and Y directions causing native scroll. Widget
553 // must get single event to not trigger unwanted widget position changes
554 // and then expose events causing backingstore flushes with incorrect
555 // offset causing image crruption.
556 connection()->sync();
557 }
558 }
559
560 xcb_flush(xcb_connection());
561}
562
564{
566 if (connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::Atom_NET_FRAME_EXTENTS))) {
567 auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, m_window,
568 atom(QXcbAtom::Atom_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4);
569 if (reply && reply->type == XCB_ATOM_CARDINAL && reply->format == 32 && reply->value_len == 4) {
570 quint32 *data = (quint32 *)xcb_get_property_value(reply.get());
571 // _NET_FRAME_EXTENTS format is left, right, top, bottom
572 m_frameMargins = QMargins(data[0], data[2], data[1], data[3]);
573 m_dirtyFrameMargins = false;
574 return m_frameMargins;
575 }
576 }
577
578 // _NET_FRAME_EXTENTS property is not available, so
579 // walk up the window tree to get the frame parent
580 xcb_window_t window = m_window;
581 xcb_window_t parent = m_window;
582
583 bool foundRoot = false;
584
585 const QList<xcb_window_t> &virtualRoots =
587
588 while (!foundRoot) {
589 auto reply = Q_XCB_REPLY_UNCHECKED(xcb_query_tree, xcb_connection(), parent);
590 if (reply) {
591 if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1 || reply->parent == XCB_WINDOW_NONE) {
592 foundRoot = true;
593 } else {
594 window = parent;
596 }
597 } else {
598 m_dirtyFrameMargins = false;
600 return m_frameMargins;
601 }
602 }
603
605
606 auto reply = Q_XCB_REPLY(xcb_translate_coordinates, xcb_connection(), window, parent, 0, 0);
607 if (reply) {
608 offset = QPoint(reply->dst_x, reply->dst_y);
609 }
610
611 auto geom = Q_XCB_REPLY(xcb_get_geometry, xcb_connection(), parent);
612 if (geom) {
613 // --
614 // add the border_width for the window managers frame... some window managers
615 // do not use a border_width of zero for their frames, and if we the left and
616 // top strut, we ensure that pos() is absolutely correct. frameGeometry()
617 // will still be incorrect though... perhaps i should have foffset as well, to
618 // indicate the frame offset (equal to the border_width on X).
619 // - Brad
620 // -- copied from qwidget_x11.cpp
621
622 int left = offset.x() + geom->border_width;
623 int top = offset.y() + geom->border_width;
624 int right = geom->width + geom->border_width - geometry().width() - offset.x();
625 int bottom = geom->height + geom->border_width - geometry().height() - offset.y();
626
628 }
629
630 m_dirtyFrameMargins = false;
631 }
632
633 return m_frameMargins;
634}
635
636void QXcbWindow::setVisible(bool visible)
637{
638 if (visible)
639 show();
640 else
641 hide();
642}
643
645{
646 if (window()->isTopLevel()) {
648 qCDebug(lcQpaWindow) << "QXcbWindow: need to recreate window" << window() << m_recreationReasons;
649 create();
651 }
652
653 // update WM_NORMAL_HINTS
655
656 // update WM_TRANSIENT_FOR
657 xcb_window_t transientXcbParent = 0;
658 if (isTransient(window())) {
659 const QWindow *tp = window()->transientParent();
660 if (tp && tp->handle())
661 transientXcbParent = tp->handle()->winId();
662 // Default to client leader if there is no transient parent, else modal dialogs can
663 // be hidden by their parents.
664 if (!transientXcbParent)
665 transientXcbParent = connection()->clientLeader();
666 if (transientXcbParent) { // ICCCM 4.1.2.6
667 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
668 XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
669 1, &transientXcbParent);
670 }
671 }
672 if (!transientXcbParent)
673 xcb_delete_property(xcb_connection(), m_window, XCB_ATOM_WM_TRANSIENT_FOR);
674
675 // update _NET_WM_STATE
677 }
678
679 // QWidget-attribute Qt::WA_ShowWithoutActivating.
680 const auto showWithoutActivating = window()->property("_q_showWithoutActivating");
681 if (showWithoutActivating.isValid() && showWithoutActivating.toBool())
683 else if (connection()->time() != XCB_TIME_CURRENT_TIME)
685
687 return; // defer showing until XEMBED_EMBEDDED_NOTIFY
688
689 xcb_map_window(xcb_connection(), m_window);
690
693
694 xcbScreen()->windowShown(this);
695
696 connection()->sync();
697}
698
700{
701 xcb_unmap_window(xcb_connection(), m_window);
702
703 // send synthetic UnmapNotify event according to icccm 4.1.4
705 event.response_type = XCB_UNMAP_NOTIFY;
706 event.event = xcbScreen()->root();
707 event.window = m_window;
708 event.from_configure = false;
709 xcb_send_event(xcb_connection(), false, xcbScreen()->root(),
710 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event);
711
712 xcb_flush(xcb_connection());
713
714 if (connection()->mouseGrabber() == this)
715 connection()->setMouseGrabber(nullptr);
716 if (QPlatformWindow *w = connection()->mousePressWindow()) {
717 // Unset mousePressWindow when it (or one of its parents) is unmapped
718 while (w) {
719 if (w == this) {
721 break;
722 }
723 w = w->parent();
724 }
725 }
726
727 m_mapped = false;
728
729 // Hiding a modal window doesn't send an enter event to its transient parent when the
730 // mouse is already over the parent window, so the enter event must be emulated.
731 if (window()->isModal()) {
732 // Get the cursor position at modal window screen
733 const QPoint nativePos = xcbScreen()->cursor()->pos();
734 const QPoint cursorPos = QHighDpi::fromNativePixels(nativePos, xcbScreen()->screenForPosition(nativePos)->screen());
735
736 // Find the top level window at cursor position.
737 // Don't use QGuiApplication::topLevelAt(): search only the virtual siblings of this window's screen
738 QWindow *enterWindow = nullptr;
739 const auto screens = xcbScreen()->virtualSiblings();
740 for (QPlatformScreen *screen : screens) {
741 if (screen->geometry().contains(cursorPos)) {
742 const QPoint devicePosition = QHighDpi::toNativePixels(cursorPos, screen->screen());
743 enterWindow = screen->topLevelAt(devicePosition);
744 break;
745 }
746 }
747
748 if (enterWindow && enterWindow != window()) {
749 // Find the child window at cursor position, otherwise use the top level window
750 if (QWindow *childWindow = childWindowAt(enterWindow, cursorPos))
751 enterWindow = childWindow;
752 const QPoint localPos = enterWindow->mapFromGlobal(cursorPos);
754 localPos * QHighDpiScaling::factor(enterWindow),
755 nativePos);
756 }
757 }
758}
759
761{
762 QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver();
763 // get top-level window
764 while (w && w->parent())
765 w = w->parent();
766
767 QWindow *modalWindow = nullptr;
768 const bool blocked = QGuiApplicationPrivate::instance()->isWindowBlocked(w, &modalWindow);
769 if (blocked && modalWindow != w) {
770 modalWindow->requestActivate();
771 connection()->flush();
772 return true;
773 }
774
775 return false;
776}
777
779{
781 return;
782 QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver();
785}
786
788{
789 connection()->setFocusWindow(nullptr);
791 // Do not set the active window to nullptr if there is a FocusIn coming.
793}
794
798 quint32 status; // unused
799};
800
801enum {
803
804 MWM_FUNC_ALL = (1L << 0),
805 MWM_FUNC_RESIZE = (1L << 1),
806 MWM_FUNC_MOVE = (1L << 2),
807 MWM_FUNC_MINIMIZE = (1L << 3),
808 MWM_FUNC_MAXIMIZE = (1L << 4),
809 MWM_FUNC_CLOSE = (1L << 5),
810
812
813 MWM_DECOR_ALL = (1L << 0),
814 MWM_DECOR_BORDER = (1L << 1),
815 MWM_DECOR_RESIZEH = (1L << 2),
816 MWM_DECOR_TITLE = (1L << 3),
817 MWM_DECOR_MENU = (1L << 4),
820};
821
822QXcbWindow::NetWmStates QXcbWindow::netWmStates()
823{
824 NetWmStates result;
825
826 auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(),
828 XCB_ATOM_ATOM, 0, 1024);
829
830 if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) {
831 const xcb_atom_t *states = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply.get()));
832 const xcb_atom_t *statesEnd = states + reply->length;
833 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_ABOVE)))
835 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_BELOW)))
837 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_FULLSCREEN)))
839 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_HORZ)))
841 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_MAXIMIZED_VERT)))
843 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_MODAL)))
845 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_STAYS_ON_TOP)))
847 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_DEMANDS_ATTENTION)))
849 if (statesEnd != std::find(states, statesEnd, atom(QXcbAtom::Atom_NET_WM_STATE_HIDDEN)))
851 } else {
852 qCDebug(lcQpaXcb, "getting net wm state (%x), empty\n", m_window);
853 }
854
855 return result;
856}
857
859{
861
862 if (type == Qt::ToolTip)
864 if (type == Qt::Popup)
866
867 Qt::WindowFlags oldflags = window()->flags();
872
873 const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
874 const quint32 values[] = {
875 // XCB_CW_OVERRIDE_REDIRECT
877 // XCB_CW_EVENT_MASK
879 };
880
881 xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values);
882
883 WindowTypes wmWindowTypes;
884 if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) {
885 wmWindowTypes = static_cast<WindowTypes>(
886 qvariant_cast<int>(window()->property(wm_window_type_property_id)));
887 }
888
892
895}
896
898{
900
901 QtMotifWmHints mwmhints;
902 memset(&mwmhints, 0, sizeof(mwmhints));
903
904 if (type != Qt::SplashScreen) {
905 mwmhints.flags |= MWM_HINTS_DECORATIONS;
906
907 bool customize = flags & Qt::CustomizeWindowHint;
908 if (type == Qt::Window && !customize) {
910 if (!(flags & defaultFlags))
911 flags |= defaultFlags;
912 }
913 if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
914 mwmhints.decorations |= MWM_DECOR_BORDER;
915 mwmhints.decorations |= MWM_DECOR_RESIZEH;
916 mwmhints.decorations |= MWM_DECOR_TITLE;
917
919 mwmhints.decorations |= MWM_DECOR_MENU;
920
923 mwmhints.functions |= MWM_FUNC_MINIMIZE;
924 }
925
928 mwmhints.functions |= MWM_FUNC_MAXIMIZE;
929 }
930
932 mwmhints.functions |= MWM_FUNC_CLOSE;
933 }
934 } else {
935 // if type == Qt::SplashScreen
936 mwmhints.decorations = MWM_DECOR_ALL;
937 }
938
939 if (mwmhints.functions != 0) {
940 mwmhints.flags |= MWM_HINTS_FUNCTIONS;
942 } else {
943 mwmhints.functions = MWM_FUNC_ALL;
944 }
945
949 && !(flags &
953 {
954 // a special case - only the titlebar without any button
955 mwmhints.flags = MWM_HINTS_FUNCTIONS;
957 mwmhints.decorations = 0;
958 }
959
960 if (mwmhints.flags) {
961 xcb_change_property(xcb_connection(),
962 XCB_PROP_MODE_REPLACE,
963 m_window,
966 32,
967 5,
968 &mwmhints);
969 } else {
971 }
972}
973
974void QXcbWindow::setNetWmState(bool set, xcb_atom_t one, xcb_atom_t two)
975{
976 xcb_client_message_event_t event;
977
978 event.response_type = XCB_CLIENT_MESSAGE;
979 event.format = 32;
980 event.sequence = 0;
981 event.window = m_window;
982 event.type = atom(QXcbAtom::Atom_NET_WM_STATE);
983 event.data.data32[0] = set ? 1 : 0;
984 event.data.data32[1] = one;
985 event.data.data32[2] = two;
986 event.data.data32[3] = 0;
987 event.data.data32[4] = 0;
988
989 xcb_send_event(xcb_connection(), 0, xcbScreen()->root(),
990 XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
991 (const char *)&event);
992}
993
994void QXcbWindow::setNetWmState(Qt::WindowStates state)
995{
1000 }
1001
1004}
1005
1007{
1012}
1013
1015{
1016 if (Q_UNLIKELY(m_mapped))
1017 qCWarning(lcQpaXcb()) << "internal error: " << Q_FUNC_INFO << "called on mapped window";
1018
1019 NetWmStates states;
1020 const Qt::WindowFlags flags = window()->flags();
1024 } else if (flags & Qt::WindowStaysOnBottomHint) {
1026 }
1027
1028 if (window()->windowStates() & Qt::WindowMinimized)
1030
1031 if (window()->windowStates() & Qt::WindowFullScreen)
1033
1034 if (window()->windowStates() & Qt::WindowMaximized) {
1037 }
1038
1039 if (window()->modality() != Qt::NonModal)
1041
1042 // According to EWMH:
1043 // "The Window Manager should remove _NET_WM_STATE whenever a window is withdrawn".
1044 // Which means that we don't have to read this property before changing it on a withdrawn
1045 // window. But there are situations where users want to adjust this property as well
1046 // (e4cea305ed2ba3c9f580bf9d16c59a1048af0e8a), so instead of overwriting the property
1047 // we first read it and then merge our hints with the existing values, allowing a user
1048 // to set custom hints.
1049
1050 QList<xcb_atom_t> atoms;
1051 auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(),
1053 XCB_ATOM_ATOM, 0, 1024);
1054 if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM && reply->value_len > 0) {
1055 const xcb_atom_t *data = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply.get()));
1056 atoms.resize(reply->value_len);
1057 memcpy((void *)&atoms.first(), (void *)data, reply->value_len * sizeof(xcb_atom_t));
1058 }
1059
1078
1079 if (atoms.isEmpty()) {
1080 xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::Atom_NET_WM_STATE));
1081 } else {
1082 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
1083 atom(QXcbAtom::Atom_NET_WM_STATE), XCB_ATOM_ATOM, 32,
1084 atoms.size(), atoms.constData());
1085 }
1086 xcb_flush(xcb_connection());
1087}
1088
1089void QXcbWindow::setWindowState(Qt::WindowStates state)
1090{
1091 if (state == m_windowState)
1092 return;
1093
1094 // unset old state
1096 xcb_map_window(xcb_connection(), m_window);
1098 setNetWmState(false,
1103
1104 // set new state
1105 if (state & Qt::WindowMinimized) {
1106 {
1107 xcb_client_message_event_t event;
1108
1109 event.response_type = XCB_CLIENT_MESSAGE;
1110 event.format = 32;
1111 event.sequence = 0;
1112 event.window = m_window;
1113 event.type = atom(QXcbAtom::AtomWM_CHANGE_STATE);
1114 event.data.data32[0] = XCB_ICCCM_WM_STATE_ICONIC;
1115 event.data.data32[1] = 0;
1116 event.data.data32[2] = 0;
1117 event.data.data32[3] = 0;
1118 event.data.data32[4] = 0;
1119
1120 xcb_send_event(xcb_connection(), 0, xcbScreen()->root(),
1121 XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
1122 (const char *)&event);
1123 }
1124 m_minimized = true;
1125 }
1127 setNetWmState(true,
1132
1134
1135 xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window);
1136 xcb_icccm_wm_hints_t hints;
1137 if (xcb_icccm_get_wm_hints_reply(xcb_connection(), cookie, &hints, nullptr)) {
1139 xcb_icccm_wm_hints_set_iconic(&hints);
1140 else
1141 xcb_icccm_wm_hints_set_normal(&hints);
1142 xcb_icccm_set_wm_hints(xcb_connection(), m_window, &hints);
1143 }
1144
1145 connection()->sync();
1147}
1148
1149void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp)
1150{
1151 xcb_window_t wid = m_window;
1152 // If timestamp == 0, then it means that the window should not be
1153 // initially activated. Don't update global user time for this
1154 // special case.
1155 if (timestamp != 0)
1156 connection()->setNetWmUserTime(timestamp);
1157
1159 if (m_netWmUserTimeWindow || isSupportedByWM) {
1160 if (!m_netWmUserTimeWindow) {
1161 m_netWmUserTimeWindow = xcb_generate_id(xcb_connection());
1162 xcb_create_window(xcb_connection(),
1163 XCB_COPY_FROM_PARENT, // depth -- same as root
1164 m_netWmUserTimeWindow, // window id
1165 m_window, // parent window id
1166 -1, -1, 1, 1,
1167 0, // border width
1168 XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
1169 m_visualId, // visual
1170 0, // value mask
1171 nullptr); // value list
1173 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::Atom_NET_WM_USER_TIME_WINDOW),
1174 XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow);
1176
1178 QStringLiteral("Qt NET_WM User Time Window"));
1179
1180 } else if (!isSupportedByWM) {
1181 // WM no longer supports it, then we should remove the
1182 // _NET_WM_USER_TIME_WINDOW atom.
1184 xcb_destroy_window(xcb_connection(), m_netWmUserTimeWindow);
1185 m_netWmUserTimeWindow = XCB_NONE;
1186 } else {
1188 }
1189 }
1190 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, wid, atom(QXcbAtom::Atom_NET_WM_USER_TIME),
1191 XCB_ATOM_CARDINAL, 32, 1, &timestamp);
1192}
1193
1195{
1196 if (!connection()->hasXFixes() || transparent == m_transparent)
1197 return;
1198
1199 xcb_rectangle_t rectangle;
1200
1201 xcb_rectangle_t *rect = nullptr;
1202 int nrect = 0;
1203
1204 if (!transparent) {
1205 rectangle.x = 0;
1206 rectangle.y = 0;
1207 rectangle.width = geometry().width();
1208 rectangle.height = geometry().height();
1209 rect = &rectangle;
1210 nrect = 1;
1211 }
1212
1213 xcb_xfixes_region_t region = xcb_generate_id(xcb_connection());
1214 xcb_xfixes_create_region(xcb_connection(), region, nrect, rect);
1215 xcb_xfixes_set_window_shape_region_checked(xcb_connection(), m_window, XCB_SHAPE_SK_INPUT, 0, 0, region);
1216 xcb_xfixes_destroy_region(xcb_connection(), region);
1217
1218 m_transparent = transparent;
1219}
1220
1221void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus)
1222{
1223 xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(xcb_connection(), m_window);
1224
1225 xcb_icccm_wm_hints_t hints;
1226 if (!xcb_icccm_get_wm_hints_reply(xcb_connection(), cookie, &hints, nullptr))
1227 return;
1228
1229 xcb_icccm_wm_hints_set_input(&hints, !doesNotAcceptFocus);
1230 xcb_icccm_set_wm_hints(xcb_connection(), m_window, &hints);
1231}
1232
1234{
1235 return m_window;
1236}
1237
1239{
1240 QPoint topLeft = geometry().topLeft();
1241
1242 xcb_window_t xcb_parent_id;
1243 if (parent) {
1244 const QXcbWindow *qXcbParent = static_cast<const QXcbWindow *>(parent);
1245 xcb_parent_id = qXcbParent->xcb_window();
1246 m_embedded = qXcbParent->isForeignWindow();
1247 } else {
1248 xcb_parent_id = xcbScreen()->root();
1249 m_embedded = false;
1250 }
1251 xcb_reparent_window(xcb_connection(), xcb_window(), xcb_parent_id, topLeft.x(), topLeft.y());
1252}
1253
1255{
1257}
1258
1260{
1261 const QByteArray ba = title.toUtf8();
1262 xcb_change_property(xcb_connection(),
1263 XCB_PROP_MODE_REPLACE,
1264 m_window,
1267 8,
1268 ba.size(),
1269 ba.constData());
1270}
1271
1273{
1274 QList<quint32> icon_data;
1275 if (!icon.isNull()) {
1276 QList<QSize> availableSizes = icon.availableSizes();
1277 if (availableSizes.isEmpty()) {
1278 // try to use default sizes since the icon can be a scalable image like svg.
1279 availableSizes.push_back(QSize(16,16));
1280 availableSizes.push_back(QSize(32,32));
1281 availableSizes.push_back(QSize(64,64));
1282 availableSizes.push_back(QSize(128,128));
1283 }
1284 for (int i = 0; i < availableSizes.size(); ++i) {
1285 QSize size = availableSizes.at(i);
1287 if (!pixmap.isNull()) {
1288 QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
1289 int pos = icon_data.size();
1290 icon_data.resize(pos + 2 + image.width()*image.height());
1291 icon_data[pos++] = image.width();
1292 icon_data[pos++] = image.height();
1293 memcpy(icon_data.data() + pos, image.bits(), image.width()*image.height()*4);
1294 }
1295 }
1296 }
1297
1298 if (!icon_data.isEmpty()) {
1299 // Ignore icon exceeding maximum xcb request length
1300 if (quint64(icon_data.size()) > quint64(xcb_get_maximum_request_length(xcb_connection()))) {
1301 qWarning() << "Ignoring window icon" << icon_data.size()
1302 << "exceeds maximum xcb request length"
1303 << xcb_get_maximum_request_length(xcb_connection());
1304 return;
1305 }
1306 xcb_change_property(xcb_connection(),
1307 XCB_PROP_MODE_REPLACE,
1308 m_window,
1311 32,
1312 icon_data.size(),
1313 (unsigned char *) icon_data.data());
1314 } else {
1315 xcb_delete_property(xcb_connection(),
1316 m_window,
1318 }
1319}
1320
1322{
1323 const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
1324 const quint32 values[] = { XCB_STACK_MODE_ABOVE };
1325 xcb_configure_window(xcb_connection(), m_window, mask, values);
1326}
1327
1329{
1330 const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
1331 const quint32 values[] = { XCB_STACK_MODE_BELOW };
1332 xcb_configure_window(xcb_connection(), m_window, mask, values);
1333}
1334
1336{
1337 // update WM_NORMAL_HINTS
1338 xcb_size_hints_t hints;
1339 memset(&hints, 0, sizeof(hints));
1340
1341 const QRect rect = geometry();
1343
1344 if (!win->positionAutomatic)
1345 xcb_icccm_size_hints_set_position(&hints, true, rect.x(), rect.y());
1346 if (rect.width() < QWINDOWSIZE_MAX || rect.height() < QWINDOWSIZE_MAX)
1347 xcb_icccm_size_hints_set_size(&hints, true, rect.width(), rect.height());
1348
1349 /* Gravity describes how to interpret x and y values the next time
1350 window needs to be positioned on a screen.
1351 XCB_GRAVITY_STATIC : the left top corner of the client window
1352 XCB_GRAVITY_NORTH_WEST : the left top corner of the frame window */
1353 auto gravity = win->positionPolicy == QWindowPrivate::WindowFrameInclusive
1354 ? XCB_GRAVITY_NORTH_WEST : XCB_GRAVITY_STATIC;
1355
1356 xcb_icccm_size_hints_set_win_gravity(&hints, gravity);
1357
1358 QSize minimumSize = windowMinimumSize();
1359 QSize maximumSize = windowMaximumSize();
1360 QSize baseSize = windowBaseSize();
1361 QSize sizeIncrement = windowSizeIncrement();
1362
1363 if (minimumSize.width() > 0 || minimumSize.height() > 0)
1364 xcb_icccm_size_hints_set_min_size(&hints,
1365 qMin(XCOORD_MAX,minimumSize.width()),
1366 qMin(XCOORD_MAX,minimumSize.height()));
1367
1368 if (maximumSize.width() < QWINDOWSIZE_MAX || maximumSize.height() < QWINDOWSIZE_MAX)
1369 xcb_icccm_size_hints_set_max_size(&hints,
1370 qMin(XCOORD_MAX, maximumSize.width()),
1371 qMin(XCOORD_MAX, maximumSize.height()));
1372
1373 if (sizeIncrement.width() > 0 || sizeIncrement.height() > 0) {
1374 xcb_icccm_size_hints_set_base_size(&hints, baseSize.width(), baseSize.height());
1375 xcb_icccm_size_hints_set_resize_inc(&hints, sizeIncrement.width(), sizeIncrement.height());
1376 }
1377
1378 xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints);
1379
1381}
1382
1384{
1385 /* Never activate embedded windows; doing that would prevent the container
1386 * to re-gain the keyboard focus later. */
1387 if (m_embedded) {
1389 return;
1390 }
1391
1392 if (!m_mapped) {
1393 m_deferredActivation = true;
1394 return;
1395 }
1396 m_deferredActivation = false;
1397
1399 QWindow *focusWindow = QGuiApplication::focusWindow();
1400
1401 if (window()->isTopLevel()
1403 && (!focusWindow || !window()->isAncestorOf(focusWindow))
1404 && connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::Atom_NET_ACTIVE_WINDOW))) {
1405 xcb_client_message_event_t event;
1406
1407 event.response_type = XCB_CLIENT_MESSAGE;
1408 event.format = 32;
1409 event.sequence = 0;
1410 event.window = m_window;
1412 event.data.data32[0] = 1;
1413 event.data.data32[1] = connection()->time();
1414 event.data.data32[2] = focusWindow ? focusWindow->winId() : XCB_NONE;
1415 event.data.data32[3] = 0;
1416 event.data.data32[4] = 0;
1417
1418 xcb_send_event(xcb_connection(), 0, xcbScreen()->root(),
1419 XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
1420 (const char *)&event);
1421 } else {
1422 xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, connection()->time());
1423 }
1424
1425 connection()->sync();
1426}
1427
1429{
1430 return m_format;
1431}
1432
1433QXcbWindow::WindowTypes QXcbWindow::wmWindowTypes() const
1434{
1435 WindowTypes result;
1436
1437 auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(),
1439 XCB_ATOM_ATOM, 0, 1024);
1440 if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) {
1441 const xcb_atom_t *types = static_cast<const xcb_atom_t *>(xcb_get_property_value(reply.get()));
1442 const xcb_atom_t *types_end = types + reply->length;
1443 for (; types != types_end; types++) {
1445 switch (type) {
1447 result |= WindowType::Normal;
1448 break;
1450 result |= WindowType::Desktop;
1451 break;
1453 result |= WindowType::Dock;
1454 break;
1456 result |= WindowType::Toolbar;
1457 break;
1459 result |= WindowType::Menu;
1460 break;
1462 result |= WindowType::Utility;
1463 break;
1465 result |= WindowType::Splash;
1466 break;
1468 result |= WindowType::Dialog;
1469 break;
1471 result |= WindowType::DropDownMenu;
1472 break;
1474 result |= WindowType::PopupMenu;
1475 break;
1477 result |= WindowType::Tooltip;
1478 break;
1480 result |= WindowType::Notification;
1481 break;
1483 result |= WindowType::Combo;
1484 break;
1486 result |= WindowType::Dnd;
1487 break;
1489 result |= WindowType::KdeOverride;
1490 break;
1491 default:
1492 break;
1493 }
1494 }
1495 }
1496 return result;
1497}
1498
1499void QXcbWindow::setWmWindowType(WindowTypes types, Qt::WindowFlags flags)
1500{
1501 QList<xcb_atom_t> atoms;
1502
1503 // manual selection 1 (these are never set by Qt and take precedence)
1504 if (types & WindowType::Normal)
1506 if (types & WindowType::Desktop)
1508 if (types & WindowType::Dock)
1510 if (types & WindowType::Notification)
1512
1513 // manual selection 2 (Qt uses these during auto selection);
1514 if (types & WindowType::Utility)
1516 if (types & WindowType::Splash)
1518 if (types & WindowType::Dialog)
1520 if (types & WindowType::Tooltip)
1522 if (types & WindowType::KdeOverride)
1524
1525 // manual selection 3 (these can be set by Qt, but don't have a
1526 // corresponding Qt::WindowType). note that order of the *MENU
1527 // atoms is important
1528 if (types & WindowType::Menu)
1530 if (types & WindowType::DropDownMenu)
1532 if (types & WindowType::PopupMenu)
1534 if (types & WindowType::Toolbar)
1536 if (types & WindowType::Combo)
1538 if (types & WindowType::Dnd)
1540
1541 // automatic selection
1543 switch (type) {
1544 case Qt::Dialog:
1545 case Qt::Sheet:
1546 if (!(types & WindowType::Dialog))
1548 break;
1549 case Qt::Tool:
1550 case Qt::Drawer:
1551 if (!(types & WindowType::Utility))
1553 break;
1554 case Qt::ToolTip:
1555 if (!(types & WindowType::Tooltip))
1557 break;
1558 case Qt::SplashScreen:
1559 if (!(types & WindowType::Splash))
1561 break;
1562 default:
1563 break;
1564 }
1565
1566 if ((flags & Qt::FramelessWindowHint) && !(types & WindowType::KdeOverride)) {
1567 // override netwm type - quick and easy for KDE noborder
1569 }
1570
1571 if (atoms.size() == 1 && atoms.first() == atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE_NORMAL))
1572 atoms.clear();
1573 else
1575
1576 if (atoms.isEmpty()) {
1578 } else {
1579 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
1580 atom(QXcbAtom::Atom_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32,
1581 atoms.size(), atoms.constData());
1582 }
1583 xcb_flush(xcb_connection());
1584}
1585
1587{
1588 QByteArray roleData = role.toLatin1();
1589 xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
1590 atom(QXcbAtom::AtomWM_WINDOW_ROLE), XCB_ATOM_STRING, 8,
1591 roleData.size(), roleData.constData());
1592}
1593
1595{
1596 const quint32 mask = XCB_CW_BACK_PIXMAP;
1597 const quint32 values[] = { XCB_BACK_PIXMAP_PARENT_RELATIVE };
1598 xcb_change_window_attributes(xcb_connection(), m_window, mask, values);
1599}
1600
1602{
1603 if (!connection()->systemTrayTracker())
1604 return false;
1606 return true;
1607}
1608
1609bool QXcbWindow::handleNativeEvent(xcb_generic_event_t *event)
1610{
1611 auto eventType = connection()->nativeInterface()->nativeEventType();
1612 qintptr result = 0; // Used only by MS Windows
1614}
1615
1616void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
1617{
1618 QRect rect(event->x, event->y, event->width, event->height);
1620
1621 bool pending = true;
1622
1624 [this, &pending](xcb_generic_event_t *event, int type) {
1625 if (type != XCB_EXPOSE)
1626 return false;
1627 auto expose = reinterpret_cast<xcb_expose_event_t *>(event);
1628 if (expose->window != m_window)
1629 return false;
1630 if (expose->count == 0)
1631 pending = false;
1632 m_exposeRegion |= QRect(expose->x, expose->y, expose->width, expose->height);
1633 free(expose);
1634 return true;
1635 });
1636
1637 // if count is non-zero there are more expose events pending
1638 if (event->count == 0 || !pending) {
1641 }
1642}
1643
1644void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event)
1645{
1646 if (event->format != 32)
1647 return;
1648
1649 if (event->type == atom(QXcbAtom::AtomWM_PROTOCOLS)) {
1650 xcb_atom_t protocolAtom = event->data.data32[0];
1651 if (protocolAtom == atom(QXcbAtom::AtomWM_DELETE_WINDOW)) {
1653 } else if (protocolAtom == atom(QXcbAtom::AtomWM_TAKE_FOCUS)) {
1654 connection()->setTime(event->data.data32[1]);
1656 return;
1657 } else if (protocolAtom == atom(QXcbAtom::Atom_NET_WM_PING)) {
1658 if (event->window == xcbScreen()->root())
1659 return;
1660
1661 xcb_client_message_event_t reply = *event;
1662
1663 reply.response_type = XCB_CLIENT_MESSAGE;
1664 reply.window = xcbScreen()->root();
1665
1666 xcb_send_event(xcb_connection(), 0, xcbScreen()->root(),
1667 XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
1668 (const char *)&reply);
1669 xcb_flush(xcb_connection());
1670 } else if (protocolAtom == atom(QXcbAtom::Atom_NET_WM_SYNC_REQUEST)) {
1671 connection()->setTime(event->data.data32[1]);
1672 m_syncValue.lo = event->data.data32[2];
1673 m_syncValue.hi = event->data.data32[3];
1674 if (connection()->hasXSync())
1676#ifndef QT_NO_WHATSTHIS
1677 } else if (protocolAtom == atom(QXcbAtom::Atom_NET_WM_CONTEXT_HELP)) {
1678 QWindowSystemInterface::handleEnterWhatsThisEvent();
1679#endif
1680 } else {
1681 qCWarning(lcQpaXcb, "Unhandled WM_PROTOCOLS (%s)",
1682 connection()->atomName(protocolAtom).constData());
1683 }
1684#if QT_CONFIG(draganddrop)
1685 } else if (event->type == atom(QXcbAtom::AtomXdndEnter)) {
1686 connection()->drag()->handleEnter(this, event);
1687 } else if (event->type == atom(QXcbAtom::AtomXdndPosition)) {
1688 connection()->drag()->handlePosition(this, event);
1689 } else if (event->type == atom(QXcbAtom::AtomXdndLeave)) {
1690 connection()->drag()->handleLeave(this, event);
1691 } else if (event->type == atom(QXcbAtom::AtomXdndDrop)) {
1692 connection()->drag()->handleDrop(this, event);
1693#endif
1694 } else if (event->type == atom(QXcbAtom::Atom_XEMBED)) {
1696 } else if (event->type == atom(QXcbAtom::Atom_NET_ACTIVE_WINDOW)) {
1697 doFocusIn();
1698 } else if (event->type == atom(QXcbAtom::AtomMANAGER)
1701 // Ignore _NET_WM_STATE, MANAGER which are relate to tray icons
1702 // and other messages.
1708 //silence the _COMPIZ and _GTK messages for now
1709 } else {
1710 qCWarning(lcQpaXcb) << "Unhandled client message: " << connection()->atomName(event->type);
1711 }
1712}
1713
1714void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
1715{
1716 bool fromSendEvent = (event->response_type & 0x80);
1717 QPoint pos(event->x, event->y);
1718 if (!parent() && !fromSendEvent) {
1719 // Do not trust the position, query it instead.
1720 auto reply = Q_XCB_REPLY(xcb_translate_coordinates, xcb_connection(),
1721 xcb_window(), xcbScreen()->root(), 0, 0);
1722 if (reply) {
1723 pos.setX(reply->dst_x);
1724 pos.setY(reply->dst_y);
1725 }
1726 }
1727
1728 const QRect actualGeometry = QRect(pos, QSize(event->width, event->height));
1729 QPlatformScreen *newScreen = parent() ? parent()->screen() : screenForGeometry(actualGeometry);
1730 if (!newScreen)
1731 return;
1732
1734
1735 // QPlatformScreen::screen() is updated asynchronously, so we can't compare it
1736 // with the newScreen. Just send the WindowScreenChanged event and QGuiApplication
1737 // will make the comparison later.
1739
1742
1743 // Send the synthetic expose event on resize only when the window is shrunk,
1744 // because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically.
1746 && (actualGeometry.width() < m_oldWindowSize.width()
1747 || actualGeometry.height() < m_oldWindowSize.height())) {
1748 QWindowSystemInterface::handleExposeEvent(window(), QRegion(0, 0, actualGeometry.width(), actualGeometry.height()));
1749 }
1750 m_oldWindowSize = actualGeometry.size();
1751
1752 if (connection()->hasXSync() && m_syncState == SyncReceived)
1754
1755 m_dirtyFrameMargins = true;
1756}
1757
1759{
1760 return m_mapped;
1761}
1762
1764{
1765 return m_embedded;
1766}
1767
1769{
1770 if (!m_embedded)
1772
1773 QPoint ret;
1774 auto reply = Q_XCB_REPLY(xcb_translate_coordinates, xcb_connection(),
1775 xcb_window(), xcbScreen()->root(),
1776 pos.x(), pos.y());
1777 if (reply) {
1778 ret.setX(reply->dst_x);
1779 ret.setY(reply->dst_y);
1780 }
1781
1782 return ret;
1783}
1784
1786{
1787 if (!m_embedded)
1789
1790 QPoint ret;
1791 auto reply = Q_XCB_REPLY(xcb_translate_coordinates, xcb_connection(),
1792 xcbScreen()->root(), xcb_window(),
1793 pos.x(), pos.y());
1794 if (reply) {
1795 ret.setX(reply->dst_x);
1796 ret.setY(reply->dst_y);
1797 }
1798
1799 return ret;
1800}
1801
1802void QXcbWindow::handleMapNotifyEvent(const xcb_map_notify_event_t *event)
1803{
1804 if (event->window == m_window) {
1805 m_mapped = true;
1808
1810 }
1811}
1812
1813void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
1814{
1815 if (event->window == m_window) {
1816 m_mapped = false;
1818 }
1819}
1820
1821void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, int root_y,
1822 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
1824{
1825 const bool isWheel = detail >= 4 && detail <= 7;
1826 if (!isWheel && window() != QGuiApplication::focusWindow()) {
1827 QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver();
1829 && w->type() != Qt::ToolTip
1830 && w->type() != Qt::Popup) {
1831 w->requestActivate();
1832 }
1833 }
1834
1835 updateNetWmUserTime(timestamp);
1836
1837 if (m_embedded && !m_trayIconWindow) {
1839 const QXcbWindow *container = static_cast<const QXcbWindow *>(parent());
1840 Q_ASSERT(container != nullptr);
1841
1843 }
1844 }
1845 QPoint local(event_x, event_y);
1846 QPoint global(root_x, root_y);
1847
1848 if (isWheel) {
1849 if (!connection()->isAtLeastXI21()) {
1850 QPoint angleDelta;
1851 if (detail == 4)
1852 angleDelta.setY(120);
1853 else if (detail == 5)
1854 angleDelta.setY(-120);
1855 else if (detail == 6)
1856 angleDelta.setX(120);
1857 else if (detail == 7)
1858 angleDelta.setX(-120);
1860 angleDelta = angleDelta.transposed();
1861 QWindowSystemInterface::handleWheelEvent(window(), timestamp, local, global, QPoint(), angleDelta, modifiers);
1862 }
1863 return;
1864 }
1865
1867
1868 handleMouseEvent(timestamp, local, global, modifiers, type, source);
1869}
1870
1871void QXcbWindow::handleButtonReleaseEvent(int event_x, int event_y, int root_x, int root_y,
1872 int detail, Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
1874{
1875 QPoint local(event_x, event_y);
1876 QPoint global(root_x, root_y);
1877
1878 if (detail >= 4 && detail <= 7) {
1879 // mouse wheel, handled in handleButtonPressEvent()
1880 return;
1881 }
1882
1883 if (connection()->buttonState() == Qt::NoButton)
1884 connection()->setMousePressWindow(nullptr);
1885
1886 handleMouseEvent(timestamp, local, global, modifiers, type, source);
1887}
1888
1889static inline bool doCheckUnGrabAncestor(QXcbConnection *conn)
1890{
1891 /* Checking for XCB_NOTIFY_MODE_GRAB and XCB_NOTIFY_DETAIL_ANCESTOR prevents unwanted
1892 * enter/leave events on AwesomeWM on mouse button press. It also ignores duplicated
1893 * enter/leave events on Alt+Tab switching on some WMs with XInput2 events.
1894 * Without XInput2 events the (Un)grabAncestor cannot be checked when mouse button is
1895 * not pressed, otherwise (e.g. on Alt+Tab) it can igonre important enter/leave events.
1896 */
1897 if (conn) {
1898 const bool mouseButtonsPressed = (conn->buttonState() != Qt::NoButton);
1899 return mouseButtonsPressed || conn->hasXInput2();
1900 }
1901 return true;
1902}
1903
1905{
1906 return ((doCheckUnGrabAncestor(conn)
1907 && mode == XCB_NOTIFY_MODE_GRAB && detail == XCB_NOTIFY_DETAIL_ANCESTOR)
1908 || (mode == XCB_NOTIFY_MODE_UNGRAB && detail == XCB_NOTIFY_DETAIL_INFERIOR)
1909 || detail == XCB_NOTIFY_DETAIL_VIRTUAL
1910 || detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL);
1911}
1912
1914{
1915 return ((doCheckUnGrabAncestor(conn)
1916 && mode == XCB_NOTIFY_MODE_UNGRAB && detail == XCB_NOTIFY_DETAIL_ANCESTOR)
1917 || (mode != XCB_NOTIFY_MODE_NORMAL && mode != XCB_NOTIFY_MODE_UNGRAB)
1918 || detail == XCB_NOTIFY_DETAIL_VIRTUAL
1919 || detail == XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL);
1920}
1921
1922void QXcbWindow::handleEnterNotifyEvent(int event_x, int event_y, int root_x, int root_y,
1923 quint8 mode, quint8 detail, xcb_timestamp_t timestamp)
1924{
1925 connection()->setTime(timestamp);
1926
1927 const QPoint global = QPoint(root_x, root_y);
1928
1929 if (ignoreEnterEvent(mode, detail, connection()) || connection()->mousePressWindow())
1930 return;
1931
1932 // Updates scroll valuators, as user might have done some scrolling outside our X client.
1934
1935 const QPoint local(event_x, event_y);
1937}
1938
1939void QXcbWindow::handleLeaveNotifyEvent(int root_x, int root_y,
1940 quint8 mode, quint8 detail, xcb_timestamp_t timestamp)
1941{
1942 connection()->setTime(timestamp);
1943
1944 if (ignoreLeaveEvent(mode, detail, connection()) || connection()->mousePressWindow())
1945 return;
1946
1947 // check if enter event is buffered
1948 auto event = connection()->eventQueue()->peek([](xcb_generic_event_t *event, int type) {
1949 if (type != XCB_ENTER_NOTIFY)
1950 return false;
1951 auto enter = reinterpret_cast<xcb_enter_notify_event_t *>(event);
1952 return !ignoreEnterEvent(enter->mode, enter->detail);
1953 });
1954 auto enter = reinterpret_cast<xcb_enter_notify_event_t *>(event);
1955 QXcbWindow *enterWindow = enter ? connection()->platformWindowFromId(enter->event) : nullptr;
1956
1957 if (enterWindow) {
1958 QPoint local(enter->event_x, enter->event_y);
1959 QPoint global = QPoint(root_x, root_y);
1961 } else {
1963 }
1964
1965 free(enter);
1966}
1967
1968void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, int root_y,
1969 Qt::KeyboardModifiers modifiers, xcb_timestamp_t timestamp,
1971{
1972 QPoint local(event_x, event_y);
1973 QPoint global(root_x, root_y);
1974
1975 // "mousePressWindow" can be NULL i.e. if a window will be grabbed or unmapped, so set it again here.
1976 // Unset "mousePressWindow" when mouse button isn't pressed - in some cases the release event won't arrive.
1977 const bool isMouseButtonPressed = (connection()->buttonState() != Qt::NoButton);
1978 const bool hasMousePressWindow = (connection()->mousePressWindow() != nullptr);
1979 if (isMouseButtonPressed && !hasMousePressWindow)
1981 else if (hasMousePressWindow && !isMouseButtonPressed)
1982 connection()->setMousePressWindow(nullptr);
1983
1984 handleMouseEvent(timestamp, local, global, modifiers, type, source);
1985}
1986
1987void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
1988{
1989 Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
1990 handleButtonPressEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail,
1992}
1993
1994void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event)
1995{
1996 Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
1997 handleButtonReleaseEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->detail,
1999}
2000
2001void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
2002{
2003 Qt::KeyboardModifiers modifiers = connection()->keyboard()->translateModifiers(event->state);
2004 handleMotionNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, modifiers,
2005 event->time, QEvent::MouseMove);
2006}
2007
2008static inline int fixed1616ToInt(xcb_input_fp1616_t val)
2009{
2010 return int(qreal(val) / 0x10000);
2011}
2012
2013#define qt_xcb_mask_is_set(ptr, event) (((unsigned char*)(ptr))[(event)>>3] & (1 << ((event) & 7)))
2014
2016{
2017 QXcbConnection *conn = connection();
2018 auto *ev = reinterpret_cast<xcb_input_button_press_event_t *>(event);
2019
2020 if (ev->buttons_len > 0) {
2021 unsigned char *buttonMask = (unsigned char *) &ev[1];
2022 // There is a bug in the evdev driver which leads to receiving mouse events without
2023 // XIPointerEmulated being set: https://bugs.freedesktop.org/show_bug.cgi?id=98188
2024 // Filter them out by other attributes: when their source device is a touch screen
2025 // and the LMB is pressed.
2026 if (qt_xcb_mask_is_set(buttonMask, 1) && conn->isTouchScreen(ev->sourceid)) {
2027 if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
2028 qCDebug(lcQpaXInput, "XI2 mouse event from touch device %d was ignored", ev->sourceid);
2029 return;
2030 }
2031 for (int i = 1; i <= 15; ++i)
2032 conn->setButtonState(conn->translateMouseButton(i), qt_xcb_mask_is_set(buttonMask, i));
2033 }
2034
2035 const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective);
2036 const int event_x = fixed1616ToInt(ev->event_x);
2037 const int event_y = fixed1616ToInt(ev->event_y);
2038 const int root_x = fixed1616ToInt(ev->root_x);
2039 const int root_y = fixed1616ToInt(ev->root_y);
2040
2041 conn->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group);
2042
2043 const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail);
2044
2045 const char *sourceName = nullptr;
2046 if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) {
2047 const QMetaObject *metaObject = qt_getEnumMetaObject(source);
2048 const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source)));
2049 sourceName = me.valueToKey(source);
2050 }
2051
2052 switch (ev->event_type) {
2053 case XCB_INPUT_BUTTON_PRESS:
2054 if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
2055 qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName);
2056 conn->setButtonState(button, true);
2057 handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, QEvent::MouseButtonPress, source);
2058 break;
2059 case XCB_INPUT_BUTTON_RELEASE:
2060 if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
2061 qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName);
2062 conn->setButtonState(button, false);
2063 handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, QEvent::MouseButtonRelease, source);
2064 break;
2065 case XCB_INPUT_MOTION:
2066 if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
2067 qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName);
2068 handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, QEvent::MouseMove, source);
2069 break;
2070 default:
2071 qWarning() << "Unrecognized XI2 mouse event" << ev->event_type;
2072 break;
2073 }
2074}
2075
2077{
2078 auto *ev = reinterpret_cast<xcb_input_enter_event_t *>(event);
2079
2080 // Compare the window with current mouse grabber to prevent deliver events to any other windows.
2081 // If leave event occurs and the window is under mouse - allow to deliver the leave event.
2082 QXcbWindow *mouseGrabber = connection()->mouseGrabber();
2083 if (mouseGrabber && mouseGrabber != this
2084 && (ev->event_type != XCB_INPUT_LEAVE || QGuiApplicationPrivate::currentMouseWindow != window())) {
2085 return;
2086 }
2087
2088 const int root_x = fixed1616ToInt(ev->root_x);
2089 const int root_y = fixed1616ToInt(ev->root_y);
2090
2091 switch (ev->event_type) {
2092 case XCB_INPUT_ENTER: {
2093 const int event_x = fixed1616ToInt(ev->event_x);
2094 const int event_y = fixed1616ToInt(ev->event_y);
2095 qCDebug(lcQpaXInputEvents, "XI2 mouse enter %d,%d, mode %d, detail %d, time %d",
2096 event_x, event_y, ev->mode, ev->detail, ev->time);
2097 handleEnterNotifyEvent(event_x, event_y, root_x, root_y, ev->mode, ev->detail, ev->time);
2098 break;
2099 }
2100 case XCB_INPUT_LEAVE:
2101 qCDebug(lcQpaXInputEvents, "XI2 mouse leave, mode %d, detail %d, time %d",
2102 ev->mode, ev->detail, ev->time);
2103 connection()->keyboard()->updateXKBStateFromXI(&ev->mods, &ev->group);
2104 handleLeaveNotifyEvent(root_x, root_y, ev->mode, ev->detail, ev->time);
2105 break;
2106 }
2107}
2108
2110
2111void QXcbWindow::handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
2112 Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source)
2113{
2114 m_lastPointerPosition = local;
2119 connection()->buttonState(), button,
2121}
2122
2123void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *event)
2124{
2125 handleEnterNotifyEvent(event->event_x, event->event_y, event->root_x, event->root_y, event->mode, event->detail, event->time);
2126}
2127
2128void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
2129{
2130 handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
2131}
2132
2133void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
2134{
2135 connection()->setTime(event->time);
2136
2137 const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
2138
2140 if (propertyDeleted)
2141 return;
2142
2143 Qt::WindowStates newState = Qt::WindowNoState;
2144
2145 if (event->atom == atom(QXcbAtom::AtomWM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
2146 auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
2148 XCB_ATOM_ANY, 0, 1024);
2149 if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::AtomWM_STATE)) {
2150 const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
2151 if (reply->length != 0)
2152 m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
2153 || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
2154 }
2155 }
2156
2157 const NetWmStates states = netWmStates();
2158 // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
2159 // not be visible on the screen if its desktop/viewport were active and its coordinates were
2160 // within the screen bounds. The canonical example is that minimized windows should be in
2161 // the _NET_WM_STATE_HIDDEN state.
2162 if (m_minimized && (!connection()->wmSupport()->isSupportedByWM(NetWmStateHidden)
2163 || states.testFlag(NetWmStateHidden)))
2165
2170 // Send Window state, compress events in case other flags (modality, etc) are changed.
2175 if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
2176 connection()->setMouseGrabber(nullptr);
2177 }
2178 return;
2179 } else if (event->atom == atom(QXcbAtom::Atom_NET_FRAME_EXTENTS)) {
2180 m_dirtyFrameMargins = true;
2181 }
2182}
2183
2184void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *event)
2185{
2186 // Ignore focus events that are being sent only because the pointer is over
2187 // our window, even if the input focus is in a different window.
2188 if (event->detail == XCB_NOTIFY_DETAIL_POINTER)
2189 return;
2190
2192 doFocusIn();
2193}
2194
2195
2196void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *event)
2197{
2198 // Ignore focus events that are being sent only because the pointer is over
2199 // our window, even if the input focus is in a different window.
2200 if (event->detail == XCB_NOTIFY_DETAIL_POINTER)
2201 return;
2202 doFocusOut();
2203}
2204
2206{
2208 // window manager does not expect a sync event yet.
2209 return;
2210 }
2211 if (connection()->hasXSync() && (m_syncValue.lo != 0 || m_syncValue.hi != 0)) {
2212 xcb_sync_set_counter(xcb_connection(), m_syncCounter, m_syncValue);
2213 xcb_flush(xcb_connection());
2214
2215 m_syncValue.lo = 0;
2216 m_syncValue.hi = 0;
2218 }
2219}
2220
2221const xcb_visualtype_t *QXcbWindow::createVisual()
2222{
2224 : nullptr;
2225}
2226
2228{
2229 if (grab && !connection()->canGrab())
2230 return false;
2231
2232 if (!grab) {
2233 xcb_ungrab_keyboard(xcb_connection(), XCB_TIME_CURRENT_TIME);
2234 return true;
2235 }
2236
2237 auto reply = Q_XCB_REPLY(xcb_grab_keyboard, xcb_connection(), false,
2238 m_window, XCB_TIME_CURRENT_TIME,
2239 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
2240 return reply && reply->status == XCB_GRAB_STATUS_SUCCESS;
2241}
2242
2244{
2245 if (!grab && connection()->mouseGrabber() == this)
2246 connection()->setMouseGrabber(nullptr);
2247
2248 if (grab && !connection()->canGrab())
2249 return false;
2250
2251 if (connection()->hasXInput2()) {
2253 if (grab && result)
2254 connection()->setMouseGrabber(this);
2255 return result;
2256 }
2257
2258 if (!grab) {
2259 xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME);
2260 return true;
2261 }
2262
2263 auto reply = Q_XCB_REPLY(xcb_grab_pointer, xcb_connection(),
2264 false, m_window,
2265 (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
2266 | XCB_EVENT_MASK_BUTTON_MOTION | XCB_EVENT_MASK_ENTER_WINDOW
2267 | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION),
2268 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
2269 XCB_WINDOW_NONE, XCB_CURSOR_NONE,
2270 XCB_TIME_CURRENT_TIME);
2271 bool result = reply && reply->status == XCB_GRAB_STATUS_SUCCESS;
2272 if (result)
2273 connection()->setMouseGrabber(this);
2274 return result;
2275}
2276
2278{
2279 switch (event->type()) {
2280 case QEvent::FocusIn:
2281 if (m_embedded && !m_trayIconWindow && !event->spontaneous()) {
2282 QFocusEvent *focusEvent = static_cast<QFocusEvent *>(event);
2283 switch (focusEvent->reason()) {
2284 case Qt::TabFocusReason:
2286 {
2287 const QXcbWindow *container =
2288 static_cast<const QXcbWindow *>(parent());
2289 sendXEmbedMessage(container->xcb_window(),
2290 focusEvent->reason() == Qt::TabFocusReason ?
2292 event->accept();
2293 }
2294 break;
2295 default:
2296 break;
2297 }
2298 }
2299 break;
2300 default:
2301 break;
2302 }
2304}
2305
2307{
2309}
2310
2312{
2314}
2315
2317{
2318 const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE);
2319 if (!connection()->wmSupport()->isSupportedByWM(moveResize))
2320 return false;
2321
2322 // ### FIXME QTBUG-53389
2323 bool startedByTouch = connection()->startSystemMoveResizeForTouch(m_window, edges);
2324 if (startedByTouch) {
2325 const QString wmname = connection()->windowManagerName();
2326 if (wmname != "kwin"_L1 && wmname != "openbox"_L1) {
2327 qCDebug(lcQpaXInputDevices) << "only KDE and OpenBox support startSystemMove/Resize which is triggered from touch events: XDG_CURRENT_DESKTOP="
2328 << qgetenv("XDG_CURRENT_DESKTOP");
2330 return false;
2331 }
2332 // KWin, Openbox, AwesomeWM and Gnome have been tested to work with _NET_WM_MOVERESIZE.
2333 } else { // Started by mouse press.
2335 }
2336
2337 return true;
2338}
2339
2341{
2342 if (edges == (Qt::TopEdge | Qt::LeftEdge))
2343 return 0;
2344 if (edges == Qt::TopEdge)
2345 return 1;
2346 if (edges == (Qt::TopEdge | Qt::RightEdge))
2347 return 2;
2348 if (edges == Qt::RightEdge)
2349 return 3;
2350 if (edges == (Qt::RightEdge | Qt::BottomEdge))
2351 return 4;
2352 if (edges == Qt::BottomEdge)
2353 return 5;
2354 if (edges == (Qt::BottomEdge | Qt::LeftEdge))
2355 return 6;
2356 if (edges == Qt::LeftEdge)
2357 return 7;
2358
2359 qWarning() << "Cannot convert " << edges << "to _NET_WM_MOVERESIZE direction.";
2360 return 0;
2361}
2362
2363void QXcbWindow::doStartSystemMoveResize(const QPoint &globalPos, int edges)
2364{
2365 qCDebug(lcQpaXInputDevices) << "triggered system move or resize via sending _NET_WM_MOVERESIZE client message";
2366 const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE);
2367 xcb_client_message_event_t xev;
2368 xev.response_type = XCB_CLIENT_MESSAGE;
2369 xev.type = moveResize;
2370 xev.sequence = 0;
2371 xev.window = xcb_window();
2372 xev.format = 32;
2373 xev.data.data32[0] = globalPos.x();
2374 xev.data.data32[1] = globalPos.y();
2375 if (edges == 16)
2376 xev.data.data32[2] = 8; // move
2377 else
2378 xev.data.data32[2] = qtEdgesToXcbMoveResizeDirection(Qt::Edges(edges));
2379 xev.data.data32[3] = XCB_BUTTON_INDEX_1;
2380 xev.data.data32[4] = 0;
2381 xcb_ungrab_pointer(connection()->xcb_connection(), XCB_CURRENT_TIME);
2382 xcb_send_event(connection()->xcb_connection(), false, xcbScreen()->root(),
2383 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
2384 (const char *)&xev);
2385
2387}
2388
2389// Sends an XEmbed message.
2391 quint32 detail, quint32 data1, quint32 data2)
2392{
2393 xcb_client_message_event_t event;
2394
2395 event.response_type = XCB_CLIENT_MESSAGE;
2396 event.format = 32;
2397 event.sequence = 0;
2398 event.window = window;
2399 event.type = atom(QXcbAtom::Atom_XEMBED);
2400 event.data.data32[0] = connection()->time();
2401 event.data.data32[1] = message;
2402 event.data.data32[2] = detail;
2403 event.data.data32[3] = data1;
2404 event.data.data32[4] = data2;
2405 xcb_send_event(xcb_connection(), false, window, XCB_EVENT_MASK_NO_EVENT, (const char *)&event);
2406}
2407
2409{
2410 /* Check from window system event queue if the next queued activation
2411 * targets a window other than @window.
2412 */
2416 return systemEvent && systemEvent->activated != window;
2417}
2418
2419void QXcbWindow::handleXEmbedMessage(const xcb_client_message_event_t *event)
2420{
2421 connection()->setTime(event->data.data32[0]);
2422 switch (event->data.data32[1]) {
2425 break;
2427 xcb_map_window(xcb_connection(), m_window);
2428 xcbScreen()->windowShown(this);
2429 break;
2430 case XEMBED_FOCUS_IN:
2432 Qt::FocusReason reason;
2433 switch (event->data.data32[2]) {
2434 case XEMBED_FOCUS_FIRST:
2435 reason = Qt::TabFocusReason;
2436 break;
2437 case XEMBED_FOCUS_LAST:
2438 reason = Qt::BacktabFocusReason;
2439 break;
2441 default:
2442 reason = Qt::OtherFocusReason;
2443 break;
2444 }
2447 break;
2448 case XEMBED_FOCUS_OUT:
2451 connection()->setFocusWindow(nullptr);
2453 }
2454 break;
2455 }
2456}
2457
2458static inline xcb_rectangle_t qRectToXCBRectangle(const QRect &r)
2459{
2460 xcb_rectangle_t result;
2461 result.x = qMax(SHRT_MIN, r.x());
2462 result.y = qMax(SHRT_MIN, r.y());
2463 result.width = qMin((int)USHRT_MAX, r.width());
2464 result.height = qMin((int)USHRT_MAX, r.height());
2465 return result;
2466}
2467
2469{
2470 if (!m_window)
2471 return;
2472
2473 quint32 value = qRound64(qBound(qreal(0), level, qreal(1)) * 0xffffffff);
2474
2475 xcb_change_property(xcb_connection(),
2476 XCB_PROP_MODE_REPLACE,
2477 m_window,
2479 XCB_ATOM_CARDINAL,
2480 32,
2481 1,
2482 (uchar *)&value);
2483}
2484
2486{
2488 rects.reserve(region.rectCount());
2489 for (const QRect &r : region)
2491 return rects;
2492}
2493
2494void QXcbWindow::setMask(const QRegion &region)
2495{
2496 if (!connection()->hasXShape())
2497 return;
2498 if (region.isEmpty()) {
2499 xcb_shape_mask(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
2500 XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE);
2501 } else {
2502 const auto rects = qRegionToXcbRectangleList(region);
2503 xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
2504 XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
2505 xcb_window(), 0, 0, rects.size(), &rects[0]);
2506 }
2507}
2508
2510{
2511 if (m_alertState == enabled)
2512 return;
2513
2515
2517}
2518
2520{
2521 return m_visualId;
2522}
2523
2525{
2527}
2528
2530{
2531 if (!m_pendingSyncRequest) {
2535 }
2536}
2537
2539{
2540 return static_cast<QXcbScreen *>(screen());
2541}
2542
2543void QXcbWindow::setWindowTitle(const QXcbConnection *conn, xcb_window_t window, const QString &title)
2544{
2545 QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH
2546 const QByteArray ba = std::move(fullTitle).toUtf8();
2547 xcb_change_property(conn->xcb_connection(),
2548 XCB_PROP_MODE_REPLACE,
2549 window,
2552 8,
2553 ba.size(),
2554 ba.constData());
2555
2556#if QT_CONFIG(xcb_xlib)
2557 Display *dpy = static_cast<Display *>(conn->xlib_display());
2558 XTextProperty *text = qstringToXTP(dpy, title);
2559 if (text)
2560 XSetWMName(dpy, window, text);
2561#endif
2562 xcb_flush(conn->xcb_connection());
2563}
2564
2566{
2567 const xcb_atom_t utf8Atom = conn->atom(QXcbAtom::AtomUTF8_STRING);
2568 auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, conn->xcb_connection(),
2569 false, window, conn->atom(QXcbAtom::Atom_NET_WM_NAME),
2570 utf8Atom, 0, 1024);
2571 if (reply && reply->format == 8 && reply->type == utf8Atom) {
2572 const char *name = reinterpret_cast<const char *>(xcb_get_property_value(reply.get()));
2573 return QString::fromUtf8(name, xcb_get_property_value_length(reply.get()));
2574 }
2575
2576 reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, conn->xcb_connection(),
2577 false, window, conn->atom(QXcbAtom::AtomWM_NAME),
2578 XCB_ATOM_STRING, 0, 1024);
2579 if (reply && reply->format == 8 && reply->type == XCB_ATOM_STRING) {
2580 const char *name = reinterpret_cast<const char *>(xcb_get_property_value(reply.get()));
2581 return QString::fromLatin1(name, xcb_get_property_value_length(reply.get()));
2582 }
2583
2584 return QString();
2585}
2586
2588
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:534
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:474
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:106
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
@ MouseMove
Definition qcoreevent.h:63
@ FocusIn
Definition qcoreevent.h:66
@ MouseButtonPress
Definition qcoreevent.h:60
@ MouseButtonRelease
Definition qcoreevent.h:61
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
Qt::FocusReason reason() const
Returns the reason for this focus event.
Definition qevent.cpp:1566
static QGuiApplicationPrivate * instance()
static QWindow * currentMouseWindow
bool isWindowBlocked(QWindow *window, QWindow **blockingWindow=nullptr) const
static QWindow * modalWindow()
Returns the most recently shown modal window.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
static qreal factor(C *context)
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition qicon.cpp:973
QList< QSize > availableSizes(Mode mode=Normal, State state=Off) const
Definition qicon.cpp:1098
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition qicon.cpp:788
\inmodule QtGui
Definition qimage.h:37
@ Format_RGB32
Definition qimage.h:46
@ Format_RGB16
Definition qimage.h:49
@ Format_ARGB32
Definition qimage.h:47
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
const_pointer constData() const noexcept
Definition qlist.h:416
bool isEmpty() const noexcept
Definition qlist.h:390
T & first()
Definition qlist.h:628
void push_back(parameter_type t)
Definition qlist.h:672
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
void reserve(qsizetype size)
Definition qlist.h:746
pointer data()
Definition qlist.h:414
void resize(qsizetype size)
Definition qlist.h:392
void append(parameter_type t)
Definition qlist.h:441
void clear()
Definition qlist.h:417
\inmodule QtCore
Definition qmargins.h:23
\inmodule QtCore
const char * valueToKey(int value) const
Returns the string that is used as the name of the given enumeration value, or \nullptr if value is n...
QObject * parent
Definition qobject.h:61
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:153
\inmodule QtCore
Definition qobject.h:90
const QObjectList & children() const
Returns a list of child objects.
Definition qobject.h:171
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4187
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
virtual QPoint pos() const
The QPlatformScreen class provides an abstraction for visual displays.
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
QScreen * screen() const
virtual QWindow * topLevelAt(const QPoint &point) const
Return the given top level window for a given position.
The QPlatformWindow class provides an abstraction for top-level windows.
static QString formatWindowTitle(const QString &title, const QString &separator)
Call this method to put together a window title composed of title separator the application display n...
virtual QPoint mapFromGlobal(const QPoint &pos) const
Translates the global screen coordinate pos to window coordinates using native methods.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
QPlatformScreen * screenForGeometry(const QRect &newGeometry) const
Helper function for finding the new screen for newGeometry in response to a geometry changed event.
QPlatformScreen * screen() const override
Returns the platform screen handle corresponding to this platform window, or null if the window is no...
QSize windowMinimumSize() const
Returns the QWindow minimum size.
virtual bool windowEvent(QEvent *event)
Reimplement this method to be able to do any platform specific event handling.
QPlatformWindow * parent() const
Returns the parent platform window (or \nullptr if orphan).
virtual void setGeometry(const QRect &rect)
This function is called by Qt whenever a window is moved or resized using the QWindow API.
virtual void requestActivateWindow()
Reimplement to let Qt be able to request activation/focus for a window.
virtual QRect geometry() const
Returns the current geometry of a window.
virtual WId winId() const
Reimplement in subclasses to return a handle to the native window.
virtual bool isAncestorOf(const QPlatformWindow *child) const
Returns true if the window is an ancestor of the given child.
virtual QPoint mapToGlobal(const QPoint &pos) const
Translates the window coordinate pos to global screen coordinates using native methods.
virtual bool isForeignWindow() const
QSize windowBaseSize() const
Returns the QWindow base size.
QSize windowMaximumSize() const
Returns the QWindow maximum size.
QSize windowSizeIncrement() const
Returns the QWindow size increment.
\inmodule QtCore\reentrant
Definition qpoint.h:23
constexpr QPoint transposed() const noexcept
Definition qpoint.h:37
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:127
constexpr void setY(int y) noexcept
Sets the y coordinate of this point to the given y coordinate.
Definition qpoint.h:142
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:132
constexpr void setX(int x) noexcept
Sets the x coordinate of this point to the given x coordinate.
Definition qpoint.h:137
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:220
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:851
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:241
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:235
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
int rectCount() const noexcept
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Definition qsize.h:123
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QByteArray toLatin1() const &
Definition qstring.h:559
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5710
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
QByteArray toLocal8Bit() const &
Definition qstring.h:567
QByteArray toUtf8() const &
Definition qstring.h:563
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
bool hasAlpha() const
Returns true if the alpha buffer size is greater than zero.
@ OpenGLSurface
Definition qsurface.h:32
@ VulkanSurface
Definition qsurface.h:35
static QString machineHostName()
Definition qsysinfo.cpp:926
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:208
void stop()
Stops the timer.
Definition qtimer.cpp:226
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition qwidget.h:106
QScreen * screenForGeometry(const QRect &rect) const
Definition qwindow.cpp:1790
static WindowSystemEvent * peekWindowSystemEvent(EventType t)
static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result)
Passes a native event identified by eventType to the window.
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen)
static void handleLeaveEvent(QWindow *window)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static bool handleCloseEvent(QWindow *window)
static void handleGeometryChange(QWindow *window, const QRect &newRect)
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local=QPointF(), const QPointF &global=QPointF())
This method can be used to ensure leave and enter events are both in queue when moving from one QWind...
static bool handleExposeEvent(QWindow *window, const QRegion &region)
static void handleWindowActivated(QWindow *window, Qt::FocusReason r=Qt::OtherFocusReason)
static void handleEnterEvent(QWindow *window, const QPointF &local=QPointF(), const QPointF &global=QPointF())
static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::ScrollPhase phase=Qt::NoScrollPhase, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState=-1)
\inmodule QtGui
Definition qwindow.h:63
Qt::WindowFlags flags
the window flags of the window
Definition qwindow.h:79
@ AtomXdndDrop
Definition qxcbatom.h:140
@ Atom_NET_WM_STATE_MAXIMIZED_HORZ
Definition qxcbatom.h:87
@ Atom_NET_WM_WINDOW_TYPE_DROPDOWN_MENU
Definition qxcbatom.h:106
@ Atom_NET_WM_WINDOW_TYPE_COMBO
Definition qxcbatom.h:110
@ Atom_NET_WM_PID
Definition qxcbatom.h:79
@ Atom_COMPIZ_DECOR_DELETE_PIXMAP
Definition qxcbatom.h:200
@ AtomWM_PROTOCOLS
Definition qxcbatom.h:13
@ Atom_NET_WM_WINDOW_TYPE_MENU
Definition qxcbatom.h:102
@ Atom_MOTIF_WM_HINTS
Definition qxcbatom.h:60
@ Atom_XEMBED_INFO
Definition qxcbatom.h:161
@ Atom_NET_WM_MOVERESIZE
Definition qxcbatom.h:73
@ AtomWM_NAME
Definition qxcbatom.h:27
@ Atom_NET_WM_WINDOW_TYPE
Definition qxcbatom.h:98
@ Atom_COMPIZ_DECOR_PENDING
Definition qxcbatom.h:198
@ Atom_NET_WM_WINDOW_TYPE_DOCK
Definition qxcbatom.h:100
@ Atom_NET_WM_PING
Definition qxcbatom.h:16
@ AtomXdndLeave
Definition qxcbatom.h:139
@ Atom_GTK_LOAD_ICONTHEMES
Definition qxcbatom.h:202
@ Atom_NET_WM_WINDOW_TYPE_POPUP_MENU
Definition qxcbatom.h:107
@ Atom_XEMBED
Definition qxcbatom.h:160
@ AtomWM_CLIENT_MACHINE
Definition qxcbatom.h:33
@ Atom_NET_WM_STATE_HIDDEN
Definition qxcbatom.h:92
@ AtomWM_CHANGE_STATE
Definition qxcbatom.h:25
@ AtomXdndEnter
Definition qxcbatom.h:136
@ Atom_NET_WM_WINDOW_TYPE_UTILITY
Definition qxcbatom.h:103
@ Atom_NET_WM_WINDOW_TYPE_DND
Definition qxcbatom.h:111
@ Atom_NET_WM_STATE_BELOW
Definition qxcbatom.h:85
@ Atom_NET_WM_WINDOW_TYPE_DIALOG
Definition qxcbatom.h:105
@ AtomWM_CLIENT_LEADER
Definition qxcbatom.h:30
@ Atom_NET_WM_STATE_MAXIMIZED_VERT
Definition qxcbatom.h:88
@ Atom_KDE_NET_WM_WINDOW_TYPE_OVERRIDE
Definition qxcbatom.h:113
@ Atom_NET_WM_STATE
Definition qxcbatom.h:83
@ Atom_NET_FRAME_EXTENTS
Definition qxcbatom.h:116
@ Atom_NET_WM_SYNC_REQUEST
Definition qxcbatom.h:18
@ Atom_NET_WM_STATE_MODAL
Definition qxcbatom.h:89
@ AtomMANAGER
Definition qxcbatom.h:20
@ Atom_NET_WM_ICON
Definition qxcbatom.h:77
@ Atom_NET_WM_SYNC_REQUEST_COUNTER
Definition qxcbatom.h:19
@ Atom_NET_WM_WINDOW_OPACITY
Definition qxcbatom.h:81
@ Atom_NET_WM_STATE_STAYS_ON_TOP
Definition qxcbatom.h:90
@ AtomWM_WINDOW_ROLE
Definition qxcbatom.h:31
@ Atom_NET_WM_WINDOW_TYPE_TOOLBAR
Definition qxcbatom.h:101
@ Atom_NET_WM_STATE_ABOVE
Definition qxcbatom.h:84
@ AtomUTF8_STRING
Definition qxcbatom.h:132
@ Atom_NET_WM_ICON_NAME
Definition qxcbatom.h:76
@ Atom_COMPIZ_DECOR_REQUEST
Definition qxcbatom.h:199
@ AtomWM_DELETE_WINDOW
Definition qxcbatom.h:14
@ Atom_NET_WM_WINDOW_TYPE_TOOLTIP
Definition qxcbatom.h:108
@ Atom_NET_WM_WINDOW_TYPE_SPLASH
Definition qxcbatom.h:104
@ Atom_NET_WM_STATE_FULLSCREEN
Definition qxcbatom.h:86
@ Atom_NET_WM_STATE_DEMANDS_ATTENTION
Definition qxcbatom.h:91
@ AtomWM_CLASS
Definition qxcbatom.h:26
@ Atom_NET_WM_WINDOW_TYPE_NORMAL
Definition qxcbatom.h:112
@ Atom_NET_WM_NAME
Definition qxcbatom.h:75
@ Atom_NET_WM_CONTEXT_HELP
Definition qxcbatom.h:17
@ AtomCARDINAL
Definition qxcbatom.h:133
@ AtomXdndPosition
Definition qxcbatom.h:137
@ AtomWM_STATE
Definition qxcbatom.h:24
@ Atom_NET_WM_USER_TIME
Definition qxcbatom.h:94
@ AtomWM_TAKE_FOCUS
Definition qxcbatom.h:15
@ Atom_NET_WM_USER_TIME_WINDOW
Definition qxcbatom.h:95
@ Atom_NET_ACTIVE_WINDOW
Definition qxcbatom.h:128
@ Atom_COMPIZ_TOOLKIT_ACTION
Definition qxcbatom.h:201
@ Atom_NET_WM_WINDOW_TYPE_DESKTOP
Definition qxcbatom.h:99
@ Atom_NET_WM_WINDOW_TYPE_NOTIFICATION
Definition qxcbatom.h:109
QXcbAtom::Atom qatom(xcb_atom_t atom) const
QByteArray atomName(xcb_atom_t atom)
xcb_connection_t * xcb_connection() const
xcb_atom_t atom(QXcbAtom::Atom qatom) const
void setMousePressWindow(QXcbWindow *)
Qt::MouseButton translateMouseButton(xcb_button_t s)
QXcbKeyboard * keyboard() const
QTimer & focusInTimer()
QXcbWindow * mouseGrabber() const
QXcbWindow * mousePressWindow() const
Qt::MouseButtons buttonState() const
void setMouseGrabber(QXcbWindow *)
void setTime(xcb_timestamp_t t)
void setButtonState(Qt::MouseButton button, bool down)
QString windowManagerName() const
xcb_visualid_t defaultVisualId() const
bool isTouchScreen(int id)
void setNetWmUserTime(xcb_timestamp_t t)
xcb_timestamp_t time() const
bool startSystemMoveResizeForTouch(xcb_window_t window, int edges)
QXcbWMSupport * wmSupport() const
void setFocusWindow(QWindow *)
void abortSystemMoveResize(xcb_window_t window)
QXcbEventQueue * eventQueue() const
xcb_window_t clientLeader()
void setDuringSystemMoveResize(bool during)
void xi2SelectDeviceEvents(xcb_window_t window)
Qt::MouseButton xiToQtMouseButton(uint32_t b)
Qt::MouseButton button() const
QXcbNativeInterface * nativeInterface() const
QXcbWindow * platformWindowFromId(xcb_window_t id)
bool xi2SetMouseGrabEnabled(xcb_window_t w, bool grab)
void addWindowEventListener(xcb_window_t id, QXcbWindowEventListener *eventListener)
QXcbSystemTrayTracker * systemTrayTracker() const
void removeWindowEventListener(xcb_window_t id)
xcb_generic_event_t * peek(Peeker &&peeker)
QByteArray wmClass() const
static QXcbIntegration * instance()
Qt::KeyboardModifiers translateModifiers(int s) const
void updateXKBStateFromXI(void *modInfo, void *groupInfo)
const QByteArray & nativeEventType() const
QXcbConnection * connection() const
Definition qxcbobject.h:17
xcb_connection_t * xcb_connection() const
Definition qxcbobject.h:20
xcb_atom_t atom(QXcbAtom::Atom atom) const
Definition qxcbobject.h:19
void setConnection(QXcbConnection *connection)
Definition qxcbobject.h:16
const xcb_visualtype_t * visualForFormat(const QSurfaceFormat &format) const
Definition qxcbscreen.h:173
QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &format) const
xcb_screen_t * screen() const
Definition qxcbscreen.h:152
xcb_window_t root() const
Definition qxcbscreen.h:153
quint8 depthOfVisual(xcb_visualid_t visualid) const
Definition qxcbscreen.h:176
const xcb_visualtype_t * visualForId(xcb_visualid_t visualid) const
QList< QPlatformScreen * > virtualSiblings() const override
Returns a list of all the platform screens that are part of the same virtual desktop.
Definition qxcbscreen.h:143
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
void windowShown(QXcbWindow *window)
xcb_colormap_t colormapForVisual(xcb_visualid_t visualid) const
Definition qxcbscreen.h:175
void requestSystemTrayWindowDock(xcb_window_t window) const
const QList< xcb_window_t > & virtualRoots() const
bool isSupportedByWM(xcb_atom_t atom) const
xcb_window_t xcb_window() const
Definition qxcbwindow.h:91
@ NetWmStateMaximizedHorz
Definition qxcbwindow.h:31
@ NetWmStateModal
Definition qxcbwindow.h:33
@ NetWmStateHidden
Definition qxcbwindow.h:36
@ NetWmStateStaysOnTop
Definition qxcbwindow.h:34
@ NetWmStateBelow
Definition qxcbwindow.h:29
@ NetWmStateFullScreen
Definition qxcbwindow.h:30
@ NetWmStateAbove
Definition qxcbwindow.h:28
@ NetWmStateMaximizedVert
Definition qxcbwindow.h:32
@ NetWmStateDemandsAttention
Definition qxcbwindow.h:35
QXcbWindow * toWindow() override
xcb_window_t m_window
Definition qxcbwindow.h:209
Qt::WindowStates m_windowState
Definition qxcbwindow.h:218
bool m_minimized
Definition qxcbwindow.h:225
void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event) override
void handleClientMessageEvent(const xcb_client_message_event_t *event) override
void setMask(const QRegion &region) override
Reimplement to be able to let Qt set the mask of a window.
void updateSyncRequestCounter()
QSurfaceFormat format() const override
Returns the actual surface format of the window.
bool m_imageRgbSwap
Definition qxcbwindow.h:213
QXcbScreen * initialScreen() const
void setOpacity(qreal level) override
Reimplement to be able to let Qt set the opacity level of a window.
WindowTypes wmWindowTypes() const
bool requestSystemTrayWindowDock()
virtual const xcb_visualtype_t * createVisual()
void setTransparentForMouseEvents(bool transparent)
virtual void destroy()
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
bool m_dirtyFrameMargins
Definition qxcbwindow.h:231
QMargins m_frameMargins
Definition qxcbwindow.h:232
QRegion m_exposeRegion
Definition qxcbwindow.h:234
bool startSystemResize(Qt::Edges edges) override
Reimplement this method to start a system resize operation if the system supports it and return true ...
void setWmWindowType(WindowTypes types, Qt::WindowFlags flags)
@ SyncAndConfigureReceived
Definition qxcbwindow.h:246
bool setKeyboardGrabEnabled(bool grab) override
void handleButtonReleaseEvent(const xcb_button_release_event_t *event) override
bool handleNativeEvent(xcb_generic_event_t *event) override
void handleExposeEvent(const xcb_expose_event_t *event) override
void handleXIEnterLeave(xcb_ge_event_t *) override
QSurfaceFormat m_format
Definition qxcbwindow.h:229
xcb_sync_int64_t m_syncValue
Definition qxcbwindow.h:215
void setAlertState(bool enabled) override
Reimplement this method to set whether the window demands attention (for example, by flashing the tas...
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
QXcbScreen * xcbScreen() const
bool m_deferredActivation
Definition qxcbwindow.h:222
void handleXEmbedMessage(const xcb_client_message_event_t *event)
uint visualId() const override
void propagateSizeHints() override
Reimplement to propagate the size hints of the QWindow.
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
void updateNetWmUserTime(xcb_timestamp_t timestamp)
QXcbWindow(QWindow *window)
void setNetWmState(bool set, xcb_atom_t one, xcb_atom_t two=0)
QPoint m_lastPointerPosition
Definition qxcbwindow.h:236
void doFocusIn()
void handleMapNotifyEvent(const xcb_map_notify_event_t *event) override
QPoint m_lastPointerGlobalPosition
Definition qxcbwindow.h:237
void setMotifWmHints(Qt::WindowFlags flags)
void setWindowIconText(const QString &title) override
bool m_trayIconWindow
Definition qxcbwindow.h:226
void setImageFormatForVisual(const xcb_visualtype_t *visual)
void sendXEmbedMessage(xcb_window_t window, quint32 message, quint32 detail=0, quint32 data1=0, quint32 data2=0)
static bool isTrayIconWindow(QWindow *window)
Definition qxcbwindow.h:144
void setWindowIcon(const QIcon &icon) override
Reimplement to set the window icon to icon.
void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event) override
bool relayFocusToModalWindow() const
void setWindowRole(const QString &role) override
void postSyncWindowRequest()
QMargins frameMargins() const override
void doFocusOut()
xcb_visualid_t m_visualId
Definition qxcbwindow.h:239
SyncState m_syncState
Definition qxcbwindow.h:248
void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event) override
bool m_alertState
Definition qxcbwindow.h:224
qreal m_sizeHintsScaleFactor
Definition qxcbwindow.h:253
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
void updateDoesNotAcceptFocus(bool doesNotAcceptFocus)
xcb_sync_counter_t m_syncCounter
Definition qxcbwindow.h:216
bool m_transparent
Definition qxcbwindow.h:221
bool isExposed() const override
Returns if this window is exposed in the windowing system.
bool m_embedded
Definition qxcbwindow.h:223
void setWindowTitle(const QString &title) override
Reimplement to set the window title to title.
NetWmStates netWmStates()
QSize m_oldWindowSize
Definition qxcbwindow.h:235
bool needsSync() const
void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override
bool windowEvent(QEvent *event) override
Reimplement this method to be able to do any platform specific event handling.
void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized) override
bool isEmbedded() const override
Returns true if the window is a child of a non-Qt window.
QPoint mapFromGlobal(const QPoint &pos) const override
Translates the global screen coordinate pos to window coordinates using native methods.
void setWindowFlags(Qt::WindowFlags flags) override
Requests setting the window flags of this surface to flags.
static QString windowTitle(const QXcbConnection *conn, xcb_window_t window)
QXcbSyncWindowRequest * m_pendingSyncRequest
Definition qxcbwindow.h:250
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
QImage::Format m_imageFormat
Definition qxcbwindow.h:212
void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event) override
void handleButtonPressEvent(const xcb_button_press_event_t *event) override
Qt::WindowStates m_lastWindowStateEvent
Definition qxcbwindow.h:241
void handleFocusOutEvent(const xcb_focus_out_event_t *event) override
RecreationReasons m_recreationReasons
Definition qxcbwindow.h:255
QPoint mapToGlobal(const QPoint &pos) const override
Translates the window coordinate pos to global screen coordinates using native methods.
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
virtual void resolveFormat(const QSurfaceFormat &format)
Definition qxcbwindow.h:162
bool startSystemMoveResize(const QPoint &pos, int edges)
virtual void create()
void handleFocusInEvent(const xcb_focus_in_event_t *event) override
@ WindowStaysOnBottomHintChanged
Definition qxcbwindow.h:44
@ RecreationNotNeeded
Definition qxcbwindow.h:42
@ WindowStaysOnTopHintChanged
Definition qxcbwindow.h:43
void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global, Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source)
bool setMouseGrabEnabled(bool grab) override
void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event) override
bool startSystemMove() override
Reimplement this method to start a system move operation if the system supports it and return true to...
void doStartSystemMoveResize(const QPoint &globalPos, int edges)
void setParentRelativeBackPixmap()
bool m_mapped
Definition qxcbwindow.h:220
xcb_window_t m_netWmUserTimeWindow
Definition qxcbwindow.h:227
QXcbScreen * parentScreen()
void setNetWmStateOnUnmappedWindow()
EGLImageKHR int int EGLuint64KHR * modifiers
QString text
QPushButton * button
[2]
double e
rect
[4]
else opt state
[0]
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
T toNativePixels(const T &value, const C *context)
T toNativeLocalPosition(const T &value, const C *context)
T fromNativePixels(const T &value, const C *context)
QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *window)
Combined button and popup list for selecting options.
QFuture< QtPrivate::MapResultType< Sequence, MapFunctor > > mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map)
@ WindowFullScreen
Definition qnamespace.h:254
@ WindowNoState
Definition qnamespace.h:251
@ WindowMinimized
Definition qnamespace.h:252
@ WindowMaximized
Definition qnamespace.h:253
MouseButton
Definition qnamespace.h:55
@ NoButton
Definition qnamespace.h:56
@ NonModal
MouseEventSource
@ AltModifier
@ RightEdge
@ TopEdge
@ BottomEdge
@ LeftEdge
WindowType
Definition qnamespace.h:204
@ CustomizeWindowHint
Definition qnamespace.h:238
@ BypassWindowManagerHint
Definition qnamespace.h:222
@ Desktop
Definition qnamespace.h:214
@ FramelessWindowHint
Definition qnamespace.h:224
@ WindowDoesNotAcceptFocus
Definition qnamespace.h:235
@ WindowContextHelpButtonHint
Definition qnamespace.h:230
@ WindowStaysOnBottomHint
Definition qnamespace.h:239
@ ToolTip
Definition qnamespace.h:212
@ Drawer
Definition qnamespace.h:209
@ Popup
Definition qnamespace.h:210
@ WindowType_Mask
Definition qnamespace.h:219
@ Window
Definition qnamespace.h:206
@ SplashScreen
Definition qnamespace.h:213
@ WindowStaysOnTopHint
Definition qnamespace.h:232
@ WindowMaximizeButtonHint
Definition qnamespace.h:228
@ WindowMinimizeButtonHint
Definition qnamespace.h:227
@ Dialog
Definition qnamespace.h:207
@ WindowMinMaxButtonsHint
Definition qnamespace.h:229
@ Sheet
Definition qnamespace.h:208
@ WindowTransparentForInput
Definition qnamespace.h:233
@ Tool
Definition qnamespace.h:211
@ WindowTitleHint
Definition qnamespace.h:225
@ X11BypassWindowManagerHint
Definition qnamespace.h:223
@ WindowSystemMenuHint
Definition qnamespace.h:226
@ WindowCloseButtonHint
Definition qnamespace.h:240
FocusReason
@ BacktabFocusReason
@ OtherFocusReason
@ ActiveWindowFocusReason
@ TabFocusReason
Definition image.cpp:4
@ defaultWindowHeight
@ defaultWindowWidth
#define Q_UNLIKELY(x)
#define Q_FUNC_INFO
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall * pending
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:287
qint64 qRound64(qfloat16 d) noexcept
Definition qfloat16.h:284
#define qWarning
Definition qlogging.h:162
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
return ret
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLenum GLsizei GLsizei GLint * values
[15]
GLenum mode
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLsizei GLenum GLenum * types
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint left
GLenum type
GLint GLint bottom
GLbitfield flags
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLuint name
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei GLsizei GLchar * source
struct _cl_event * event
GLhandleARB obj
[2]
GLuint GLfloat * val
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint * states
#define QWINDOWSIZE_MAX
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QStringLiteral(str)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
struct _XDisplay Display
@ Q_PRIMITIVE_TYPE
Definition qtypeinfo.h:144
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:163
unsigned int quint32
Definition qtypes.h:45
unsigned char uchar
Definition qtypes.h:27
int qint32
Definition qtypes.h:44
unsigned long long quint64
Definition qtypes.h:56
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
unsigned char quint8
Definition qtypes.h:41
ptrdiff_t qintptr
Definition qtypes.h:71
Q_GUI_EXPORT QWindowPrivate * qt_window_private(QWindow *window)
Definition qwindow.cpp:2864
#define enabled
const char property[13]
Definition qwizard.cpp:101
#define Q_XCB_REPLY(call,...)
#define Q_XCB_REPLY_UNCHECKED(call,...)
QT_BEGIN_NAMESPACE bool qt_xcb_imageFormatForVisual(QXcbConnection *connection, uint8_t depth, const xcb_visualtype_t *visual, QImage::Format *imageFormat, bool *needsRgbSwap)
Definition qxcbimage.cpp:68
static bool fromSendEvent(const void *event)
static QXcbSystemTrayTracker * systemTrayTracker(const QScreen *s)
static uint qtEdgesToXcbMoveResizeDirection(Qt::Edges edges)
#define XCOORD_MAX
static bool doCheckUnGrabAncestor(QXcbConnection *conn)
static const char * wm_window_type_property_id
static bool isTransient(const QWindow *w)
#define qt_xcb_mask_is_set(ptr, event)
static bool ignoreEnterEvent(quint8 mode, quint8 detail, QXcbConnection *conn=nullptr)
static const char * wm_window_role_property_id
QList< xcb_rectangle_t > qRegionToXcbRectangleList(const QRegion &region)
static bool ignoreLeaveEvent(quint8 mode, quint8 detail, QXcbConnection *conn=nullptr)
static xcb_rectangle_t qRectToXCBRectangle(const QRect &r)
const quint32 XEMBED_VERSION
@ baseEventMask
@ transparentForInputEventMask
@ defaultEventMask
QX11EmbedInfoFlags
@ XEMBED_MAPPED
static int fixed1616ToInt(xcb_input_fp1616_t val)
@ defaultWindowHeight
@ defaultWindowWidth
QX11EmbedMessageType
@ XEMBED_REQUEST_FOCUS
@ XEMBED_UNREGISTER_ACCELERATOR
@ XEMBED_WINDOW_DEACTIVATE
@ XEMBED_FOCUS_OUT
@ XEMBED_REGISTER_ACCELERATOR
@ XEMBED_MODALITY_OFF
@ XEMBED_FOCUS_IN
@ XEMBED_MODALITY_ON
@ XEMBED_WINDOW_ACTIVATE
@ XEMBED_FOCUS_NEXT
@ XEMBED_FOCUS_PREV
@ XEMBED_EMBEDDED_NOTIFY
@ XEMBED_ACTIVATE_ACCELERATOR
@ MWM_HINTS_DECORATIONS
@ MWM_FUNC_MINIMIZE
@ MWM_FUNC_ALL
@ MWM_FUNC_MAXIMIZE
@ MWM_DECOR_MINIMIZE
@ MWM_DECOR_MAXIMIZE
@ MWM_HINTS_FUNCTIONS
@ MWM_DECOR_MENU
@ MWM_DECOR_BORDER
@ MWM_DECOR_ALL
@ MWM_FUNC_RESIZE
@ MWM_FUNC_MOVE
@ MWM_FUNC_CLOSE
@ MWM_DECOR_TITLE
@ MWM_DECOR_RESIZEH
QX11EmbedFocusInDetail
@ XEMBED_FOCUS_CURRENT
@ XEMBED_FOCUS_FIRST
@ XEMBED_FOCUS_LAST
static bool activeWindowChangeQueued(const QWindow *window)
static QWindow * childWindowAt(QWindow *win, const QPoint &p)
QList< xcb_rectangle_t > qRegionToXcbRectangleList(const QRegion &region)
QWidget * win
Definition settings.cpp:6
QFuture< QSet< QChar > > set
[10]
QByteArray ba
[0]
std::array< QModelRoleData, 3 > roleData
[13]
obj metaObject() -> className()
QString title
[35]
widget render & pixmap
aWidget window() -> setWindowTitle("New Window Title")
[2]
QNetworkReply * reply
QJSValue global
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:955
bool contains(const AT &t) const noexcept
Definition qlist.h:44
\inmodule QtCore
quint32 decorations
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent