Qt 4.8
qcursor_x11.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <qdebug.h>
43 #include <qdatastream.h>
44 #include <private/qcursor_p.h>
45 #include <private/qt_x11_p.h>
46 #include <private/qapplication_p.h>
47 #include <qbitmap.h>
48 #include <qcursor.h>
49 #include <X11/cursorfont.h>
50 
51 #include <qlibrary.h>
52 
53 #ifndef QT_NO_XCURSOR
54 # include <X11/Xcursor/Xcursor.h>
55 #endif // QT_NO_XCURSOR
56 
57 #ifndef QT_NO_XFIXES
58 #ifndef Status
59 #define Status int
60 #endif
61 # include <X11/extensions/Xfixes.h>
62 #endif // QT_NO_XFIXES
63 
64 #include "qx11info_x11.h"
65 #include <private/qpixmap_x11_p.h>
66 
68 
69 // Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to
70 // use the ugly X11 cursors.
71 
72 /*****************************************************************************
73  Internal QCursorData class
74  *****************************************************************************/
75 
77  : cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(0), pm(0), pmm(0)
78 {
79  ref = 1;
80 }
81 
83 {
84  Display *dpy = X11 ? X11->display : (Display*)0;
85 
86  // Add in checking for the display too as on HP-UX
87  // we seem to get a core dump as the cursor data is
88  // deleted again from main() on exit...
89  if (hcurs && dpy)
90  XFreeCursor(dpy, hcurs);
91  if (pm && dpy)
92  XFreePixmap(dpy, pm);
93  if (pmm && dpy)
94  XFreePixmap(dpy, pmm);
95  delete bm;
96  delete bmm;
97 }
98 
99 #ifndef QT_NO_CURSOR
101 {
105  d->hcurs = cursor;
106 }
107 
108 #endif
109 
110 QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
111 {
114  if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
115  qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
117  c->ref.ref();
118  return c;
119  }
120  QCursorData *d = new QCursorData;
121  d->ref = 1;
122 
123  extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
124  d->bm = new QBitmap(qt_toX11Pixmap(bitmap));
125  d->bmm = new QBitmap(qt_toX11Pixmap(mask));
126 
127  d->hcurs = 0;
129  d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
130  d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
131  d->fg.red = 0x0000;
132  d->fg.green = 0x0000;
133  d->fg.blue = 0x0000;
134  d->bg.red = 0xffff;
135  d->bg.green = 0xffff;
136  d->bg.blue = 0xffff;
137  return d;
138 }
139 
140 
141 
142 #ifndef QT_NO_CURSOR
144 {
147  if (!d->hcurs)
148  d->update();
149  return d->hcurs;
150 }
151 #endif
152 
154 {
155  Window root;
156  Window child;
157  int root_x, root_y, win_x, win_y;
158  uint buttons;
159  Display* dpy = X11->display;
160  for (int i = 0; i < ScreenCount(dpy); ++i) {
161  if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
162  &win_x, &win_y, &buttons))
163 
164  return QPoint(root_x, root_y);
165  }
166  return QPoint();
167 }
168 
171 #ifndef QT_NO_CURSOR
172 int QCursor::x11Screen()
173 {
174  Window root;
175  Window child;
176  int root_x, root_y, win_x, win_y;
177  uint buttons;
178  Display* dpy = X11->display;
179  for (int i = 0; i < ScreenCount(dpy); ++i) {
180  if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
181  &win_x, &win_y, &buttons))
182  return i;
183  }
184  return -1;
185 }
186 #endif
187 
188 void QCursor::setPos(int x, int y)
189 {
190  QPoint current, target(x, y);
191 
192  // this is copied from pos(), since we need the screen number for the correct
193  // root window in the XWarpPointer call
194  Window root;
195  Window child;
196  int root_x, root_y, win_x, win_y;
197  uint buttons;
198  Display* dpy = X11->display;
199  int screen;
200  for (screen = 0; screen < ScreenCount(dpy); ++screen) {
201  if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
202  &win_x, &win_y, &buttons)) {
203  current = QPoint(root_x, root_y);
204  break;
205  }
206  }
207 
208  if (screen >= ScreenCount(dpy))
209  return;
210 
211  // Need to check, since some X servers generate null mouse move
212  // events, causing looping in applications which call setPos() on
213  // every mouse move event.
214  //
215  if (current == target)
216  return;
217 
218  XWarpPointer(X11->display, XNone, QX11Info::appRootWindow(screen), 0, 0, 0, 0, x, y);
219 }
220 
221 
231 void QCursorData::update()
232 {
235  if (hcurs)
236  return;
237 
238  Display *dpy = X11->display;
239  Window rootwin = QX11Info::appRootWindow();
240 
241  if (cshape == Qt::BitmapCursor) {
242  extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
243 #ifndef QT_NO_XRENDER
244  if (!pixmap.isNull() && X11->use_xrender) {
245  pixmap = qt_toX11Pixmap(pixmap);
246  hcurs = XRenderCreateCursor (X11->display, pixmap.x11PictureHandle(), hx, hy);
247  } else
248 #endif
249  {
250  hcurs = XCreatePixmapCursor(dpy, bm->handle(), bmm->handle(), &fg, &bg, hx, hy);
251  }
252  return;
253  }
254 
255  static const char *cursorNames[] = {
256  "left_ptr",
257  "up_arrow",
258  "cross",
259  "wait",
260  "ibeam",
261  "size_ver",
262  "size_hor",
263  "size_bdiag",
264  "size_fdiag",
265  "size_all",
266  "blank",
267  "split_v",
268  "split_h",
269  "pointing_hand",
270  "forbidden",
271  "whats_this",
272  "left_ptr_watch",
273  "openhand",
274  "closedhand",
275  "copy",
276  "move",
277  "link"
278  };
279 
280 #ifndef QT_NO_XCURSOR
281  if (X11->ptrXcursorLibraryLoadCursor) {
282  // special case for non-standard dnd-* cursors
283  switch (cshape) {
284  case Qt::DragCopyCursor:
285  hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-copy");
286  break;
287  case Qt::DragMoveCursor:
288  hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-move");
289  break;
290  case Qt::DragLinkCursor:
291  hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-link");
292  break;
293  default:
294  break;
295  }
296  if (!hcurs)
297  hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]);
298  }
299  if (hcurs)
300  return;
301 #endif // QT_NO_XCURSOR
302 
303  static const uchar cur_blank_bits[] = {
304  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
307 
308  // Non-standard X11 cursors are created from bitmaps
309 
310 #ifndef QT_USE_APPROXIMATE_CURSORS
311  static const uchar cur_ver_bits[] = {
312  0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
313  0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
314  0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
315  static const uchar mcur_ver_bits[] = {
316  0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
317  0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
318  0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
319  static const uchar cur_hor_bits[] = {
320  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
321  0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
322  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
323  static const uchar mcur_hor_bits[] = {
324  0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
325  0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
326  0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
327  static const uchar cur_bdiag_bits[] = {
328  0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
329  0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
330  0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
331  static const uchar mcur_bdiag_bits[] = {
332  0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
333  0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
334  0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
335  static const uchar cur_fdiag_bits[] = {
336  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
337  0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
338  0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
339  static const uchar mcur_fdiag_bits[] = {
340  0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
341  0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
342  0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
343  static const uchar *cursor_bits16[] = {
346  0, 0, cur_blank_bits, cur_blank_bits };
347 
348  static const uchar vsplit_bits[] = {
349  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351  0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
352  0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
353  0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
354  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
355  0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
356  0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
357  0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
358  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
359  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
360  static const uchar vsplitm_bits[] = {
361  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
363  0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
364  0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
365  0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
366  0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
367  0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
368  0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
369  0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
370  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
371  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
372  static const uchar hsplit_bits[] = {
373  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
374  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
375  0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
376  0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
377  0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
378  0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
379  0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
380  0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
381  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
383  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
384  static const uchar hsplitm_bits[] = {
385  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387  0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
388  0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
389  0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
390  0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
391  0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
392  0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
393  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
394  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
395  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
396  static const uchar whatsthis_bits[] = {
397  0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
398  0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
399  0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
400  0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
401  0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
402  0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
403  0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
404  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
405  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
406  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
407  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
408  static const uchar whatsthism_bits[] = {
409  0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
410  0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
411  0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
412  0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
413  0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
414  0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
415  0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
416  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
417  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
418  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
420  static const uchar busy_bits[] = {
421  0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
422  0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
423  0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
424  0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
425  0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
426  0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
427  0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
428  0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
429  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
430  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
431  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
432  static const uchar busym_bits[] = {
433  0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
434  0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
435  0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
436  0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
437  0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
438  0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
439  0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
440  0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
441  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
443  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
444 
445  static const uchar * const cursor_bits32[] = {
447  0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
448  };
449 
450  static const uchar forbidden_bits[] = {
451  0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
452  0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
453  0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
454  0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
455 
456  static const uchar forbiddenm_bits[] = {
457  0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
458  0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
459  0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
460  0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
461 
462  static const uchar openhand_bits[] = {
463  0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
464  0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
465  0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
466  static const uchar openhandm_bits[] = {
467  0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
468  0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
469  0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
470  static const uchar closedhand_bits[] = {
471  0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
472  0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
473  0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
474  static const uchar closedhandm_bits[] = {
475  0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
476  0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
477  0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
478 
479  static const uchar * const cursor_bits20[] = {
480  forbidden_bits, forbiddenm_bits
481  };
482 
484  || cshape == Qt::BlankCursor) {
485  XColor bg, fg;
486  bg.red = 255 << 8;
487  bg.green = 255 << 8;
488  bg.blue = 255 << 8;
489  fg.red = 0;
490  fg.green = 0;
491  fg.blue = 0;
492  int i = (cshape - Qt::SizeVerCursor) * 2;
493  pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i]), 16, 16);
494  pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i + 1]), 16, 16);
495  hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
496  } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
498  XColor bg, fg;
499  bg.red = 255 << 8;
500  bg.green = 255 << 8;
501  bg.blue = 255 << 8;
502  fg.red = 0;
503  fg.green = 0;
504  fg.blue = 0;
505  int i = (cshape - Qt::SplitVCursor) * 2;
506  pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i]), 32, 32);
507  pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i + 1]), 32, 32);
509  || cshape == Qt::BusyCursor) ? 0 : 16;
510  hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, hs, hs);
511  } else if (cshape == Qt::ForbiddenCursor) {
512  XColor bg, fg;
513  bg.red = 255 << 8;
514  bg.green = 255 << 8;
515  bg.blue = 255 << 8;
516  fg.red = 0;
517  fg.green = 0;
518  fg.blue = 0;
519  int i = (cshape - Qt::ForbiddenCursor) * 2;
520  pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i]), 20, 20);
521  pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i + 1]), 20, 20);
522  hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 10, 10);
524  XColor bg, fg;
525  bg.red = 255 << 8;
526  bg.green = 255 << 8;
527  bg.blue = 255 << 8;
528  fg.red = 0;
529  fg.green = 0;
530  fg.blue = 0;
531  bool open = cshape == Qt::OpenHandCursor;
532  pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhand_bits : closedhand_bits), 16, 16);
533  pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhandm_bits : closedhandm_bits), 16, 16);
534  hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
536  || cshape == Qt::DragLinkCursor) {
537  XColor bg, fg;
538  bg.red = 255 << 8;
539  bg.green = 255 << 8;
540  bg.blue = 255 << 8;
541  fg.red = 0;
542  fg.green = 0;
543  fg.blue = 0;
547  hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
548  }
549 
550  if (hcurs)
551  {
552 #ifndef QT_NO_XFIXES
553  if (X11->use_xfixes && X11->ptrXFixesSetCursorName)
554  X11->ptrXFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
555 #endif /* ! QT_NO_XFIXES */
556  return;
557  }
558 
559 #endif /* ! QT_USE_APPROXIMATE_CURSORS */
560 
561  uint sh;
562  switch (cshape) { // map Q cursor to X cursor
563  case Qt::ArrowCursor:
564  sh = XC_left_ptr;
565  break;
566  case Qt::UpArrowCursor:
567  sh = XC_center_ptr;
568  break;
569  case Qt::CrossCursor:
570  sh = XC_crosshair;
571  break;
572  case Qt::WaitCursor:
573  sh = XC_watch;
574  break;
575  case Qt::IBeamCursor:
576  sh = XC_xterm;
577  break;
578  case Qt::SizeAllCursor:
579  sh = XC_fleur;
580  break;
582  sh = XC_hand2;
583  break;
584 #ifdef QT_USE_APPROXIMATE_CURSORS
585  case Qt::SizeBDiagCursor:
586  sh = XC_top_right_corner;
587  break;
588  case Qt::SizeFDiagCursor:
589  sh = XC_bottom_right_corner;
590  break;
591  case Qt::BlankCursor:
592  XColor bg, fg;
593  bg.red = 255 << 8;
594  bg.green = 255 << 8;
595  bg.blue = 255 << 8;
596  fg.red = 0;
597  fg.green = 0;
598  fg.blue = 0;
599  pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16);
600  pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16);
601  hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
602  return;
603  break;
604  case Qt::SizeVerCursor:
605  case Qt::SplitVCursor:
606  sh = XC_sb_v_double_arrow;
607  break;
608  case Qt::SizeHorCursor:
609  case Qt::SplitHCursor:
610  sh = XC_sb_h_double_arrow;
611  break;
612  case Qt::WhatsThisCursor:
613  sh = XC_question_arrow;
614  break;
615  case Qt::ForbiddenCursor:
616  sh = XC_circle;
617  break;
618  case Qt::BusyCursor:
619  sh = XC_watch;
620  break;
621  case Qt::DragCopyCursor:
622  sh = XC_tcross;
623  break;
624  case Qt::DragLinkCursor:
625  sh = XC_center_ptr;
626  break;
627  case Qt::DragMoveCursor:
628  sh = XC_top_left_arrow;
629  break;
630 #endif /* QT_USE_APPROXIMATE_CURSORS */
631  default:
632  qWarning("QCursor::update: Invalid cursor shape %d", cshape);
633  return;
634  }
635  hcurs = XCreateFontCursor(dpy, sh);
636 
637 #ifndef QT_NO_XFIXES
638  if (X11->use_xfixes && X11->ptrXFixesSetCursorName)
639  X11->ptrXFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
640 #endif /* ! QT_NO_XFIXES */
641 }
642 
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
double d
Definition: qnumeric_p.h:62
static Qt::HANDLE createBitmapFromImage(const QImage &image)
QImage toImage() const
Converts the pixmap to a QImage.
Definition: qpixmap.cpp:542
static const uchar hsplit_bits[]
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static const uchar closedhandm_bits[]
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
static const uchar vsplit_bits[]
short hy
Definition: qcursor_p.h:91
QPixmap qt_toX11Pixmap(const QImage &image)
Definition: qpixmap_x11.cpp:81
QPixmap pixmap
Definition: qcursor_p.h:90
static const uchar openhandm_bits[]
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
static const uchar cur_bdiag_bits[]
static const uchar openhand_bits[]
static const uchar cur_hor_bits[]
static Qt::MouseButtons buttons
static QApplicationPrivate * instance()
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299
bool ref()
Atomically increments the value of this QAtomicInt.
static const uchar mcur_ver_bits[]
static bool initialized
Definition: qcursor_p.h:125
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
static void setPos(int x, int y)
Moves the cursor (hot spot) to the global screen position (x, y).
Definition: qcursor_mac.mm:315
#define X11
Definition: qt_x11_p.h:724
static const uchar closedhand_bits[]
static const uchar whatsthis_bits[]
static const uchar mcur_hor_bits[]
HCURSOR hcurs
Definition: qcursor_p.h:98
static QCursorData * setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
Definition: qcursor_mac.mm:278
unsigned char uchar
Definition: qglobal.h:994
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
static const uchar busy_bits[]
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const uchar hsplitm_bits[]
QCursorData(Qt::CursorShape s=Qt::ArrowCursor)
Definition: qcursor_mac.mm:253
static const uchar busym_bits[]
static const uchar whatsthism_bits[]
static const uchar cur_blank_bits[]
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
QImage createAlphaMask(Qt::ImageConversionFlags flags=Qt::AutoColor) const
Builds and returns a 1-bpp mask from the alpha buffer in this image.
Definition: qimage.cpp:4720
QCursorData * qt_cursorTable[Qt::LastCursor+1]
Definition: qcursor.cpp:398
static const uchar forbidden_bits[]
static const uchar vsplitm_bits[]
void * HANDLE
Definition: qnamespace.h:1671
void update()
Creates the cursor.
Definition: qcursor_mac.mm:387
struct _XDisplay Display
Definition: qwindowdefs.h:115
Qt::CursorShape cshape
Definition: qcursor_p.h:88
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
QPixmap getPixmapCursor(Qt::CursorShape cshape)
CursorShape
Definition: qnamespace.h:1262
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
short hx
Definition: qcursor_p.h:91
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QBitmap * bmm
Definition: qcursor_p.h:89
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
static void initialize()
Definition: qcursor.cpp:417
QAtomicInt ref
Definition: qcursor_p.h:87
static const uchar mcur_bdiag_bits[]
QCursor()
Constructs a cursor with the default arrow shape.
Definition: qcursor.cpp:433
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
QBitmap * bm
Definition: qcursor_p.h:89
static const uchar cur_ver_bits[]
static const uchar mcur_fdiag_bits[]
static const uchar forbiddenm_bits[]
int open(const char *, int,...)
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
static const uchar cur_fdiag_bits[]