Commit 6dd38c8a authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Port to org.kde.KWin.ScreenShot2.CaptureActiveScreen

Currently, "Current Screen" capture mode requires the user to select a
screen, which is the opposite what one would expect.
parent d3168d11
......@@ -186,6 +186,11 @@ ScreenShotSourceActiveWindow2::ScreenShotSourceActiveWindow2(PlatformKWinWayland
{
}
ScreenShotSourceActiveScreen2::ScreenShotSourceActiveScreen2(PlatformKWinWayland2::ScreenShotFlags flags)
: ScreenShotSource2(QStringLiteral("CaptureActiveScreen"), screenShotFlagsToVardict(flags))
{
}
ScreenShotSourceMeta2::ScreenShotSourceMeta2(const QVector<ScreenShotSource2 *> &sources)
: m_sources(sources)
{
......@@ -298,7 +303,11 @@ void PlatformKWinWayland2::doGrab(ShutterMode, GrabMode theGrabMode, bool theInc
takeScreenShotArea(workArea(), flags);
break;
case GrabMode::CurrentScreen:
takeScreenShotInteractive(InteractiveKind::Screen, flags);
if (m_apiVersion >= 2) {
takeScreenShotActiveScreen(flags);
} else {
takeScreenShotInteractive(InteractiveKind::Screen, flags);
}
break;
case GrabMode::ActiveWindow:
takeScreenShotActiveWindow(flags);
......@@ -359,6 +368,11 @@ void PlatformKWinWayland2::takeScreenShotActiveWindow(ScreenShotFlags flags)
trackSource(new ScreenShotSourceActiveWindow2(flags));
}
void PlatformKWinWayland2::takeScreenShotActiveScreen(ScreenShotFlags flags)
{
trackSource(new ScreenShotSourceActiveScreen2(flags));
}
void PlatformKWinWayland2::takeScreenShotScreens(const QList<QScreen *> &screens, ScreenShotFlags flags)
{
QVector<ScreenShotSource2 *> sources;
......
......@@ -53,6 +53,7 @@ private:
void takeScreenShotArea(const QRect &area, ScreenShotFlags flags);
void takeScreenShotScreens(const QList<QScreen *> &screens, ScreenShotFlags flags);
void takeScreenShotActiveWindow(ScreenShotFlags flags);
void takeScreenShotActiveScreen(ScreenShotFlags flags);
void trackSource(ScreenShotSource2 *source);
void trackSource(ScreenShotSourceMeta2 *source);
......@@ -136,6 +137,18 @@ public:
ScreenShotSourceActiveWindow2(PlatformKWinWayland2::ScreenShotFlags flags);
};
/**
* The ScreenShotSourceActiveScreen2 class provides a convenient way to take a screenshot
* of the active screen. This uses the org.kde.KWin.ScreenShot2 dbus interface.
*/
class ScreenShotSourceActiveScreen2 final : public ScreenShotSource2
{
Q_OBJECT
public:
ScreenShotSourceActiveScreen2(PlatformKWinWayland2::ScreenShotFlags flags);
};
/**
* The ScreenShotSourceMeta2 class represents a screenshot source that is made of several
* other sources.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment