File indexing completed on 2024-11-10 04:57:08
0001 /* 0002 SPDX-FileCopyrightText: 2010 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "screenshot.h" 0011 0012 #include <QDBusContext> 0013 #include <QDBusUnixFileDescriptor> 0014 #include <QObject> 0015 #include <QVariantMap> 0016 0017 namespace KWin 0018 { 0019 0020 class ScreenShotEffect; 0021 class ScreenShotSinkPipe2; 0022 class ScreenShotSource2; 0023 0024 /** 0025 * The ScreenshotDBusInterface2 class provides a d-bus api to take screenshots. This implements 0026 * the org.kde.KWin.ScreenShot2 interface. 0027 * 0028 * An application that requests a screenshot must have "org.kde.KWin.ScreenShot2" listed in its 0029 * X-KDE-DBUS-Restricted-Interfaces desktop file field. 0030 */ 0031 class ScreenShotDBusInterface2 : public QObject, public QDBusContext 0032 { 0033 Q_OBJECT 0034 Q_PROPERTY(int Version READ version CONSTANT) 0035 0036 public: 0037 explicit ScreenShotDBusInterface2(ScreenShotEffect *effect); 0038 ~ScreenShotDBusInterface2() override; 0039 0040 int version() const; 0041 0042 public Q_SLOTS: 0043 QVariantMap CaptureWindow(const QString &handle, const QVariantMap &options, 0044 QDBusUnixFileDescriptor pipe); 0045 QVariantMap CaptureActiveWindow(const QVariantMap &options, 0046 QDBusUnixFileDescriptor pipe); 0047 QVariantMap CaptureArea(int x, int y, int width, int height, 0048 const QVariantMap &options, 0049 QDBusUnixFileDescriptor pipe); 0050 QVariantMap CaptureScreen(const QString &name, const QVariantMap &options, 0051 QDBusUnixFileDescriptor pipe); 0052 QVariantMap CaptureActiveScreen(const QVariantMap &options, 0053 QDBusUnixFileDescriptor pipe); 0054 QVariantMap CaptureInteractive(uint kind, const QVariantMap &options, 0055 QDBusUnixFileDescriptor pipe); 0056 QVariantMap CaptureWorkspace(const QVariantMap &options, 0057 QDBusUnixFileDescriptor pipe); 0058 0059 private: 0060 void takeScreenShot(Output *screen, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); 0061 void takeScreenShot(const QRect &area, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); 0062 void takeScreenShot(EffectWindow *window, ScreenShotFlags flags, ScreenShotSinkPipe2 *sink); 0063 0064 void bind(ScreenShotSinkPipe2 *sink, ScreenShotSource2 *source); 0065 bool checkPermissions() const; 0066 0067 ScreenShotEffect *m_effect; 0068 }; 0069 0070 } // namespace KWin