Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbwmsupport.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include "qxcbwmsupport.h" | - | ||||||||||||
35 | #include "qxcbscreen.h" | - | ||||||||||||
36 | - | |||||||||||||
37 | #include <qdebug.h> | - | ||||||||||||
38 | - | |||||||||||||
39 | QT_BEGIN_NAMESPACE | - | ||||||||||||
40 | - | |||||||||||||
41 | QXcbWMSupport::QXcbWMSupport(QXcbConnection *c) | - | ||||||||||||
42 | : QXcbObject(c) | - | ||||||||||||
43 | { | - | ||||||||||||
44 | updateNetWMAtoms(); | - | ||||||||||||
45 | updateVirtualRoots(); | - | ||||||||||||
46 | } executed 129 times by 5 tests: end of block Executed by:
| 129 | ||||||||||||
47 | - | |||||||||||||
48 | bool QXcbWMSupport::isSupportedByWM(xcb_atom_t atom) const | - | ||||||||||||
49 | { | - | ||||||||||||
50 | return net_wm_atoms.contains(atom); executed 9295 times by 109 tests: return net_wm_atoms.contains(atom); Executed by:
| 9295 | ||||||||||||
51 | } | - | ||||||||||||
52 | - | |||||||||||||
53 | - | |||||||||||||
54 | - | |||||||||||||
55 | void QXcbWMSupport::updateNetWMAtoms() | - | ||||||||||||
56 | { | - | ||||||||||||
57 | net_wm_atoms.clear(); | - | ||||||||||||
58 | - | |||||||||||||
59 | xcb_window_t root = connection()->primaryScreen()->root(); | - | ||||||||||||
60 | int offset = 0; | - | ||||||||||||
61 | int remaining = 0; | - | ||||||||||||
62 | do { | - | ||||||||||||
63 | xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024); | - | ||||||||||||
64 | xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||
65 | if (!reply)
| 0-129 | ||||||||||||
66 | break; never executed: break; | 0 | ||||||||||||
67 | - | |||||||||||||
68 | remaining = 0; | - | ||||||||||||
69 | - | |||||||||||||
70 | if (reply->type == XCB_ATOM_ATOM && reply->format == 32) {
| 0-129 | ||||||||||||
71 | int len = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t); | - | ||||||||||||
72 | xcb_atom_t *atoms = (xcb_atom_t *)xcb_get_property_value(reply); | - | ||||||||||||
73 | int s = net_wm_atoms.size(); | - | ||||||||||||
74 | net_wm_atoms.resize(s + len); | - | ||||||||||||
75 | memcpy(net_wm_atoms.data() + s, atoms, len*sizeof(xcb_atom_t)); | - | ||||||||||||
76 | - | |||||||||||||
77 | remaining = reply->bytes_after; | - | ||||||||||||
78 | offset += len; | - | ||||||||||||
79 | } executed 129 times by 5 tests: end of block Executed by:
| 129 | ||||||||||||
80 | - | |||||||||||||
81 | free(reply); | - | ||||||||||||
82 | } while (remaining > 0); executed 129 times by 5 tests: end of block Executed by:
| 0-129 | ||||||||||||
83 | } executed 129 times by 5 tests: end of block Executed by:
| 129 | ||||||||||||
84 | - | |||||||||||||
85 | // update the virtual roots array | - | ||||||||||||
86 | void QXcbWMSupport::updateVirtualRoots() | - | ||||||||||||
87 | { | - | ||||||||||||
88 | net_virtual_roots.clear(); | - | ||||||||||||
89 | - | |||||||||||||
90 | if (!isSupportedByWM(atom(QXcbAtom::_NET_VIRTUAL_ROOTS)))
| 0-129 | ||||||||||||
91 | return; executed 129 times by 5 tests: return; Executed by:
| 129 | ||||||||||||
92 | - | |||||||||||||
93 | xcb_window_t root = connection()->primaryScreen()->root(); | - | ||||||||||||
94 | int offset = 0; | - | ||||||||||||
95 | int remaining = 0; | - | ||||||||||||
96 | do { | - | ||||||||||||
97 | xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_VIRTUAL_ROOTS), XCB_ATOM_WINDOW, offset, 1024); | - | ||||||||||||
98 | xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, NULL); | - | ||||||||||||
99 | if (!reply)
| 0 | ||||||||||||
100 | break; never executed: break; | 0 | ||||||||||||
101 | - | |||||||||||||
102 | remaining = 0; | - | ||||||||||||
103 | - | |||||||||||||
104 | if (reply->type == XCB_ATOM_WINDOW && reply->format == 32) {
| 0 | ||||||||||||
105 | int len = xcb_get_property_value_length(reply)/sizeof(xcb_window_t); | - | ||||||||||||
106 | xcb_window_t *roots = (xcb_window_t *)xcb_get_property_value(reply); | - | ||||||||||||
107 | int s = net_virtual_roots.size(); | - | ||||||||||||
108 | net_virtual_roots.resize(s + len); | - | ||||||||||||
109 | memcpy(net_virtual_roots.data() + s, roots, len*sizeof(xcb_window_t)); | - | ||||||||||||
110 | - | |||||||||||||
111 | remaining = reply->bytes_after; | - | ||||||||||||
112 | offset += len; | - | ||||||||||||
113 | } never executed: end of block | 0 | ||||||||||||
114 | - | |||||||||||||
115 | free(reply); | - | ||||||||||||
116 | } while (remaining > 0); never executed: end of block
| 0 | ||||||||||||
117 | - | |||||||||||||
118 | #ifdef Q_XCB_DEBUG | - | ||||||||||||
119 | qDebug() << "======== updateVirtualRoots"; | - | ||||||||||||
120 | for (int i = 0; i < net_virtual_roots.size(); ++i) | - | ||||||||||||
121 | qDebug() << connection()->atomName(net_virtual_roots.at(i)); | - | ||||||||||||
122 | qDebug() << "======== updateVirtualRoots"; | - | ||||||||||||
123 | #endif | - | ||||||||||||
124 | } never executed: end of block | 0 | ||||||||||||
125 | - | |||||||||||||
126 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |