File indexing completed on 2024-11-10 04:57:02
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org> 0006 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include "effect/effect.h" 0014 0015 namespace KWin 0016 { 0017 0018 class GLFramebuffer; 0019 class GLTexture; 0020 0021 class MagnifierEffect : public Effect 0022 { 0023 Q_OBJECT 0024 Q_PROPERTY(QSize magnifierSize READ magnifierSize) 0025 Q_PROPERTY(qreal targetZoom READ targetZoom) 0026 public: 0027 MagnifierEffect(); 0028 ~MagnifierEffect() override; 0029 void reconfigure(ReconfigureFlags) override; 0030 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; 0031 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override; 0032 void postPaintScreen() override; 0033 bool isActive() const override; 0034 static bool supported(); 0035 0036 // for properties 0037 QSize magnifierSize() const; 0038 qreal targetZoom() const; 0039 private Q_SLOTS: 0040 void zoomIn(); 0041 void zoomOut(); 0042 void toggle(); 0043 void slotMouseChanged(const QPointF &pos, const QPointF &old, 0044 Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, 0045 Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); 0046 void slotWindowAdded(EffectWindow *w); 0047 void slotWindowDamaged(); 0048 0049 private: 0050 QRect magnifierArea(QPointF pos = cursorPos()) const; 0051 double m_zoom; 0052 double m_targetZoom; 0053 bool m_polling; // Mouse polling 0054 std::chrono::milliseconds m_lastPresentTime; 0055 QSize m_magnifierSize; 0056 std::unique_ptr<GLTexture> m_texture; 0057 std::unique_ptr<GLFramebuffer> m_fbo; 0058 }; 0059 0060 } // namespace