KWin
Loading...
Searching...
No Matches
screenshot.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: 2010 Martin Gräßlin <mgraesslin@kde.org>
6 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "effect/effect.h"
14
15#include <QFuture>
16#include <QImage>
17#include <QObject>
18
19namespace KWin
20{
21
31Q_DECLARE_FLAGS(ScreenShotFlags, ScreenShotFlag)
32
33class ScreenShotDBusInterface2;
34struct ScreenShotWindowData;
35struct ScreenShotAreaData;
36struct ScreenShotScreenData;
37
47{
48 Q_OBJECT
49
50public:
52 ~ScreenShotEffect() override;
53
59 QFuture<QImage> scheduleScreenShot(Output *screen, ScreenShotFlags flags = {});
60
65 QFuture<QImage> scheduleScreenShot(const QRect &area, ScreenShotFlags flags = {});
66
72 QFuture<QImage> scheduleScreenShot(EffectWindow *window, ScreenShotFlags flags = {});
73
74 void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
75 bool isActive() const override;
76 int requestedEffectChainPosition() const override;
77
78 static bool supported();
79
80private Q_SLOTS:
81 void handleWindowClosed(EffectWindow *window);
82 void handleScreenAdded();
83 void handleScreenRemoved(Output *screen);
84
85private:
86 void takeScreenShot(ScreenShotWindowData *screenshot);
87 bool takeScreenShot(const RenderTarget &renderTarget, const RenderViewport &viewport, ScreenShotAreaData *screenshot);
88 bool takeScreenShot(const RenderTarget &renderTarget, const RenderViewport &viewport, ScreenShotScreenData *screenshot);
89
90 void cancelWindowScreenShots();
91 void cancelAreaScreenShots();
92 void cancelScreenScreenShots();
93
94 void grabPointerImage(QImage &snapshot, int xOffset, int yOffset) const;
95 QImage blitScreenshot(const RenderTarget &renderTarget, const RenderViewport &viewport, const QRect &geometry, qreal devicePixelRatio = 1.0) const;
96
97 std::vector<ScreenShotWindowData> m_windowScreenShots;
98 std::vector<ScreenShotAreaData> m_areaScreenShots;
99 std::vector<ScreenShotScreenData> m_screenScreenShots;
100
101 std::unique_ptr<ScreenShotDBusInterface2> m_dbusInterface2;
102 Output *m_paintedScreen = nullptr;
103};
104
105} // namespace KWin
106
107Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::ScreenShotFlags)
Base class for all KWin effects.
Definition effect.h:535
Representation of a window used by/for Effect classes.
int requestedEffectChainPosition() const override
~ScreenShotEffect() override
void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override
bool isActive() const override
static bool supported()
QFuture< QImage > scheduleScreenShot(Output *screen, ScreenShotFlags flags={})
ScreenShotFlag
Definition screenshot.h:25
@ ScreenShotIncludeShadow
Include the window shadow.
Definition screenshot.h:29
@ ScreenShotNativeResolution
Take the screenshot at the native resolution.
Definition screenshot.h:28
@ ScreenShotIncludeCursor
Include the cursor.
Definition screenshot.h:27
@ ScreenShotIncludeDecoration
Include window titlebar and borders.
Definition screenshot.h:26