Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglfscursor_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QEGLFSCURSOR_H
5#define QEGLFSCURSOR_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qeglfsglobal_p.h"
19#include <qpa/qplatformcursor.h>
20#include <qpa/qplatformscreen.h>
21#include <QtOpenGL/QOpenGLShaderProgram>
22#include <QtGui/QMatrix4x4>
23#include <QtGui/private/qinputdevicemanager_p.h>
24
25#include <QtCore/qlist.h>
26
28
30class QEglFSCursor;
31class QEglFSScreen;
32
34{
36
37public:
38 QEglFSCursorDeviceListener(QEglFSCursor *cursor) : m_cursor(cursor) { }
39 bool hasMouse() const;
40
41public slots:
43
44private:
45 QEglFSCursor *m_cursor;
46};
47
48#if QT_CONFIG(opengl)
49
50struct QEglFSCursorData {
51 QScopedPointer<QOpenGLShaderProgram> program;
52 int textureEntry = 0;
53 int matEntry = 0;
54 uint customCursorTexture = 0;
55 uint atlasTexture = 0;
56 qint64 customCursorKey = 0;
57};
58
59class Q_EGLFS_EXPORT QEglFSCursor : public QPlatformCursor
60{
62public:
63 QEglFSCursor(QPlatformScreen *screen);
64 ~QEglFSCursor();
65
66#ifndef QT_NO_CURSOR
67 void changeCursor(QCursor *cursor, QWindow *widget) override;
68#endif
69 void pointerEvent(const QMouseEvent &event) override;
70 QPoint pos() const override;
71 void setPos(const QPoint &pos) override;
72
73 QRect cursorRect() const;
74 void paintOnScreen();
75 void resetResources();
76
77 void updateMouseStatus();
78
79private:
80 bool event(QEvent *e) override;
81#ifndef QT_NO_CURSOR
82 bool setCurrentCursor(QCursor *cursor);
83#endif
84 void draw(const QRectF &rect);
85 void update(const QRect &rect, bool allScreens);
86 void createShaderPrograms();
87 void createCursorTexture(uint *texture, const QImage &image);
88 void initCursorAtlas();
89
90 // current cursor information
91 struct Cursor {
92 Cursor() : shape(Qt::BlankCursor), customCursorPending(false), customCursorKey(0), useCustomCursor(false) { }
93 Qt::CursorShape shape;
94 QRectF textureRect; // normalized rect inside texture
95 QSize size; // size of the cursor
96 QPoint hotSpot;
97 QImage customCursorImage;
98 QPoint pos; // current cursor position
99 bool customCursorPending;
100 qint64 customCursorKey;
101 bool useCustomCursor;
102 } m_cursor;
103
104 // cursor atlas information
105 struct CursorAtlas {
106 CursorAtlas() : cursorsPerRow(0), cursorWidth(0), cursorHeight(0) { }
107 int cursorsPerRow;
108 int width, height; // width and height of the atlas
109 int cursorWidth, cursorHeight; // width and height of cursors inside the atlas
110 QList<QPoint> hotSpots;
111 QImage image; // valid until it's uploaded
112 } m_cursorAtlas;
113
114 bool m_visible;
115 QEglFSScreen *m_screen;
116 QPlatformScreen *m_activeScreen;
117 QEglFSCursorDeviceListener *m_deviceListener;
118 bool m_updateRequested;
119 QMatrix4x4 m_rotationMatrix;
120};
121#endif // QT_CONFIG(opengl)
122
124
125#endif // QEGLFSCURSOR_H
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
QEglFSCursorDeviceListener(QEglFSCursor *cursor)
void onDeviceListChanged(QInputDeviceManager::DeviceType type)
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtGui
Definition qimage.h:37
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
The QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used.
The QPlatformCursor class provides information about pointer device events (movement,...
virtual void setPos(const QPoint &pos)
virtual void changeCursor(QCursor *windowCursor, QWindow *window)=0
This method is called by Qt whenever the cursor graphic should be changed.
virtual QPoint pos() const
virtual void pointerEvent(const QMouseEvent &event)
This method is called by Qt whenever a QMouseEvent is generated by the underlying pointer input.
The QPlatformScreen class provides an abstraction for visual displays.
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
QCursor cursor
rect
[4]
Combined button and popup list for selecting options.
Definition qcompare.h:63
CursorShape
@ BlankCursor
Definition image.cpp:4
#define Q_EGLFS_EXPORT
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei width
GLenum type
GLenum GLuint texture
GLuint program
struct _cl_event * event
QScreen * screen
[1]
Definition main.cpp:29
#define Q_OBJECT
#define slots
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
myFilter draw(painter, QPoint(0, 0), originalPixmap)