KWin
Loading...
Searching...
No Matches
shakecursor.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "effect/effect.h"
10#include "input_event_spy.h"
12
13#include <QTimer>
14#include <QVariantAnimation>
15
16namespace KWin
17{
18
19class Cursor;
20class GLTexture;
21
23{
24 Q_OBJECT
25
26public:
28 ~ShakeCursorEffect() override;
29
30 static bool supported();
31
32 void reconfigure(ReconfigureFlags flags) override;
33 void pointerEvent(MouseEvent *event) override;
34 bool isActive() const override;
35 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
36
37private:
38 GLTexture *ensureCursorTexture();
39 void markCursorTextureDirty();
40
41 void showCursor();
42 void hideCursor();
43
44 struct Transaction
45 {
46 QPointF position;
47 QPointF hotspot;
48 QSizeF size;
49 qreal magnification;
50 bool damaged = false;
51 };
52 void update(const Transaction &transaction);
53
54 QTimer m_resetCursorScaleTimer;
55 QVariantAnimation m_resetCursorScaleAnimation;
56 ShakeDetector m_shakeDetector;
57
58 Cursor *m_cursor;
59 QRectF m_cursorGeometry;
60 qreal m_cursorMagnification = 1.0;
61
62 std::unique_ptr<GLTexture> m_cursorTexture;
63 bool m_cursorTextureDirty = false;
64 bool m_mouseHidden = false;
65};
66
67} // namespace KWin
Replacement for QCursor.
Definition cursor.h:102
Base class for all KWin effects.
Definition effect.h:535
void pointerEvent(MouseEvent *event) override
void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override
void reconfigure(ReconfigureFlags flags) override
bool isActive() const override