Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqnxcursor.cpp
Go to the documentation of this file.
1
// Copyright (C) 2011 - 2012 Research In Motion
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qqnxglobal.h"
6
#
include
"qqnxcursor.h"
7
8
#
include
<
QWindow
>
9
#
include
<
QCursor
>
10
11
QT_BEGIN_NAMESPACE
12
13
QQnxCursor
::
QQnxCursor
(screen_context_t context)
14
: m_screenContext(context)
15
, m_customCursorEnabled(qEnvironmentVariableIntValue(
"QT_QPA_QNX_CUSTOM_CURSOR"
))
16
{
17
}
18
19
QQnxCursor
::~
QQnxCursor
()
20
{
21
if
(m_session)
22
screen_destroy_session(m_session);
23
}
24
25
#
if
!
defined
(
QT_NO_CURSOR
)
26
static
int
mapQtCursorToScreenCursor
(
int
cshape)
27
{
28
int
cursor_shape;
29
30
switch
(cshape) {
31
case
Qt::ArrowCursor:
32
cursor_shape = SCREEN_CURSOR_SHAPE_ARROW;
33
break
;
34
case
Qt::CrossCursor:
35
cursor_shape = SCREEN_CURSOR_SHAPE_CROSS;
36
break
;
37
case
Qt::WaitCursor:
38
cursor_shape = SCREEN_CURSOR_SHAPE_WAIT;
39
break
;
40
case
Qt::IBeamCursor:
41
cursor_shape = SCREEN_CURSOR_SHAPE_IBEAM;
42
break
;
43
case
Qt::PointingHandCursor:
44
cursor_shape = SCREEN_CURSOR_SHAPE_HAND;
45
break
;
46
case
Qt::OpenHandCursor:
47
cursor_shape = SCREEN_CURSOR_SHAPE_GRAB;
48
break
;
49
case
Qt::ClosedHandCursor:
50
cursor_shape = SCREEN_CURSOR_SHAPE_GRABBING;
51
break
;
52
case
Qt::DragMoveCursor:
53
cursor_shape = SCREEN_CURSOR_SHAPE_MOVE;
54
break
;
55
default
:
56
cursor_shape = SCREEN_CURSOR_SHAPE_ARROW;
57
break
;
58
}
59
return
cursor_shape;
60
}
61
62
void
QQnxCursor
::
changeCursor
(QCursor *windowCursor, QWindow *window)
63
{
64
// Custom cursor support requires cursors to be declared in the BSP graphics.conf.
65
// Calling screen_flush_context() without that configuration freezes input,
66
// so this feature is opt-in via QT_QPA_QNX_CUSTOM_CURSOR.
67
if
(m_customCursorEnabled) {
68
if
(!windowCursor || !window || !window->winId())
69
return
;
70
71
qCDebug(lcQpaQnx) <<
"QQnxCursor::changeCursor() - shape:"
<< windowCursor->shape()
72
<<
"window:"
<< window;
73
74
if
(windowCursor->shape() != m_currentCShape) {
75
m_currentCShape = windowCursor->shape();
76
int
cursorShape = mapQtCursorToScreenCursor(windowCursor->shape());
77
screen_window_t screenWindow =
reinterpret_cast
<screen_window_t>(window->winId());
78
79
if
(!m_session) {
80
Q_SCREEN_CHECKERROR
(screen_create_session_type(&m_session, m_screenContext,
81
SCREEN_EVENT_POINTER),
82
"failed to create session type"
);
83
if
(!m_session)
84
return
;
85
}
86
Q_SCREEN_CHECKERROR
(screen_set_session_property_pv(m_session, SCREEN_PROPERTY_WINDOW,
87
(
void
**) &screenWindow),
88
"Failed to set window property"
);
89
Q_SCREEN_CHECKERROR
(screen_set_session_property_iv(m_session, SCREEN_PROPERTY_CURSOR,
90
&cursorShape),
"Failed to set cursor shape"
);
91
Q_SCREEN_CHECKERROR
(screen_flush_context(m_screenContext, 0),
92
"Failed to flush screen context"
);
93
}
94
}
95
}
96
#
endif
97
98
void
QQnxCursor
::
setPos
(
const
QPoint &pos)
99
{
100
qCDebug(lcQpaQnx) <<
"QQnxCursor::setPos -"
<< pos;
101
m_pos = pos;
102
}
103
104
QPoint
QQnxCursor
::
pos
()
const
105
{
106
qCDebug(lcQpaQnx) <<
"QQnxCursor::pos -"
<< m_pos;
107
return
m_pos;
108
}
109
110
QT_END_NAMESPACE
QQnxCursor
Definition
qqnxcursor.h:15
QQnxCursor::setPos
void setPos(const QPoint &pos) override
Definition
qqnxcursor.cpp:98
QQnxCursor::~QQnxCursor
~QQnxCursor()
Definition
qqnxcursor.cpp:19
QQnxCursor::pos
QPoint pos() const override
Definition
qqnxcursor.cpp:104
QQnxCursor::changeCursor
void changeCursor(QCursor *windowCursor, QWindow *window) override
This method is called by Qt whenever the cursor graphic should be changed.
Definition
qqnxcursor.cpp:62
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
mapQtCursorToScreenCursor
static int mapQtCursorToScreenCursor(int cshape)
Definition
qqnxcursor.cpp:26
Q_SCREEN_CHECKERROR
#define Q_SCREEN_CHECKERROR(x, message)
Definition
qqnxglobal.h:17
qtbase
src
plugins
platforms
qnx
qqnxcursor.cpp
Generated on
for Qt by
1.18.0