From 1f7975e2715f955c059251089277612fc74f9459 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 17 Mar 2023 17:16:08 +0200 Subject: [PATCH] effects/screenshot: Provide screenshot scale information --- .../screenshot/org.kde.KWin.ScreenShot2.xml | 21 +++++++++++++++++++ .../screenshot/screenshotdbusinterface2.cpp | 1 + 2 files changed, 22 insertions(+) diff --git a/src/effects/screenshot/org.kde.KWin.ScreenShot2.xml b/src/effects/screenshot/org.kde.KWin.ScreenShot2.xml index 1c7011c453..65911c65a3 100644 --- a/src/effects/screenshot/org.kde.KWin.ScreenShot2.xml +++ b/src/effects/screenshot/org.kde.KWin.ScreenShot2.xml @@ -55,6 +55,9 @@ Available only if the image type is "raw" * "windowId" (s): The window id of the captured window. Available since version 4. + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. --> @@ -100,6 +103,9 @@ Available only if the image type is "raw" * "windowId" (s): The window id of the captured window. Available since version 4. + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. --> @@ -142,6 +148,9 @@ image type is "raw" * "format" (u): The image format, as defined in QImage::Format. Available only if the image type is "raw" + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. --> @@ -187,6 +196,9 @@ Available only if the image type is "raw" * "screen" (s): The name of the captured screen, same as QScreen::name(). Available since version 4 + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. --> @@ -230,6 +242,9 @@ Available only if the image type is "raw" * "screen" (s): The name of the captured screen, same as QScreen::name(). Available since version 4 + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. --> @@ -268,6 +283,9 @@ image type is "raw" * "format" (u): The image format, as defined in QImage::Format. Available only if the image type is "raw" + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. The following results get returned when taking a window screenshot: @@ -319,6 +337,9 @@ image type is "raw" * "format" (u): The image format, as defined in QImage::Format. Available only if the image type is "raw" + * "scale" (d): The ratio between the native size and the logical + size of the contents, corresponds to QImage::devicePixelRatio(). + Available since version 4. --> diff --git a/src/effects/screenshot/screenshotdbusinterface2.cpp b/src/effects/screenshot/screenshotdbusinterface2.cpp index dbc40ba843..3c43f49b7d 100644 --- a/src/effects/screenshot/screenshotdbusinterface2.cpp +++ b/src/effects/screenshot/screenshotdbusinterface2.cpp @@ -284,6 +284,7 @@ void ScreenShotSinkPipe2::flush(const QImage &image, const QVariantMap &attribut results.insert(QStringLiteral("width"), quint32(image.width())); results.insert(QStringLiteral("height"), quint32(image.height())); results.insert(QStringLiteral("stride"), quint32(image.bytesPerLine())); + results.insert(QStringLiteral("scale"), double(image.devicePixelRatio())); QDBusConnection::sessionBus().send(m_replyMessage.createReply(results)); QtConcurrent::run([fileDescriptor = std::move(m_fileDescriptor), image]() mutable {