Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qxcbwmsupport.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// Qt-Security score:significant reason:default
4
6#include "qxcbscreen.h"
7
8#include <qdebug.h>
9
11
13 : QXcbObject(c)
14{
15 updateNetWMAtoms();
16 updateVirtualRoots();
17}
18
19bool QXcbWMSupport::isSupportedByWM(xcb_atom_t atom) const
20{
21 return net_wm_atoms.contains(atom);
22}
23
24
25
26void QXcbWMSupport::updateNetWMAtoms()
27{
28 net_wm_atoms.clear();
29
30 xcb_window_t root = connection()->primaryScreen()->root();
31 int offset = 0;
32 int remaining = 0;
33 do {
34 auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(), false, root, atom(QXcbAtom::Atom_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024);
35 if (!reply)
36 break;
37
38 remaining = 0;
39
40 if (reply->type == XCB_ATOM_ATOM && reply->format == 32) {
41 int len = xcb_get_property_value_length(reply.get())/sizeof(xcb_atom_t);
42 xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply.get());
43 int s = net_wm_atoms.size();
44 net_wm_atoms.resize(s + len);
45 memcpy(net_wm_atoms.data() + s, atoms, len*sizeof(xcb_atom_t));
46
47 remaining = reply->bytes_after;
48 offset += len;
49 }
50 } while (remaining > 0);
51}
52
53// update the virtual roots array
54void QXcbWMSupport::updateVirtualRoots()
55{
56 net_virtual_roots.clear();
57
59 return;
60
61 xcb_window_t root = connection()->primaryScreen()->root();
62 int offset = 0;
63 int remaining = 0;
64 do {
65 auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
66 false, root, atom(QXcbAtom::Atom_NET_VIRTUAL_ROOTS), XCB_ATOM_WINDOW, offset, 1024);
67 if (!reply)
68 break;
69
70 remaining = 0;
71
72 if (reply->type == XCB_ATOM_WINDOW && reply->format == 32) {
73 int len = xcb_get_property_value_length(reply.get())/sizeof(xcb_window_t);
74 xcb_window_t *roots = (xcb_window_t *)xcb_get_property_value(reply.get());
75 int s = net_virtual_roots.size();
76 net_virtual_roots.resize(s + len);
77 memcpy(net_virtual_roots.data() + s, roots, len*sizeof(xcb_window_t));
78
79 remaining = reply->bytes_after;
80 offset += len;
81 }
82
83 } while (remaining > 0);
84
85//#define VIRTUAL_ROOTS_DEBUG
86#ifdef VIRTUAL_ROOTS_DEBUG
87 qDebug("======== updateVirtualRoots");
88 for (int i = 0; i < net_virtual_roots.size(); ++i)
89 qDebug() << connection()->atomName(net_virtual_roots.at(i));
90 qDebug("======== updateVirtualRoots");
91#endif
92}
93
94QT_END_NAMESPACE
@ Atom_NET_VIRTUAL_ROOTS
Definition qxcbatom.h:70
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
bool isSupportedByWM(xcb_atom_t atom) const
#define Q_XCB_REPLY(call,...)