KWin
Loading...
Searching...
No Matches
zoom.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
6 SPDX-FileCopyrightText: 2010 Sebastian Sauer <sebsauer@kdab.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include <config-kwin.h>
14
15#include "effect/effect.h"
16#include <QTime>
17#include <QTimeLine>
18
19namespace KWin
20{
21
22#if HAVE_ACCESSIBILITY
23class ZoomAccessibilityIntegration;
24#endif
25
26class GLFramebuffer;
27class GLTexture;
28class GLVertexBuffer;
29
31 : public Effect
32{
33 Q_OBJECT
34 Q_PROPERTY(qreal zoomFactor READ configuredZoomFactor)
39 Q_PROPERTY(int focusDelay READ configuredFocusDelay)
40 Q_PROPERTY(qreal moveFactor READ configuredMoveFactor)
41 Q_PROPERTY(qreal targetZoom READ targetZoom)
42public:
43 ZoomEffect();
44 ~ZoomEffect() override;
45 void reconfigure(ReconfigureFlags flags) override;
46 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
47 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
48 void postPaintScreen() override;
49 bool isActive() const override;
50 int requestedEffectChainPosition() const override;
51 // for properties
52 qreal configuredZoomFactor() const;
53 int configuredMousePointer() const;
54 int configuredMouseTracking() const;
55 bool isFocusTrackingEnabled() const;
56 bool isTextCaretTrackingEnabled() const;
57 int configuredFocusDelay() const;
58 qreal configuredMoveFactor() const;
59 qreal targetZoom() const;
60private Q_SLOTS:
61 inline void zoomIn()
62 {
63 zoomIn(-1.0);
64 };
65 void zoomIn(double to);
66 void zoomOut();
67 void actualSize();
68 void moveZoomLeft();
69 void moveZoomRight();
70 void moveZoomUp();
71 void moveZoomDown();
72 void moveMouseToFocus();
73 void moveMouseToCenter();
74 void timelineFrameChanged(int frame);
75 void moveFocus(const QPoint &point);
76 void slotMouseChanged(const QPointF &pos, const QPointF &old,
77 Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
78 Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
79 void slotWindowAdded(EffectWindow *w);
80 void slotWindowDamaged();
81 void slotScreenRemoved(Output *screen);
82
83private:
84 void showCursor();
85 void hideCursor();
86 void moveZoom(int x, int y);
87
88private:
89 struct OffscreenData
90 {
91 std::unique_ptr<GLTexture> texture;
92 std::unique_ptr<GLFramebuffer> framebuffer;
93 QRect viewport;
94 };
95
96 GLTexture *ensureCursorTexture();
97 OffscreenData *ensureOffscreenData(const RenderTarget &renderTarget, const RenderViewport &viewport, Output *screen);
98 void markCursorTextureDirty();
99
100#if HAVE_ACCESSIBILITY
101 ZoomAccessibilityIntegration *m_accessibilityIntegration = nullptr;
102#endif
103 double zoom;
104 double target_zoom;
105 double source_zoom;
106 bool polling; // Mouse polling
107 double zoomFactor;
108 enum MouseTrackingType {
109 MouseTrackingProportional = 0,
110 MouseTrackingCentred = 1,
111 MouseTrackingPush = 2,
112 MouseTrackingDisabled = 3,
113 };
114 MouseTrackingType mouseTracking;
115 enum MousePointerType {
116 MousePointerScale = 0,
117 MousePointerKeep = 1,
118 MousePointerHide = 2,
119 };
120 MousePointerType mousePointer;
121 int focusDelay;
122 QPoint cursorPoint;
123 QPoint focusPoint;
124 QPoint prevPoint;
125 QTime lastMouseEvent;
126 QTime lastFocusEvent;
127 std::unique_ptr<GLTexture> m_cursorTexture;
128 bool m_cursorTextureDirty = false;
129 bool isMouseHidden;
130 QTimeLine timeline;
131 int xMove, yMove;
132 double moveFactor;
133 std::chrono::milliseconds lastPresentTime;
134 std::map<Output *, OffscreenData> m_offscreenData;
135};
136
137} // namespace
Base class for all KWin effects.
Definition effect.h:535
Representation of a window used by/for Effect classes.
qreal zoomFactor
Definition zoom.h:34
qreal configuredMoveFactor() const
Definition zoom.cpp:617
void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override
Definition zoom.cpp:294
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override
Definition zoom.cpp:245
bool focusTrackingEnabled
Definition zoom.h:37
void reconfigure(ReconfigureFlags flags) override
Definition zoom.cpp:212
int focusDelay
Definition zoom.h:39
qreal targetZoom
Definition zoom.h:41
int configuredFocusDelay() const
Definition zoom.cpp:612
qreal moveFactor
Definition zoom.h:40
int configuredMousePointer() const
Definition zoom.cpp:602
int configuredMouseTracking() const
Definition zoom.cpp:607
int mousePointer
Definition zoom.h:35
int requestedEffectChainPosition() const override
Definition zoom.cpp:592
bool isActive() const override
Definition zoom.cpp:587
int mouseTracking
Definition zoom.h:36
void postPaintScreen() override
Definition zoom.cpp:417
bool isFocusTrackingEnabled() const
Definition zoom.cpp:142
bool textCaretTrackingEnabled
Definition zoom.h:38
bool isTextCaretTrackingEnabled() const
Definition zoom.cpp:151
qreal configuredZoomFactor() const
Definition zoom.cpp:597
#define private