File indexing completed on 2024-11-10 04:57:11
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org> 0006 SPDX-FileCopyrightText: 2010 Jorge Mata <matamax123@gmail.com> 0007 SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #pragma once 0013 0014 #include "effect/effect.h" 0015 0016 class QAction; 0017 0018 namespace KWin 0019 { 0020 class GLTexture; 0021 0022 class TrackMouseEffect 0023 : public Effect 0024 { 0025 Q_OBJECT 0026 Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers) 0027 Q_PROPERTY(bool mousePolling READ isMousePolling) 0028 public: 0029 TrackMouseEffect(); 0030 ~TrackMouseEffect() override; 0031 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; 0032 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; 0033 void postPaintScreen() override; 0034 void reconfigure(ReconfigureFlags) override; 0035 bool isActive() const override; 0036 0037 // for properties 0038 Qt::KeyboardModifiers modifiers() const 0039 { 0040 return m_modifiers; 0041 } 0042 bool isMousePolling() const 0043 { 0044 return m_mousePolling; 0045 } 0046 private Q_SLOTS: 0047 void toggle(); 0048 void slotMouseChanged(const QPointF &pos, const QPointF &old, 0049 Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, 0050 Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); 0051 0052 private: 0053 bool init(); 0054 void loadTexture(); 0055 QRect m_lastRect[2]; 0056 bool m_mousePolling; 0057 float m_angle; 0058 float m_angleBase; 0059 std::unique_ptr<GLTexture> m_texture[2]; 0060 QAction *m_action; 0061 QImage m_image[2]; 0062 Qt::KeyboardModifiers m_modifiers; 0063 0064 enum class State { 0065 ActivatedByModifiers, 0066 ActivatedByShortcut, 0067 Inactive 0068 }; 0069 State m_state = State::Inactive; 0070 }; 0071 0072 } // namespace