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