File indexing completed on 2024-11-10 04:57:08
0001 /* 0002 SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "effect/effect.h" 0010 #include "input_event_spy.h" 0011 #include "plugins/shakecursor/shakedetector.h" 0012 0013 #include <QTimer> 0014 #include <QVariantAnimation> 0015 0016 namespace KWin 0017 { 0018 0019 class Cursor; 0020 class GLTexture; 0021 0022 class ShakeCursorEffect : public Effect, public InputEventSpy 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 ShakeCursorEffect(); 0028 ~ShakeCursorEffect() override; 0029 0030 static bool supported(); 0031 0032 void reconfigure(ReconfigureFlags flags) override; 0033 void pointerEvent(MouseEvent *event) override; 0034 bool isActive() const override; 0035 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; 0036 0037 private: 0038 GLTexture *ensureCursorTexture(); 0039 void markCursorTextureDirty(); 0040 0041 void showCursor(); 0042 void hideCursor(); 0043 0044 struct Transaction 0045 { 0046 QPointF position; 0047 QPointF hotspot; 0048 QSizeF size; 0049 qreal magnification; 0050 bool damaged = false; 0051 }; 0052 void update(const Transaction &transaction); 0053 0054 QTimer m_resetCursorScaleTimer; 0055 QVariantAnimation m_resetCursorScaleAnimation; 0056 ShakeDetector m_shakeDetector; 0057 0058 Cursor *m_cursor; 0059 QRectF m_cursorGeometry; 0060 qreal m_cursorMagnification = 1.0; 0061 0062 std::unique_ptr<GLTexture> m_cursorTexture; 0063 bool m_cursorTextureDirty = false; 0064 bool m_mouseHidden = false; 0065 }; 0066 0067 } // namespace KWin