kernel/qcursor_qpa.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 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 <qcursor.h> -
43#include <qscreen.h> -
44#include <private/qcursor_p.h> -
45#include <qpa/qplatformcursor.h> -
46#include <private/qguiapplication_p.h> -
47#include <qbitmap.h> -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51QT_USE_NAMESPACE -
52 -
53#ifndef QT_NO_CURSOR -
54 -
55/***************************************************************************** -
56 Internal QCursorData class -
57 *****************************************************************************/ -
58 -
59QCursorData::QCursorData(Qt::CursorShape s) -
60 : ref(1), cshape(s), bm(0), bmm(0), hx(0), hy(0) -
61{ -
62}
executed: }
Execution Count:6430
6430
63 -
64QCursorData::~QCursorData() -
65{ -
66 delete bm;
executed (the execution status of this line is deduced): delete bm;
-
67 delete bmm;
executed (the execution status of this line is deduced): delete bmm;
-
68}
executed: }
Execution Count:6367
6367
69 -
70 -
71/***************************************************************************** -
72 Global cursors -
73 *****************************************************************************/ -
74 -
75extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp -
76 -
77QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) -
78{ -
79 if (!QCursorData::initialized)
partially evaluated: !QCursorData::initialized
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
0-72
80 QCursorData::initialize();
never executed: QCursorData::initialize();
0
81 if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
partially evaluated: bitmap.depth() != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
partially evaluated: mask.depth() != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
partially evaluated: bitmap.size() != mask.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
0-72
82 qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcursor_qpa.cpp", 82, __PRETTY_FUNCTION__).warning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
-
83 QCursorData *c = qt_cursorTable[0];
never executed (the execution status of this line is deduced): QCursorData *c = qt_cursorTable[0];
-
84 c->ref.ref();
never executed (the execution status of this line is deduced): c->ref.ref();
-
85 return c;
never executed: return c;
0
86 } -
87 QCursorData *d = new QCursorData;
executed (the execution status of this line is deduced): QCursorData *d = new QCursorData;
-
88 d->bm = new QBitmap(bitmap);
executed (the execution status of this line is deduced): d->bm = new QBitmap(bitmap);
-
89 d->bmm = new QBitmap(mask);
executed (the execution status of this line is deduced): d->bmm = new QBitmap(mask);
-
90 d->cshape = Qt::BitmapCursor;
executed (the execution status of this line is deduced): d->cshape = Qt::BitmapCursor;
-
91 d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
evaluated: hotX >= 0
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:12
12-60
92 d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
evaluated: hotY >= 0
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:12
12-60
93 -
94 return d;
executed: return d;
Execution Count:72
72
95} -
96 -
97void QCursorData::update() -
98{ -
99} -
100 -
101#endif //QT_NO_CURSOR -
102 -
103QPoint QCursor::pos() -
104{ -
105 return QCursor::pos(QGuiApplication::primaryScreen());
executed: return QCursor::pos(QGuiApplication::primaryScreen());
Execution Count:18996
18996
106} -
107 -
108QPoint QCursor::pos(const QScreen *screen) -
109{ -
110 if (screen)
partially evaluated: screen
TRUEFALSE
yes
Evaluation Count:18996
no
Evaluation Count:0
0-18996
111 if (const QPlatformCursor *cursor = screen->handle()->cursor())
partially evaluated: const QPlatformCursor *cursor = screen->handle()->cursor()
TRUEFALSE
yes
Evaluation Count:18996
no
Evaluation Count:0
0-18996
112 return cursor->pos();
executed: return cursor->pos();
Execution Count:18996
18996
113 return QGuiApplicationPrivate::lastCursorPosition.toPoint();
never executed: return QGuiApplicationPrivate::lastCursorPosition.toPoint();
0
114} -
115 -
116void QCursor::setPos(QScreen *screen, int x, int y) -
117{ -
118 if (screen) {
partially evaluated: screen
TRUEFALSE
yes
Evaluation Count:442
no
Evaluation Count:0
0-442
119 if (QPlatformCursor *cursor = screen->handle()->cursor()) {
partially evaluated: QPlatformCursor *cursor = screen->handle()->cursor()
TRUEFALSE
yes
Evaluation Count:442
no
Evaluation Count:0
0-442
120 const QPoint pos = QPoint(x, y);
executed (the execution status of this line is deduced): const QPoint pos = QPoint(x, y);
-
121 // Need to check, since some X servers generate null mouse move -
122 // events, causing looping in applications which call setPos() on -
123 // every mouse move event. -
124 if (pos != cursor->pos())
evaluated: pos != cursor->pos()
TRUEFALSE
yes
Evaluation Count:432
yes
Evaluation Count:10
10-432
125 cursor->setPos(pos);
executed: cursor->setPos(pos);
Execution Count:432
432
126 }
executed: }
Execution Count:442
442
127 }
executed: }
Execution Count:442
442
128}
executed: }
Execution Count:442
442
129 -
130void QCursor::setPos(int x, int y) -
131{ -
132 QCursor::setPos(QGuiApplication::primaryScreen(), x, y);
executed (the execution status of this line is deduced): QCursor::setPos(QGuiApplication::primaryScreen(), x, y);
-
133}
executed: }
Execution Count:442
442
134 -
135QT_END_NAMESPACE -
136 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial