KWin
Loading...
Searching...
No Matches
cursorsource.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
10
11#include <QImage>
12#include <QObject>
13#include <QPoint>
14#include <QTimer>
15
16namespace KWin
17{
18
19class SurfaceInterface;
20
24class KWIN_EXPORT CursorSource : public QObject
25{
26 Q_OBJECT
27
28public:
29 explicit CursorSource(QObject *parent = nullptr);
30
31 QSizeF size() const;
32 QPointF hotspot() const;
33
34Q_SIGNALS:
35 void changed();
36
37protected:
38 QSizeF m_size = QSizeF(0, 0);
39 QPointF m_hotspot;
40};
41
45class KWIN_EXPORT ShapeCursorSource : public CursorSource
46{
47 Q_OBJECT
48
49public:
50 explicit ShapeCursorSource(QObject *parent = nullptr);
51
52 QImage image() const;
53
54 QByteArray shape() const;
55 void setShape(const QByteArray &shape);
56 void setShape(Qt::CursorShape shape);
57
58 KXcursorTheme theme() const;
59 void setTheme(const KXcursorTheme &theme);
60
61private:
62 void refresh();
63 void selectNextSprite();
64 void selectSprite(int index);
65
66 KXcursorTheme m_theme;
67 QByteArray m_shape;
68 QList<KXcursorSprite> m_sprites;
69 QTimer m_delayTimer;
70 QImage m_image;
71 int m_currentSprite = -1;
72};
73
77class KWIN_EXPORT SurfaceCursorSource : public CursorSource
78{
79 Q_OBJECT
80
81public:
82 explicit SurfaceCursorSource(QObject *parent = nullptr);
83
84 SurfaceInterface *surface() const;
85
86public Q_SLOTS:
87 void update(SurfaceInterface *surface, const QPointF &hotspot);
88
89private:
90 void refresh();
91 void reset();
92
93 SurfaceInterface *m_surface = nullptr;
94};
95
96} // namespace KWin
Resource representing a wl_surface.
Definition surface.h:80