Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/xcb/qxcbcursor.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
24 | ** | - | ||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
35 | ** | - | ||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||
37 | ** | - | ||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||
39 | - | |||||||||||||
40 | #include "qxcbcursor.h" | - | ||||||||||||
41 | #include "qxcbconnection.h" | - | ||||||||||||
42 | #include "qxcbwindow.h" | - | ||||||||||||
43 | #include "qxcbimage.h" | - | ||||||||||||
44 | #include "qxcbxsettings.h" | - | ||||||||||||
45 | - | |||||||||||||
46 | #include <QtCore/QLibrary> | - | ||||||||||||
47 | #include <QtGui/QWindow> | - | ||||||||||||
48 | #include <QtGui/QBitmap> | - | ||||||||||||
49 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||
50 | #include <X11/cursorfont.h> | - | ||||||||||||
51 | #include <xcb/xfixes.h> | - | ||||||||||||
52 | #include <xcb/xcb_image.h> | - | ||||||||||||
53 | - | |||||||||||||
54 | QT_BEGIN_NAMESPACE | - | ||||||||||||
55 | - | |||||||||||||
56 | typedef int (*PtrXcursorLibraryLoadCursor)(void *, const char *); | - | ||||||||||||
57 | typedef char *(*PtrXcursorLibraryGetTheme)(void *); | - | ||||||||||||
58 | typedef int (*PtrXcursorLibrarySetTheme)(void *, const char *); | - | ||||||||||||
59 | typedef int (*PtrXcursorLibraryGetDefaultSize)(void *); | - | ||||||||||||
60 | - | |||||||||||||
61 | #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) | - | ||||||||||||
62 | #include <X11/Xlib.h> | - | ||||||||||||
63 | enum { | - | ||||||||||||
64 | XCursorShape = CursorShape | - | ||||||||||||
65 | }; | - | ||||||||||||
66 | #undef CursorShape | - | ||||||||||||
67 | - | |||||||||||||
68 | static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = 0; | - | ||||||||||||
69 | static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = 0; | - | ||||||||||||
70 | static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = 0; | - | ||||||||||||
71 | static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = 0; | - | ||||||||||||
72 | #endif | - | ||||||||||||
73 | - | |||||||||||||
74 | static xcb_font_t cursorFont = 0; | - | ||||||||||||
75 | static int cursorCount = 0; | - | ||||||||||||
76 | - | |||||||||||||
77 | static uint8_t cur_blank_bits[] = { | - | ||||||||||||
78 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
81 | - | |||||||||||||
82 | static const uint8_t cur_ver_bits[] = { | - | ||||||||||||
83 | 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, | - | ||||||||||||
84 | 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, | - | ||||||||||||
85 | 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; | - | ||||||||||||
86 | static const uint8_t mcur_ver_bits[] = { | - | ||||||||||||
87 | 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, | - | ||||||||||||
88 | 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, | - | ||||||||||||
89 | 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; | - | ||||||||||||
90 | static const uint8_t cur_hor_bits[] = { | - | ||||||||||||
91 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, | - | ||||||||||||
92 | 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, | - | ||||||||||||
93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
94 | static const uint8_t mcur_hor_bits[] = { | - | ||||||||||||
95 | 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, | - | ||||||||||||
96 | 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, | - | ||||||||||||
97 | 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; | - | ||||||||||||
98 | static const uint8_t cur_bdiag_bits[] = { | - | ||||||||||||
99 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, | - | ||||||||||||
100 | 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, | - | ||||||||||||
101 | 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
102 | static const uint8_t mcur_bdiag_bits[] = { | - | ||||||||||||
103 | 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, | - | ||||||||||||
104 | 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, | - | ||||||||||||
105 | 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
106 | static const uint8_t cur_fdiag_bits[] = { | - | ||||||||||||
107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, | - | ||||||||||||
108 | 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, | - | ||||||||||||
109 | 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
110 | static const uint8_t mcur_fdiag_bits[] = { | - | ||||||||||||
111 | 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, | - | ||||||||||||
112 | 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, | - | ||||||||||||
113 | 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; | - | ||||||||||||
114 | static const uint8_t *cursor_bits16[] = { | - | ||||||||||||
115 | cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, | - | ||||||||||||
116 | cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, | - | ||||||||||||
117 | 0, 0, cur_blank_bits, cur_blank_bits }; | - | ||||||||||||
118 | - | |||||||||||||
119 | static const uint8_t vsplit_bits[] = { | - | ||||||||||||
120 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
122 | 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, | - | ||||||||||||
123 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, | - | ||||||||||||
124 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, | - | ||||||||||||
125 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, | - | ||||||||||||
126 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, | - | ||||||||||||
127 | 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, | - | ||||||||||||
128 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
129 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
130 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
131 | static const uint8_t vsplitm_bits[] = { | - | ||||||||||||
132 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
133 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, | - | ||||||||||||
134 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, | - | ||||||||||||
135 | 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, | - | ||||||||||||
136 | 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, | - | ||||||||||||
137 | 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, | - | ||||||||||||
138 | 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, | - | ||||||||||||
139 | 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, | - | ||||||||||||
140 | 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, | - | ||||||||||||
141 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
142 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
143 | static const uint8_t hsplit_bits[] = { | - | ||||||||||||
144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
145 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
146 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, | - | ||||||||||||
147 | 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, | - | ||||||||||||
148 | 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, | - | ||||||||||||
149 | 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, | - | ||||||||||||
150 | 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, | - | ||||||||||||
151 | 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
152 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
153 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
154 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
155 | static const uint8_t hsplitm_bits[] = { | - | ||||||||||||
156 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
157 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
158 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, | - | ||||||||||||
159 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, | - | ||||||||||||
160 | 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, | - | ||||||||||||
161 | 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, | - | ||||||||||||
162 | 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, | - | ||||||||||||
163 | 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
164 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
165 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
166 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | - | ||||||||||||
167 | static const uint8_t whatsthis_bits[] = { | - | ||||||||||||
168 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, | - | ||||||||||||
169 | 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, | - | ||||||||||||
170 | 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00, | - | ||||||||||||
171 | 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00, | - | ||||||||||||
172 | 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00, | - | ||||||||||||
173 | 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00, | - | ||||||||||||
174 | 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
175 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
176 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
177 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
178 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; | - | ||||||||||||
179 | static const uint8_t whatsthism_bits[] = { | - | ||||||||||||
180 | 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, | - | ||||||||||||
181 | 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, | - | ||||||||||||
182 | 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00, | - | ||||||||||||
183 | 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00, | - | ||||||||||||
184 | 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00, | - | ||||||||||||
185 | 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, | - | ||||||||||||
186 | 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
187 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
188 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
189 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
190 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; | - | ||||||||||||
191 | static const uint8_t busy_bits[] = { | - | ||||||||||||
192 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, | - | ||||||||||||
193 | 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, | - | ||||||||||||
194 | 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00, | - | ||||||||||||
195 | 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00, | - | ||||||||||||
196 | 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00, | - | ||||||||||||
197 | 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00, | - | ||||||||||||
198 | 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00, | - | ||||||||||||
199 | 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
200 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
201 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
202 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | - | ||||||||||||
203 | static const uint8_t busym_bits[] = { | - | ||||||||||||
204 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | - | ||||||||||||
205 | 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, | - | ||||||||||||
206 | 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00, | - | ||||||||||||
207 | 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00, | - | ||||||||||||
208 | 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00, | - | ||||||||||||
209 | 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00, | - | ||||||||||||
210 | 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00, | - | ||||||||||||
211 | 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
212 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
213 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | - | ||||||||||||
214 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | - | ||||||||||||
215 | - | |||||||||||||
216 | static const uint8_t * const cursor_bits32[] = { | - | ||||||||||||
217 | vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, | - | ||||||||||||
218 | 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits | - | ||||||||||||
219 | }; | - | ||||||||||||
220 | - | |||||||||||||
221 | static const uint8_t forbidden_bits[] = { | - | ||||||||||||
222 | 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, | - | ||||||||||||
223 | 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, | - | ||||||||||||
224 | 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03, | - | ||||||||||||
225 | 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; | - | ||||||||||||
226 | - | |||||||||||||
227 | static const uint8_t forbiddenm_bits[] = { | - | ||||||||||||
228 | 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, | - | ||||||||||||
229 | 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, | - | ||||||||||||
230 | 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07, | - | ||||||||||||
231 | 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; | - | ||||||||||||
232 | - | |||||||||||||
233 | static const uint8_t openhand_bits[] = { | - | ||||||||||||
234 | 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, | - | ||||||||||||
235 | 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, | - | ||||||||||||
236 | 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; | - | ||||||||||||
237 | static const uint8_t openhandm_bits[] = { | - | ||||||||||||
238 | 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, | - | ||||||||||||
239 | 0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, | - | ||||||||||||
240 | 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; | - | ||||||||||||
241 | static const uint8_t closedhand_bits[] = { | - | ||||||||||||
242 | 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, | - | ||||||||||||
243 | 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, | - | ||||||||||||
244 | 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; | - | ||||||||||||
245 | static const uint8_t closedhandm_bits[] = { | - | ||||||||||||
246 | 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, | - | ||||||||||||
247 | 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, | - | ||||||||||||
248 | 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; | - | ||||||||||||
249 | - | |||||||||||||
250 | static const uint8_t * const cursor_bits20[] = { | - | ||||||||||||
251 | forbidden_bits, forbiddenm_bits | - | ||||||||||||
252 | }; | - | ||||||||||||
253 | - | |||||||||||||
254 | static const char * const cursorNames[] = { | - | ||||||||||||
255 | "left_ptr", | - | ||||||||||||
256 | "up_arrow", | - | ||||||||||||
257 | "cross", | - | ||||||||||||
258 | "wait", | - | ||||||||||||
259 | "ibeam", | - | ||||||||||||
260 | "size_ver", | - | ||||||||||||
261 | "size_hor", | - | ||||||||||||
262 | "size_bdiag", | - | ||||||||||||
263 | "size_fdiag", | - | ||||||||||||
264 | "size_all", | - | ||||||||||||
265 | "blank", | - | ||||||||||||
266 | "split_v", | - | ||||||||||||
267 | "split_h", | - | ||||||||||||
268 | "pointing_hand", | - | ||||||||||||
269 | "forbidden", | - | ||||||||||||
270 | "whats_this", | - | ||||||||||||
271 | "left_ptr_watch", | - | ||||||||||||
272 | "openhand", | - | ||||||||||||
273 | "closedhand", | - | ||||||||||||
274 | "copy", | - | ||||||||||||
275 | "move", | - | ||||||||||||
276 | "link" | - | ||||||||||||
277 | }; | - | ||||||||||||
278 | - | |||||||||||||
279 | #ifndef QT_NO_CURSOR | - | ||||||||||||
280 | - | |||||||||||||
281 | QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c) | - | ||||||||||||
282 | : shape(c.shape()), bitmapCacheKey(0), maskCacheKey(0) | - | ||||||||||||
283 | { | - | ||||||||||||
284 | if (shape == Qt::BitmapCursor) { | - | ||||||||||||
285 | const qint64 pixmapCacheKey = c.pixmap().cacheKey(); | - | ||||||||||||
286 | if (pixmapCacheKey) { | - | ||||||||||||
287 | bitmapCacheKey = pixmapCacheKey; | - | ||||||||||||
288 | } else { | - | ||||||||||||
289 | Q_ASSERT(c.bitmap()); | - | ||||||||||||
290 | Q_ASSERT(c.mask()); | - | ||||||||||||
291 | bitmapCacheKey = c.bitmap()->cacheKey(); | - | ||||||||||||
292 | maskCacheKey = c.mask()->cacheKey(); | - | ||||||||||||
293 | } | - | ||||||||||||
294 | } | - | ||||||||||||
295 | } | - | ||||||||||||
296 | - | |||||||||||||
297 | #endif // !QT_NO_CURSOR | - | ||||||||||||
298 | - | |||||||||||||
299 | QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen) | - | ||||||||||||
300 | : QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false) | - | ||||||||||||
301 | { | - | ||||||||||||
302 | if (cursorCount++) | - | ||||||||||||
303 | return; | - | ||||||||||||
304 | - | |||||||||||||
305 | cursorFont = xcb_generate_id(xcb_connection()); | - | ||||||||||||
306 | const char *cursorStr = "cursor"; | - | ||||||||||||
307 | xcb_open_font(xcb_connection(), cursorFont, strlen(cursorStr), cursorStr); | - | ||||||||||||
308 | - | |||||||||||||
309 | #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) | - | ||||||||||||
310 | static bool function_ptrs_not_initialized = true; | - | ||||||||||||
311 | if (function_ptrs_not_initialized) { | - | ||||||||||||
312 | QLibrary xcursorLib(QLatin1String("Xcursor"), 1); | - | ||||||||||||
313 | bool xcursorFound = xcursorLib.load(); | - | ||||||||||||
314 | if (!xcursorFound) { // try without the version number | - | ||||||||||||
315 | xcursorLib.setFileName(QLatin1String("Xcursor")); | - | ||||||||||||
316 | xcursorFound = xcursorLib.load(); | - | ||||||||||||
317 | } | - | ||||||||||||
318 | if (xcursorFound) { | - | ||||||||||||
319 | ptrXcursorLibraryLoadCursor = | - | ||||||||||||
320 | (PtrXcursorLibraryLoadCursor) xcursorLib.resolve("XcursorLibraryLoadCursor"); | - | ||||||||||||
321 | ptrXcursorLibraryGetTheme = | - | ||||||||||||
322 | (PtrXcursorLibraryGetTheme) xcursorLib.resolve("XcursorGetTheme"); | - | ||||||||||||
323 | ptrXcursorLibrarySetTheme = | - | ||||||||||||
324 | (PtrXcursorLibrarySetTheme) xcursorLib.resolve("XcursorSetTheme"); | - | ||||||||||||
325 | ptrXcursorLibraryGetDefaultSize = | - | ||||||||||||
326 | (PtrXcursorLibraryGetDefaultSize) xcursorLib.resolve("XcursorGetDefaultSize"); | - | ||||||||||||
327 | } | - | ||||||||||||
328 | function_ptrs_not_initialized = false; | - | ||||||||||||
329 | } | - | ||||||||||||
330 | - | |||||||||||||
331 | #endif | - | ||||||||||||
332 | } | - | ||||||||||||
333 | - | |||||||||||||
334 | QXcbCursor::~QXcbCursor() | - | ||||||||||||
335 | { | - | ||||||||||||
336 | xcb_connection_t *conn = xcb_connection(); | - | ||||||||||||
337 | - | |||||||||||||
338 | if (m_gtkCursorThemeInitialized) {
| 19-328 | ||||||||||||
339 | m_screen->xSettings()->removeCallbackForHandle(this); | - | ||||||||||||
340 | } executed 19 times by 19 tests: end of block Executed by:
| 19 | ||||||||||||
341 | - | |||||||||||||
342 | if (!--cursorCount)
| 0-347 | ||||||||||||
343 | xcb_close_font(conn, cursorFont); executed 347 times by 219 tests: xcb_close_font(conn, cursorFont); Executed by:
| 347 | ||||||||||||
344 | - | |||||||||||||
345 | #ifndef QT_NO_CURSOR | - | ||||||||||||
346 | foreachfor (xcb_cursor_t cursor ,: qAsConst(m_cursorHash))) | - | ||||||||||||
347 | xcb_free_cursor(conn, cursor); executed 164 times by 114 tests: xcb_free_cursor(conn, cursor); Executed by:
| 164 | ||||||||||||
348 | #endif | - | ||||||||||||
349 | } executed 347 times by 219 tests: end of block Executed by:
| 347 | ||||||||||||
350 | - | |||||||||||||
351 | #ifndef QT_NO_CURSOR | - | ||||||||||||
352 | void QXcbCursor::changeCursor(QCursor *cursor, QWindow *widget) | - | ||||||||||||
353 | { | - | ||||||||||||
354 | QXcbWindow *w = 0; | - | ||||||||||||
355 | if (widget && widget->handle()) | - | ||||||||||||
356 | w = static_cast<QXcbWindow *>(widget->handle()); | - | ||||||||||||
357 | else | - | ||||||||||||
358 | // No X11 cursor control when there is no widget under the cursor | - | ||||||||||||
359 | return; | - | ||||||||||||
360 | - | |||||||||||||
361 | xcb_cursor_t c = XCB_CURSOR_NONE; | - | ||||||||||||
362 | bool isBitmapCursor = false; | - | ||||||||||||
363 | - | |||||||||||||
364 | if (cursor) { | - | ||||||||||||
365 | const Qt::CursorShape shape = cursor->shape(); | - | ||||||||||||
366 | isBitmapCursor = shape == Qt::BitmapCursor; | - | ||||||||||||
367 | - | |||||||||||||
368 | if (!isBitmapCursor) { | - | ||||||||||||
369 | const QXcbCursorCacheKey key(*cursor); | - | ||||||||||||
370 | CursorHash::iterator it = m_cursorHash.find(key); | - | ||||||||||||
371 | if (it == m_cursorHash.end()) { | - | ||||||||||||
372 | it = m_cursorHash.insert(key, createFontCursor(shape)); | - | ||||||||||||
373 | } | - | ||||||||||||
374 | c = it.value(); | - | ||||||||||||
375 | } else { | - | ||||||||||||
376 | // Do not cache bitmap cursors, as otherwise they have unclear | - | ||||||||||||
377 | // lifetime (we effectively leak xcb_cursor_t). | - | ||||||||||||
378 | c = createBitmapCursor(cursor); | - | ||||||||||||
379 | } | - | ||||||||||||
380 | } | - | ||||||||||||
381 | - | |||||||||||||
382 | w->setCursor(c, isBitmapCursor); | - | ||||||||||||
383 | } | - | ||||||||||||
384 | - | |||||||||||||
385 | static int cursorIdForShape(int cshape) | - | ||||||||||||
386 | { | - | ||||||||||||
387 | int cursorId = 0; | - | ||||||||||||
388 | switch (cshape) { | - | ||||||||||||
389 | case Qt::ArrowCursor: | - | ||||||||||||
390 | cursorId = XC_left_ptr; | - | ||||||||||||
391 | break; | - | ||||||||||||
392 | case Qt::UpArrowCursor: | - | ||||||||||||
393 | cursorId = XC_center_ptr; | - | ||||||||||||
394 | break; | - | ||||||||||||
395 | case Qt::CrossCursor: | - | ||||||||||||
396 | cursorId = XC_crosshair; | - | ||||||||||||
397 | break; | - | ||||||||||||
398 | case Qt::WaitCursor: | - | ||||||||||||
399 | cursorId = XC_watch; | - | ||||||||||||
400 | break; | - | ||||||||||||
401 | case Qt::IBeamCursor: | - | ||||||||||||
402 | cursorId = XC_xterm; | - | ||||||||||||
403 | break; | - | ||||||||||||
404 | case Qt::SizeAllCursor: | - | ||||||||||||
405 | cursorId = XC_fleur; | - | ||||||||||||
406 | break; | - | ||||||||||||
407 | case Qt::PointingHandCursor: | - | ||||||||||||
408 | cursorId = XC_hand2; | - | ||||||||||||
409 | break; | - | ||||||||||||
410 | case Qt::SizeBDiagCursor: | - | ||||||||||||
411 | cursorId = XC_top_right_corner; | - | ||||||||||||
412 | break; | - | ||||||||||||
413 | case Qt::SizeFDiagCursor: | - | ||||||||||||
414 | cursorId = XC_bottom_right_corner; | - | ||||||||||||
415 | break; | - | ||||||||||||
416 | case Qt::SizeVerCursor: | - | ||||||||||||
417 | case Qt::SplitVCursor: | - | ||||||||||||
418 | cursorId = XC_sb_v_double_arrow; | - | ||||||||||||
419 | break; | - | ||||||||||||
420 | case Qt::SizeHorCursor: | - | ||||||||||||
421 | case Qt::SplitHCursor: | - | ||||||||||||
422 | cursorId = XC_sb_h_double_arrow; | - | ||||||||||||
423 | break; | - | ||||||||||||
424 | case Qt::WhatsThisCursor: | - | ||||||||||||
425 | cursorId = XC_question_arrow; | - | ||||||||||||
426 | break; | - | ||||||||||||
427 | case Qt::ForbiddenCursor: | - | ||||||||||||
428 | cursorId = XC_circle; | - | ||||||||||||
429 | break; | - | ||||||||||||
430 | case Qt::BusyCursor: | - | ||||||||||||
431 | cursorId = XC_watch; | - | ||||||||||||
432 | break; | - | ||||||||||||
433 | default: | - | ||||||||||||
434 | break; | - | ||||||||||||
435 | } | - | ||||||||||||
436 | return cursorId; | - | ||||||||||||
437 | } | - | ||||||||||||
438 | - | |||||||||||||
439 | xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) | - | ||||||||||||
440 | { | - | ||||||||||||
441 | xcb_cursor_t cursor = 0; | - | ||||||||||||
442 | xcb_connection_t *conn = xcb_connection(); | - | ||||||||||||
443 | - | |||||||||||||
444 | if (cshape == Qt::BlankCursor) { | - | ||||||||||||
445 | xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16, | - | ||||||||||||
446 | 1, 0, 0, 0); | - | ||||||||||||
447 | xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16, | - | ||||||||||||
448 | 1, 0, 0, 0); | - | ||||||||||||
449 | cursor = xcb_generate_id(conn); | - | ||||||||||||
450 | xcb_create_cursor(conn, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); | - | ||||||||||||
451 | } else if (cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor) { | - | ||||||||||||
452 | int i = (cshape - Qt::SizeVerCursor) * 2; | - | ||||||||||||
453 | xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
454 | const_cast<uint8_t*>(cursor_bits16[i]), | - | ||||||||||||
455 | 16, 16, 1, 0, 0, 0); | - | ||||||||||||
456 | xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
457 | const_cast<uint8_t*>(cursor_bits16[i + 1]), | - | ||||||||||||
458 | 16, 16, 1, 0, 0, 0); | - | ||||||||||||
459 | cursor = xcb_generate_id(conn); | - | ||||||||||||
460 | xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); | - | ||||||||||||
461 | } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor) | - | ||||||||||||
462 | || cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) { | - | ||||||||||||
463 | int i = (cshape - Qt::SplitVCursor) * 2; | - | ||||||||||||
464 | xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
465 | const_cast<uint8_t*>(cursor_bits32[i]), | - | ||||||||||||
466 | 32, 32, 1, 0, 0, 0); | - | ||||||||||||
467 | xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
468 | const_cast<uint8_t*>(cursor_bits32[i + 1]), | - | ||||||||||||
469 | 32, 32, 1, 0, 0, 0); | - | ||||||||||||
470 | int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor | - | ||||||||||||
471 | || cshape == Qt::BusyCursor) ? 0 : 16; | - | ||||||||||||
472 | cursor = xcb_generate_id(conn); | - | ||||||||||||
473 | xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, hs, hs); | - | ||||||||||||
474 | } else if (cshape == Qt::ForbiddenCursor) { | - | ||||||||||||
475 | int i = (cshape - Qt::ForbiddenCursor) * 2; | - | ||||||||||||
476 | xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
477 | const_cast<uint8_t*>(cursor_bits20[i]), | - | ||||||||||||
478 | 20, 20, 1, 0, 0, 0); | - | ||||||||||||
479 | xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
480 | const_cast<uint8_t*>(cursor_bits20[i + 1]), | - | ||||||||||||
481 | 20, 20, 1, 0, 0, 0); | - | ||||||||||||
482 | cursor = xcb_generate_id(conn); | - | ||||||||||||
483 | xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 10, 10); | - | ||||||||||||
484 | } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) { | - | ||||||||||||
485 | bool open = cshape == Qt::OpenHandCursor; | - | ||||||||||||
486 | xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
487 | const_cast<uint8_t*>(open ? openhand_bits : closedhand_bits), | - | ||||||||||||
488 | 16, 16, 1, 0, 0, 0); | - | ||||||||||||
489 | xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), | - | ||||||||||||
490 | const_cast<uint8_t*>(open ? openhandm_bits : closedhandm_bits), | - | ||||||||||||
491 | 16, 16, 1, 0, 0, 0); | - | ||||||||||||
492 | cursor = xcb_generate_id(conn); | - | ||||||||||||
493 | xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); | - | ||||||||||||
494 | } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor | - | ||||||||||||
495 | || cshape == Qt::DragLinkCursor) { | - | ||||||||||||
496 | QImage image = QGuiApplicationPrivate::instance()->getPixmapCursor(static_cast<Qt::CursorShape>(cshape)).toImage(); | - | ||||||||||||
497 | if (!image.isNull()) { | - | ||||||||||||
498 | xcb_pixmap_t pm = qt_xcb_XPixmapFromBitmap(m_screen, image); | - | ||||||||||||
499 | xcb_pixmap_t pmm = qt_xcb_XPixmapFromBitmap(m_screen, image.createAlphaMask()); | - | ||||||||||||
500 | cursor = xcb_generate_id(conn); | - | ||||||||||||
501 | xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); | - | ||||||||||||
502 | xcb_free_pixmap(conn, pm); | - | ||||||||||||
503 | xcb_free_pixmap(conn, pmm); | - | ||||||||||||
504 | } | - | ||||||||||||
505 | } | - | ||||||||||||
506 | - | |||||||||||||
507 | return cursor; | - | ||||||||||||
508 | } | - | ||||||||||||
509 | - | |||||||||||||
510 | #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) | - | ||||||||||||
511 | bool updateCursorTheme(void *dpy, const QByteArray &theme) { | - | ||||||||||||
512 | if (!ptrXcursorLibraryGetTheme | - | ||||||||||||
513 | || !ptrXcursorLibrarySetTheme) | - | ||||||||||||
514 | return false; | - | ||||||||||||
515 | QByteArray oldTheme = ptrXcursorLibraryGetTheme(dpy); | - | ||||||||||||
516 | if (oldTheme == theme) | - | ||||||||||||
517 | return false; | - | ||||||||||||
518 | - | |||||||||||||
519 | int setTheme = ptrXcursorLibrarySetTheme(dpy,theme.constData()); | - | ||||||||||||
520 | return setTheme; | - | ||||||||||||
521 | } | - | ||||||||||||
522 | - | |||||||||||||
523 | void QXcbCursor::cursorThemePropertyChanged(QXcbVirtualDesktop *screen, const QByteArray &name, const QVariant &property, void *handle) | - | ||||||||||||
524 | { | - | ||||||||||||
525 | Q_UNUSED(screen); | - | ||||||||||||
526 | Q_UNUSED(name); | - | ||||||||||||
527 | QXcbCursor *self = static_cast<QXcbCursor *>(handle); | - | ||||||||||||
528 | updateCursorTheme(self->connection()->xlib_display(),property.toByteArray()); | - | ||||||||||||
529 | } | - | ||||||||||||
530 | - | |||||||||||||
531 | static xcb_cursor_t loadCursor(void *dpy, int cshape) | - | ||||||||||||
532 | { | - | ||||||||||||
533 | xcb_cursor_t cursor = XCB_NONE; | - | ||||||||||||
534 | if (!ptrXcursorLibraryLoadCursor || !dpy) | - | ||||||||||||
535 | return cursor; | - | ||||||||||||
536 | switch (cshape) { | - | ||||||||||||
537 | case Qt::DragCopyCursor: | - | ||||||||||||
538 | cursor = ptrXcursorLibraryLoadCursor(dpy, "dnd-copy"); | - | ||||||||||||
539 | break; | - | ||||||||||||
540 | case Qt::DragMoveCursor: | - | ||||||||||||
541 | cursor = ptrXcursorLibraryLoadCursor(dpy, "dnd-move"); | - | ||||||||||||
542 | break; | - | ||||||||||||
543 | case Qt::DragLinkCursor: | - | ||||||||||||
544 | cursor = ptrXcursorLibraryLoadCursor(dpy, "dnd-link"); | - | ||||||||||||
545 | break; | - | ||||||||||||
546 | default: | - | ||||||||||||
547 | break; | - | ||||||||||||
548 | } | - | ||||||||||||
549 | if (!cursor) { | - | ||||||||||||
550 | cursor = ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]); | - | ||||||||||||
551 | } | - | ||||||||||||
552 | return cursor; | - | ||||||||||||
553 | } | - | ||||||||||||
554 | #endif //XCB_USE_XLIB / QT_NO_LIBRARY | - | ||||||||||||
555 | - | |||||||||||||
556 | xcb_cursor_t QXcbCursor::createFontCursor(int cshape) | - | ||||||||||||
557 | { | - | ||||||||||||
558 | xcb_connection_t *conn = xcb_connection(); | - | ||||||||||||
559 | int cursorId = cursorIdForShape(cshape); | - | ||||||||||||
560 | xcb_cursor_t cursor = XCB_NONE; | - | ||||||||||||
561 | - | |||||||||||||
562 | // Try Xcursor first | - | ||||||||||||
563 | #if defined(XCB_USE_XLIB) && !defined(QT_NO_LIBRARY) | - | ||||||||||||
564 | if (cshape >= 0 && cshape <= Qt::LastCursor) { | - | ||||||||||||
565 | void *dpy = connection()->xlib_display(); | - | ||||||||||||
566 | // special case for non-standard dnd-* cursors | - | ||||||||||||
567 | cursor = loadCursor(dpy, cshape); | - | ||||||||||||
568 | if (!cursor && !m_gtkCursorThemeInitialized && m_screen->xSettings()->initialized()) { | - | ||||||||||||
569 | QByteArray gtkCursorTheme = m_screen->xSettings()->setting("Gtk/CursorThemeName").toByteArray(); | - | ||||||||||||
570 | m_screen->xSettings()->registerCallbackForProperty("Gtk/CursorThemeName",cursorThemePropertyChanged,this); | - | ||||||||||||
571 | if (updateCursorTheme(dpy,gtkCursorTheme)) { | - | ||||||||||||
572 | cursor = loadCursor(dpy, cshape); | - | ||||||||||||
573 | } | - | ||||||||||||
574 | m_gtkCursorThemeInitialized = true; | - | ||||||||||||
575 | } | - | ||||||||||||
576 | } | - | ||||||||||||
577 | if (cursor) | - | ||||||||||||
578 | return cursor; | - | ||||||||||||
579 | if (!cursor && cursorId) { | - | ||||||||||||
580 | cursor = XCreateFontCursor(DISPLAY_FROM_XCB(this), cursorId); | - | ||||||||||||
581 | if (cursor) | - | ||||||||||||
582 | return cursor; | - | ||||||||||||
583 | } | - | ||||||||||||
584 | - | |||||||||||||
585 | #endif | - | ||||||||||||
586 | - | |||||||||||||
587 | // Non-standard X11 cursors are created from bitmaps | - | ||||||||||||
588 | cursor = createNonStandardCursor(cshape); | - | ||||||||||||
589 | - | |||||||||||||
590 | // Create a glpyh cursor if everything else failed | - | ||||||||||||
591 | if (!cursor && cursorId) { | - | ||||||||||||
592 | cursor = xcb_generate_id(conn); | - | ||||||||||||
593 | xcb_create_glyph_cursor(conn, cursor, cursorFont, cursorFont, | - | ||||||||||||
594 | cursorId, cursorId + 1, | - | ||||||||||||
595 | 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0); | - | ||||||||||||
596 | } | - | ||||||||||||
597 | - | |||||||||||||
598 | if (cursor && cshape >= 0 && cshape < Qt::LastCursor && connection()->hasXFixes()) { | - | ||||||||||||
599 | const char *name = cursorNames[cshape]; | - | ||||||||||||
600 | xcb_xfixes_set_cursor_name(conn, cursor, strlen(name), name); | - | ||||||||||||
601 | } | - | ||||||||||||
602 | - | |||||||||||||
603 | return cursor; | - | ||||||||||||
604 | } | - | ||||||||||||
605 | - | |||||||||||||
606 | xcb_cursor_t QXcbCursor::createBitmapCursor(QCursor *cursor) | - | ||||||||||||
607 | { | - | ||||||||||||
608 | xcb_connection_t *conn = xcb_connection(); | - | ||||||||||||
609 | QPoint spot = cursor->hotSpot(); | - | ||||||||||||
610 | xcb_cursor_t c = XCB_NONE; | - | ||||||||||||
611 | if (cursor->pixmap().depth() > 1) | - | ||||||||||||
612 | c = qt_xcb_createCursorXRender(m_screen, cursor->pixmap().toImage(), spot); | - | ||||||||||||
613 | if (!c) { | - | ||||||||||||
614 | xcb_pixmap_t cp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->bitmap()->toImage()); | - | ||||||||||||
615 | xcb_pixmap_t mp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->mask()->toImage()); | - | ||||||||||||
616 | c = xcb_generate_id(conn); | - | ||||||||||||
617 | xcb_create_cursor(conn, c, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, | - | ||||||||||||
618 | spot.x(), spot.y()); | - | ||||||||||||
619 | xcb_free_pixmap(conn, cp); | - | ||||||||||||
620 | xcb_free_pixmap(conn, mp); | - | ||||||||||||
621 | } | - | ||||||||||||
622 | return c; | - | ||||||||||||
623 | } | - | ||||||||||||
624 | #endif | - | ||||||||||||
625 | - | |||||||||||||
626 | void QXcbCursor::queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDesktop, QPoint *pos, int *keybMask) | - | ||||||||||||
627 | { | - | ||||||||||||
628 | if (pos)
| 722-15518 | ||||||||||||
629 | *pos = QPoint(); executed 15518 times by 80 tests: *pos = QPoint(); Executed by:
| 15518 | ||||||||||||
630 | - | |||||||||||||
631 | xcb_window_t root = c->primaryVirtualDesktop()->root(); | - | ||||||||||||
632 | xcb_query_pointer_cookie_t cookie = xcb_query_pointer(c->xcb_connection(), root); | - | ||||||||||||
633 | xcb_generic_error_t *err = 0; | - | ||||||||||||
634 | xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(c->xcb_connection(), cookie, &err); | - | ||||||||||||
635 | if (!err && reply) {
| 0-16240 | ||||||||||||
636 | if (virtualDesktop) {
| 722-15518 | ||||||||||||
637 | foreachconst auto virtualDesktops = c->virtualDesktops(); | - | ||||||||||||
638 | for (QXcbVirtualDesktop *vd , c->: virtualDesktops())) { | - | ||||||||||||
639 | if (vd->root() == reply->root) {
| 0-722 | ||||||||||||
640 | *virtualDesktop = vd; | - | ||||||||||||
641 | break; executed 722 times by 27 tests: break; Executed by:
| 722 | ||||||||||||
642 | } | - | ||||||||||||
643 | } never executed: end of block | 0 | ||||||||||||
644 | } executed 722 times by 27 tests: end of block Executed by:
| 722 | ||||||||||||
645 | if (pos)
| 722-15518 | ||||||||||||
646 | *pos = QPoint(reply->root_x, reply->root_y); executed 15518 times by 80 tests: *pos = QPoint(reply->root_x, reply->root_y); Executed by:
| 15518 | ||||||||||||
647 | if (keybMask)
| 0-16240 | ||||||||||||
648 | *keybMask = reply->mask; never executed: *keybMask = reply->mask; | 0 | ||||||||||||
649 | free(reply); | - | ||||||||||||
650 | return; executed 16240 times by 83 tests: return; Executed by:
| 16240 | ||||||||||||
651 | } | - | ||||||||||||
652 | free(err); | - | ||||||||||||
653 | free(reply); | - | ||||||||||||
654 | } never executed: end of block | 0 | ||||||||||||
655 | - | |||||||||||||
656 | QPoint QXcbCursor::pos() const | - | ||||||||||||
657 | { | - | ||||||||||||
658 | QPoint p; | - | ||||||||||||
659 | queryPointer(connection(), 0, &p); | - | ||||||||||||
660 | return p; | - | ||||||||||||
661 | } | - | ||||||||||||
662 | - | |||||||||||||
663 | void QXcbCursor::setPos(const QPoint &pos) | - | ||||||||||||
664 | { | - | ||||||||||||
665 | QXcbVirtualDesktop *virtualDesktop = Q_NULLPTR; | - | ||||||||||||
666 | queryPointer(connection(), &virtualDesktop, 0); | - | ||||||||||||
667 | xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y()); | - | ||||||||||||
668 | xcb_flush(xcb_connection()); | - | ||||||||||||
669 | } | - | ||||||||||||
670 | - | |||||||||||||
671 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |