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#include <errno.h>
7
8#include <QtCore/QDebug>
9#include <QWindow>
10#include <QCursor>
11
13
14Q_LOGGING_CATEGORY(lcQpaQnx, "qt.qpa.qnx");
15
16QQnxCursor::QQnxCursor(screen_context_t context) : m_screenContext(context)
17{
18}
19
20#if !defined(QT_NO_CURSOR)
21static int mapQtCursorToScreenCursor(int cshape)
22{
23 int cursor_shape;
24
25 switch (cshape) {
26 case Qt::ArrowCursor:
27 cursor_shape = SCREEN_CURSOR_SHAPE_ARROW;
28 break;
29 case Qt::CrossCursor:
30 cursor_shape = SCREEN_CURSOR_SHAPE_CROSS;
31 break;
32 case Qt::WaitCursor:
33 cursor_shape = SCREEN_CURSOR_SHAPE_WAIT;
34 break;
35 case Qt::IBeamCursor:
36 cursor_shape = SCREEN_CURSOR_SHAPE_IBEAM;
37 break;
38 case Qt::PointingHandCursor:
39 cursor_shape = SCREEN_CURSOR_SHAPE_HAND;
40 break;
41 case Qt::OpenHandCursor:
42 cursor_shape = SCREEN_CURSOR_SHAPE_GRAB;
43 break;
44 case Qt::ClosedHandCursor:
45 cursor_shape = SCREEN_CURSOR_SHAPE_GRABBING;
46 break;
47 case Qt::DragMoveCursor:
48 cursor_shape = SCREEN_CURSOR_SHAPE_MOVE;
49 break;
50 default:
51 cursor_shape = SCREEN_CURSOR_SHAPE_ARROW;
52 break;
53 }
54 return cursor_shape;
55}
56
57void QQnxCursor::changeCursor(QCursor *windowCursor, QWindow *window)
58{
59 qCDebug(lcQpaQnx) << "QQnxCursor::changeCursor() - shape:" << windowCursor->shape()
60 << "window:" << window;
61 if (!window || !window->winId())
62 return;
63 if (windowCursor && windowCursor->shape() != m_currentCShape) {
64 m_currentCShape = windowCursor->shape();
65 errno = 0;
66 int cursorShape = mapQtCursorToScreenCursor(windowCursor->shape());
67 screen_window_t screenWindow = reinterpret_cast<screen_window_t>(window->winId());
68
69 if (!m_session) {
70 Q_SCREEN_CHECKERROR(screen_create_session_type(&m_session, m_screenContext,
71 SCREEN_EVENT_POINTER),
72 "failed to create session type");
73 }
74 Q_SCREEN_CHECKERROR(screen_set_session_property_pv(m_session, SCREEN_PROPERTY_WINDOW,
75 (void**) &screenWindow),
76 "Failed to set window property");
77 Q_SCREEN_CHECKERROR(screen_set_session_property_iv(m_session, SCREEN_PROPERTY_CURSOR,
78 &cursorShape), "Failed to set cursor shape");
79 Q_SCREEN_CHECKERROR(screen_flush_context(m_screenContext, 0),
80 "Failed to flush screen context");
81 }
82}
83#endif
84
85void QQnxCursor::setPos(const QPoint &pos)
86{
87 qCDebug(lcQpaQnx) << "QQnxCursor::setPos -" << pos;
88 m_pos = pos;
89}
90
92{
93 qCDebug(lcQpaQnx) << "QQnxCursor::pos -" << m_pos;
94 return m_pos;
95}
96
97QT_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.
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
static int mapQtCursorToScreenCursor(int cshape)
#define Q_SCREEN_CHECKERROR(x, message)
Definition qqnxglobal.h:13