2015-12-10 05:06:13 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of the QtGui module of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at http://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <qdebug.h>
|
|
|
|
#include <qdatastream.h>
|
|
|
|
#include <qbitmap.h>
|
|
|
|
#include <qcursor.h>
|
2017-08-07 07:41:50 +00:00
|
|
|
#include <qapplication_p.h>
|
|
|
|
#include <qcursor_p.h>
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
#include "qx11info_x11.h"
|
|
|
|
#include <qpixmap_x11_p.h>
|
2017-08-07 07:41:50 +00:00
|
|
|
#include <qt_x11_p.h>
|
|
|
|
#include <X11/cursorfont.h>
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2017-08-09 11:51:23 +00:00
|
|
|
extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap); // qpixmap_x11.cpp
|
|
|
|
|
2015-12-10 05:06:13 +02:00
|
|
|
// Define QT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to
|
|
|
|
// use the ugly X11 cursors.
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
Internal QCursorData class
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
QCursorData::QCursorData(Qt::CursorShape s)
|
|
|
|
: cshape(s), bm(0), bmm(0), hx(0), hy(0), hcurs(0), pm(0), pmm(0)
|
|
|
|
{
|
|
|
|
ref = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QCursorData::~QCursorData()
|
|
|
|
{
|
2017-08-09 11:51:23 +00:00
|
|
|
Display *dpy = qt_x11Data ? qt_x11Data->display : (Display*)0;
|
2015-12-10 05:06:13 +02:00
|
|
|
|
|
|
|
// Add in checking for the display too as on HP-UX
|
|
|
|
// we seem to get a core dump as the cursor data is
|
|
|
|
// deleted again from main() on exit...
|
|
|
|
if (hcurs && dpy)
|
|
|
|
XFreeCursor(dpy, hcurs);
|
|
|
|
if (pm && dpy)
|
|
|
|
XFreePixmap(dpy, pm);
|
|
|
|
if (pmm && dpy)
|
|
|
|
XFreePixmap(dpy, pmm);
|
|
|
|
delete bm;
|
|
|
|
delete bmm;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
QCursor::QCursor(Qt::HANDLE cursor)
|
|
|
|
{
|
|
|
|
if (!QCursorData::initialized)
|
|
|
|
QCursorData::initialize();
|
|
|
|
d = new QCursorData(Qt::CustomCursor);
|
|
|
|
d->hcurs = cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
|
|
|
|
{
|
|
|
|
if (!QCursorData::initialized)
|
|
|
|
QCursorData::initialize();
|
|
|
|
if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
|
|
|
|
qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
|
|
|
|
QCursorData *c = qt_cursorTable[0];
|
|
|
|
c->ref.ref();
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
QCursorData *d = new QCursorData;
|
|
|
|
d->ref = 1;
|
|
|
|
|
|
|
|
d->bm = new QBitmap(qt_toX11Pixmap(bitmap));
|
|
|
|
d->bmm = new QBitmap(qt_toX11Pixmap(mask));
|
|
|
|
|
|
|
|
d->hcurs = 0;
|
|
|
|
d->cshape = Qt::BitmapCursor;
|
|
|
|
d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
|
|
|
|
d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
|
|
|
|
d->fg.red = 0x0000;
|
|
|
|
d->fg.green = 0x0000;
|
|
|
|
d->fg.blue = 0x0000;
|
|
|
|
d->bg.red = 0xffff;
|
|
|
|
d->bg.green = 0xffff;
|
|
|
|
d->bg.blue = 0xffff;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
Qt::HANDLE QCursor::handle() const
|
|
|
|
{
|
|
|
|
if (!QCursorData::initialized)
|
|
|
|
QCursorData::initialize();
|
|
|
|
if (!d->hcurs)
|
|
|
|
d->update();
|
|
|
|
return d->hcurs;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QPoint QCursor::pos()
|
|
|
|
{
|
|
|
|
Window root;
|
|
|
|
Window child;
|
|
|
|
int root_x, root_y, win_x, win_y;
|
|
|
|
uint buttons;
|
2017-08-09 11:51:23 +00:00
|
|
|
Display* dpy = qt_x11Data->display;
|
2015-12-10 05:06:13 +02:00
|
|
|
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
|
|
|
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
|
|
|
&win_x, &win_y, &buttons))
|
|
|
|
|
|
|
|
return QPoint(root_x, root_y);
|
|
|
|
}
|
|
|
|
return QPoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
*/
|
|
|
|
#ifndef QT_NO_CURSOR
|
|
|
|
int QCursor::x11Screen()
|
|
|
|
{
|
|
|
|
Window root;
|
|
|
|
Window child;
|
|
|
|
int root_x, root_y, win_x, win_y;
|
|
|
|
uint buttons;
|
2017-08-09 11:51:23 +00:00
|
|
|
Display* dpy = qt_x11Data->display;
|
2015-12-10 05:06:13 +02:00
|
|
|
for (int i = 0; i < ScreenCount(dpy); ++i) {
|
|
|
|
if (XQueryPointer(dpy, QX11Info::appRootWindow(i), &root, &child, &root_x, &root_y,
|
|
|
|
&win_x, &win_y, &buttons))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void QCursor::setPos(int x, int y)
|
|
|
|
{
|
|
|
|
QPoint current, target(x, y);
|
|
|
|
|
|
|
|
// this is copied from pos(), since we need the screen number for the correct
|
|
|
|
// root window in the XWarpPointer call
|
|
|
|
Window root;
|
|
|
|
Window child;
|
|
|
|
int root_x, root_y, win_x, win_y;
|
|
|
|
uint buttons;
|
2017-08-09 11:51:23 +00:00
|
|
|
Display* dpy = qt_x11Data->display;
|
2015-12-10 05:06:13 +02:00
|
|
|
int screen;
|
|
|
|
for (screen = 0; screen < ScreenCount(dpy); ++screen) {
|
|
|
|
if (XQueryPointer(dpy, QX11Info::appRootWindow(screen), &root, &child, &root_x, &root_y,
|
|
|
|
&win_x, &win_y, &buttons)) {
|
|
|
|
current = QPoint(root_x, root_y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (screen >= ScreenCount(dpy))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Need to check, since some X servers generate null mouse move
|
|
|
|
// events, causing looping in applications which call setPos() on
|
|
|
|
// every mouse move event.
|
|
|
|
//
|
|
|
|
if (current == target)
|
|
|
|
return;
|
|
|
|
|
2017-08-09 11:51:23 +00:00
|
|
|
XWarpPointer(qt_x11Data->display, XNone, QX11Info::appRootWindow(screen), 0, 0, 0, 0, x, y);
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
|
|
|
|
Creates the cursor.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void QCursorData::update()
|
|
|
|
{
|
|
|
|
if (!QCursorData::initialized)
|
|
|
|
QCursorData::initialize();
|
|
|
|
if (hcurs)
|
|
|
|
return;
|
|
|
|
|
2017-08-09 11:51:23 +00:00
|
|
|
Display *dpy = qt_x11Data->display;
|
2015-12-10 05:06:13 +02:00
|
|
|
Window rootwin = QX11Info::appRootWindow();
|
|
|
|
|
|
|
|
if (cshape == Qt::BitmapCursor) {
|
|
|
|
#ifndef QT_NO_XRENDER
|
2017-08-09 11:51:23 +00:00
|
|
|
if (!pixmap.isNull() && qt_x11Data->use_xrender) {
|
2015-12-10 05:06:13 +02:00
|
|
|
pixmap = qt_toX11Pixmap(pixmap);
|
2017-08-09 11:51:23 +00:00
|
|
|
hcurs = XRenderCreateCursor (qt_x11Data->display, pixmap.x11PictureHandle(), hx, hy);
|
2015-12-10 05:06:13 +02:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, bm->handle(), bmm->handle(), &fg, &bg, hx, hy);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *cursorNames[] = {
|
|
|
|
"left_ptr",
|
|
|
|
"up_arrow",
|
|
|
|
"cross",
|
|
|
|
"wait",
|
|
|
|
"ibeam",
|
|
|
|
"size_ver",
|
|
|
|
"size_hor",
|
|
|
|
"size_bdiag",
|
|
|
|
"size_fdiag",
|
|
|
|
"size_all",
|
|
|
|
"blank",
|
|
|
|
"split_v",
|
|
|
|
"split_h",
|
|
|
|
"pointing_hand",
|
|
|
|
"forbidden",
|
|
|
|
"whats_this",
|
|
|
|
"left_ptr_watch",
|
|
|
|
"openhand",
|
|
|
|
"closedhand",
|
|
|
|
"copy",
|
|
|
|
"move",
|
|
|
|
"link"
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef QT_NO_XCURSOR
|
2016-11-05 01:10:19 +00:00
|
|
|
// special case for non-standard dnd-* cursors
|
|
|
|
switch (cshape) {
|
|
|
|
case Qt::DragCopyCursor:
|
|
|
|
hcurs = XcursorLibraryLoadCursor(dpy, "dnd-copy");
|
|
|
|
break;
|
|
|
|
case Qt::DragMoveCursor:
|
|
|
|
hcurs = XcursorLibraryLoadCursor(dpy, "dnd-move");
|
|
|
|
break;
|
|
|
|
case Qt::DragLinkCursor:
|
|
|
|
hcurs = XcursorLibraryLoadCursor(dpy, "dnd-link");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2015-12-10 05:06:13 +02:00
|
|
|
}
|
2016-11-05 01:10:19 +00:00
|
|
|
if (!hcurs)
|
|
|
|
hcurs = XcursorLibraryLoadCursor(dpy, cursorNames[cshape]);
|
2015-12-10 05:06:13 +02:00
|
|
|
if (hcurs)
|
|
|
|
return;
|
|
|
|
#endif // QT_NO_XCURSOR
|
|
|
|
|
|
|
|
static const uchar cur_blank_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
// Non-standard X11 cursors are created from bitmaps
|
|
|
|
|
|
|
|
#ifndef QT_USE_APPROXIMATE_CURSORS
|
|
|
|
static const uchar cur_ver_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
|
|
|
|
0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
|
|
|
|
0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
|
|
|
|
static const uchar mcur_ver_bits[] = {
|
|
|
|
0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
|
|
|
|
0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
|
|
|
|
0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
|
|
|
|
static const uchar cur_hor_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
|
|
|
|
0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar mcur_hor_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
|
|
|
|
0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
|
|
|
|
0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
|
|
|
|
static const uchar cur_bdiag_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
|
|
|
|
0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
|
|
|
|
0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar mcur_bdiag_bits[] = {
|
|
|
|
0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
|
|
|
|
0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
|
|
|
|
0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar cur_fdiag_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
|
|
|
|
0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
|
|
|
|
0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar mcur_fdiag_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
|
|
|
|
0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
|
|
|
|
0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
|
|
|
|
static const uchar *cursor_bits16[] = {
|
|
|
|
cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
|
|
|
|
cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
|
|
|
|
0, 0, cur_blank_bits, cur_blank_bits };
|
|
|
|
|
|
|
|
static const uchar vsplit_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
|
|
|
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
|
|
|
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
|
|
|
0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar vsplitm_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
|
|
|
|
0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
|
|
|
0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
|
|
|
|
0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
|
|
|
|
0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
|
|
|
|
0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
|
|
|
|
0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar hsplit_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
|
|
|
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
|
|
|
0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
|
|
|
|
0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
|
|
|
|
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
|
|
|
|
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar hsplitm_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
|
|
|
|
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
|
|
|
|
0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
|
|
|
|
0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
|
|
|
|
0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
|
|
|
|
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
static const uchar whatsthis_bits[] = {
|
|
|
|
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
|
|
|
|
0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
|
|
|
|
0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
|
|
|
|
0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
|
|
|
|
0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
|
|
|
|
0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
|
|
|
|
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
|
|
|
static const uchar whatsthism_bits[] = {
|
|
|
|
0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
|
|
|
|
0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
|
|
|
|
0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
|
|
|
|
0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
|
|
|
|
0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
|
|
|
|
0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
|
|
|
|
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
|
|
|
static const uchar busy_bits[] = {
|
|
|
|
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
|
|
0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
|
|
|
|
0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
|
|
|
|
0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
|
|
|
|
0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
|
|
|
|
0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
|
|
|
|
0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
|
|
|
|
0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
static const uchar busym_bits[] = {
|
|
|
|
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
|
|
|
0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
|
|
|
|
0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
|
|
|
|
0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
|
|
|
|
0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
|
|
|
|
0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
|
|
|
|
0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
|
|
|
|
0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
static const uchar * const cursor_bits32[] = {
|
|
|
|
vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
|
|
|
|
0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
|
|
|
|
};
|
|
|
|
|
|
|
|
static const uchar forbidden_bits[] = {
|
|
|
|
0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
|
|
|
|
0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
|
|
|
|
0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
|
|
|
|
0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
|
|
|
|
|
|
|
|
static const uchar forbiddenm_bits[] = {
|
|
|
|
0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
|
|
|
|
0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
|
|
|
|
0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
|
|
|
|
0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
|
|
|
|
|
|
|
|
static const uchar openhand_bits[] = {
|
|
|
|
0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
|
|
|
|
0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
|
|
|
|
0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
|
|
|
|
static const uchar openhandm_bits[] = {
|
|
|
|
0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
|
|
|
|
0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
|
|
|
|
0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
|
|
|
|
static const uchar closedhand_bits[] = {
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
|
|
|
|
0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
|
|
|
|
0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
|
|
|
|
static const uchar closedhandm_bits[] = {
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
|
|
|
|
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
|
|
|
|
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
|
|
|
|
|
|
|
|
static const uchar * const cursor_bits20[] = {
|
|
|
|
forbidden_bits, forbiddenm_bits
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor)
|
|
|
|
|| cshape == Qt::BlankCursor) {
|
|
|
|
XColor bg, fg;
|
|
|
|
bg.red = 255 << 8;
|
|
|
|
bg.green = 255 << 8;
|
|
|
|
bg.blue = 255 << 8;
|
|
|
|
fg.red = 0;
|
|
|
|
fg.green = 0;
|
|
|
|
fg.blue = 0;
|
|
|
|
int i = (cshape - Qt::SizeVerCursor) * 2;
|
|
|
|
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i]), 16, 16);
|
|
|
|
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i + 1]), 16, 16);
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
|
|
|
} else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
|
|
|
|
|| cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) {
|
|
|
|
XColor bg, fg;
|
|
|
|
bg.red = 255 << 8;
|
|
|
|
bg.green = 255 << 8;
|
|
|
|
bg.blue = 255 << 8;
|
|
|
|
fg.red = 0;
|
|
|
|
fg.green = 0;
|
|
|
|
fg.blue = 0;
|
|
|
|
int i = (cshape - Qt::SplitVCursor) * 2;
|
|
|
|
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i]), 32, 32);
|
|
|
|
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i + 1]), 32, 32);
|
|
|
|
int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor
|
|
|
|
|| cshape == Qt::BusyCursor) ? 0 : 16;
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, hs, hs);
|
|
|
|
} else if (cshape == Qt::ForbiddenCursor) {
|
|
|
|
XColor bg, fg;
|
|
|
|
bg.red = 255 << 8;
|
|
|
|
bg.green = 255 << 8;
|
|
|
|
bg.blue = 255 << 8;
|
|
|
|
fg.red = 0;
|
|
|
|
fg.green = 0;
|
|
|
|
fg.blue = 0;
|
|
|
|
int i = (cshape - Qt::ForbiddenCursor) * 2;
|
|
|
|
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i]), 20, 20);
|
|
|
|
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i + 1]), 20, 20);
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 10, 10);
|
|
|
|
} else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
|
|
|
|
XColor bg, fg;
|
|
|
|
bg.red = 255 << 8;
|
|
|
|
bg.green = 255 << 8;
|
|
|
|
bg.blue = 255 << 8;
|
|
|
|
fg.red = 0;
|
|
|
|
fg.green = 0;
|
|
|
|
fg.blue = 0;
|
|
|
|
bool open = cshape == Qt::OpenHandCursor;
|
|
|
|
pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhand_bits : closedhand_bits), 16, 16);
|
|
|
|
pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhandm_bits : closedhandm_bits), 16, 16);
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
|
|
|
} else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor
|
|
|
|
|| cshape == Qt::DragLinkCursor) {
|
|
|
|
XColor bg, fg;
|
|
|
|
bg.red = 255 << 8;
|
|
|
|
bg.green = 255 << 8;
|
|
|
|
bg.blue = 255 << 8;
|
|
|
|
fg.red = 0;
|
|
|
|
fg.green = 0;
|
|
|
|
fg.blue = 0;
|
|
|
|
QImage image = QApplicationPrivate::instance()->getPixmapCursor(cshape).toImage();
|
|
|
|
pm = QX11PixmapData::createBitmapFromImage(image);
|
|
|
|
pmm = QX11PixmapData::createBitmapFromImage(image.createAlphaMask().convertToFormat(QImage::Format_MonoLSB));
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hcurs)
|
|
|
|
{
|
|
|
|
#ifndef QT_NO_XFIXES
|
2017-08-09 11:51:23 +00:00
|
|
|
if (qt_x11Data->use_xfixes)
|
2016-11-04 23:33:27 +00:00
|
|
|
XFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
|
2015-12-10 05:06:13 +02:00
|
|
|
#endif /* ! QT_NO_XFIXES */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ! QT_USE_APPROXIMATE_CURSORS */
|
|
|
|
|
|
|
|
uint sh;
|
|
|
|
switch (cshape) { // map Q cursor to X cursor
|
|
|
|
case Qt::ArrowCursor:
|
|
|
|
sh = XC_left_ptr;
|
|
|
|
break;
|
|
|
|
case Qt::UpArrowCursor:
|
|
|
|
sh = XC_center_ptr;
|
|
|
|
break;
|
|
|
|
case Qt::CrossCursor:
|
|
|
|
sh = XC_crosshair;
|
|
|
|
break;
|
|
|
|
case Qt::WaitCursor:
|
|
|
|
sh = XC_watch;
|
|
|
|
break;
|
|
|
|
case Qt::IBeamCursor:
|
|
|
|
sh = XC_xterm;
|
|
|
|
break;
|
|
|
|
case Qt::SizeAllCursor:
|
|
|
|
sh = XC_fleur;
|
|
|
|
break;
|
|
|
|
case Qt::PointingHandCursor:
|
|
|
|
sh = XC_hand2;
|
|
|
|
break;
|
|
|
|
#ifdef QT_USE_APPROXIMATE_CURSORS
|
|
|
|
case Qt::SizeBDiagCursor:
|
|
|
|
sh = XC_top_right_corner;
|
|
|
|
break;
|
|
|
|
case Qt::SizeFDiagCursor:
|
|
|
|
sh = XC_bottom_right_corner;
|
|
|
|
break;
|
|
|
|
case Qt::BlankCursor:
|
|
|
|
XColor bg, fg;
|
|
|
|
bg.red = 255 << 8;
|
|
|
|
bg.green = 255 << 8;
|
|
|
|
bg.blue = 255 << 8;
|
|
|
|
fg.red = 0;
|
|
|
|
fg.green = 0;
|
|
|
|
fg.blue = 0;
|
|
|
|
pm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16);
|
|
|
|
pmm = XCreateBitmapFromData(dpy, rootwin, cur_blank_bits, 16, 16);
|
|
|
|
hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case Qt::SizeVerCursor:
|
|
|
|
case Qt::SplitVCursor:
|
|
|
|
sh = XC_sb_v_double_arrow;
|
|
|
|
break;
|
|
|
|
case Qt::SizeHorCursor:
|
|
|
|
case Qt::SplitHCursor:
|
|
|
|
sh = XC_sb_h_double_arrow;
|
|
|
|
break;
|
|
|
|
case Qt::WhatsThisCursor:
|
|
|
|
sh = XC_question_arrow;
|
|
|
|
break;
|
|
|
|
case Qt::ForbiddenCursor:
|
|
|
|
sh = XC_circle;
|
|
|
|
break;
|
|
|
|
case Qt::BusyCursor:
|
|
|
|
sh = XC_watch;
|
|
|
|
break;
|
|
|
|
case Qt::DragCopyCursor:
|
|
|
|
sh = XC_tcross;
|
|
|
|
break;
|
|
|
|
case Qt::DragLinkCursor:
|
|
|
|
sh = XC_center_ptr;
|
|
|
|
break;
|
|
|
|
case Qt::DragMoveCursor:
|
|
|
|
sh = XC_top_left_arrow;
|
|
|
|
break;
|
|
|
|
#endif /* QT_USE_APPROXIMATE_CURSORS */
|
|
|
|
default:
|
|
|
|
qWarning("QCursor::update: Invalid cursor shape %d", cshape);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hcurs = XCreateFontCursor(dpy, sh);
|
|
|
|
|
|
|
|
#ifndef QT_NO_XFIXES
|
2017-08-09 11:51:23 +00:00
|
|
|
if (qt_x11Data->use_xfixes)
|
2016-11-04 23:33:27 +00:00
|
|
|
XFixesSetCursorName(dpy, hcurs, cursorNames[cshape]);
|
2015-12-10 05:06:13 +02:00
|
|
|
#endif /* ! QT_NO_XFIXES */
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|