quicksettings/screenshot: Fix shell not showing up and update dbus

Use hide-caller-windows from https://invent.kde.org/plasma/kwin/-/merge_requests/8832 to avoid plasmashell being hidden (by https://invent.kde.org/plasma/kwin/-/merge_requests/8338).
This commit is contained in:
Devin Lin 2026-02-17 20:13:35 -05:00
parent c8be7be5cb
commit 014e2076ec
2 changed files with 175 additions and 0 deletions

View file

@ -14,6 +14,13 @@
a screen, or a window. a screen, or a window.
--> -->
<interface name="org.kde.KWin.ScreenShot2"> <interface name="org.kde.KWin.ScreenShot2">
<!--
Version:
API version.
-->
<property name="Version" type="u" access="read"/>
<!-- <!--
CaptureWindow: CaptureWindow:
@handle: The unique handle that identified the window @handle: The unique handle that identified the window
@ -31,6 +38,8 @@
Defaults to false Defaults to false
* "include-decoration" (b): Whether the decoration should be included. * "include-decoration" (b): Whether the decoration should be included.
Defaults to false Defaults to false
* "include-shadow" (b): Whether the shadow should be included.
Defaults to true
* "native-resolution" (b): Whether the screenshot should be in * "native-resolution" (b): Whether the screenshot should be in
native size. Defaults to false native size. Defaults to false
@ -46,6 +55,11 @@
image type is "raw" image type is "raw"
* "format" (u): The image format, as defined in QImage::Format. * "format" (u): The image format, as defined in QImage::Format.
Available only if the image type is "raw" 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.
--> -->
<method name="CaptureWindow"> <method name="CaptureWindow">
<arg name="handle" type="s" direction="in" /> <arg name="handle" type="s" direction="in" />
@ -56,6 +70,55 @@
<arg name="results" type="a{sv}" direction="out" /> <arg name="results" type="a{sv}" direction="out" />
</method> </method>
<!--
CaptureActiveWindow:
@options: Optional vardict with screenshot options
@pipe: The pipe file descriptor where the screenshot will be written
Take a screenshot of the active window. The application that
requests the screenshot must have the org.kde.KWin.ScreenShot2
interface listed in the X-KDE-DBUS-Restricted-Interfaces desktop
file entry.
Supported since version 2.
Available @options include:
* "include-cursor" (b): Whether the cursor should be included.
Defaults to false
* "include-decoration" (b): Whether the decoration should be included.
Defaults to false
* "include-shadow" (b): Whether the shadow should be included.
Defaults to true
* "native-resolution" (b): Whether the screenshot should be in
native size. Defaults to false
The following results get returned via the @results vardict:
* "type" (s): The type of the image written to the pipe. Currently,
the only supported type is "raw"
* "width" (u): The width of the image. Available only if the image
type is "raw"
* "height" (u): The height of the image. Available only if the image
type is "raw"
* "stride" (u): The number of bytes per row. Available only if the
image type is "raw"
* "format" (u): The image format, as defined in QImage::Format.
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.
-->
<method name="CaptureActiveWindow">
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap" />
<arg name="options" type="a{sv}" direction="in" />
<arg name="pipe" type="h" direction="in" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" />
<arg name="results" type="a{sv}" direction="out" />
</method>
<!-- <!--
CaptureArea: CaptureArea:
@x: The x coordinate of the upper left corner of the area @x: The x coordinate of the upper left corner of the area
@ -89,6 +152,9 @@
image type is "raw" image type is "raw"
* "format" (u): The image format, as defined in QImage::Format. * "format" (u): The image format, as defined in QImage::Format.
Available only if the image type is "raw" 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.
--> -->
<method name="CaptureArea"> <method name="CaptureArea">
<arg name="x" type="i" direction="in" /> <arg name="x" type="i" direction="in" />
@ -132,6 +198,11 @@
image type is "raw" image type is "raw"
* "format" (u): The image format, as defined in QImage::Format. * "format" (u): The image format, as defined in QImage::Format.
Available only if the image type is "raw" 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.
--> -->
<method name="CaptureScreen"> <method name="CaptureScreen">
<arg name="name" type="s" direction="in" /> <arg name="name" type="s" direction="in" />
@ -142,6 +213,51 @@
<arg name="results" type="a{sv}" direction="out" /> <arg name="results" type="a{sv}" direction="out" />
</method> </method>
<!--
CaptureActiveScreen:
@options: Optional vardict with screenshot options
@pipe: The pipe file descriptor where the screenshot will be written
Take a screenshot of the active monitor. The application that
requests the screenshot must have the org.kde.KWin.ScreenShot2
interface listed in the X-KDE-DBUS-Restricted-Interfaces desktop file
entry.
Supported since version 2.
Available @options include:
* "include-cursor" (b): Whether the cursor should be included.
Defaults to false
* "native-resolution" (b): Whether the screenshot should be in
native size. Defaults to false
The following results get returned via the @results vardict:
* "type" (s): The type of the image written to the pipe. Currently,
the only supported type is "raw"
* "width" (u): The width of the image. Available only if the image
type is "raw"
* "height" (u): The height of the image. Available only if the image
type is "raw"
* "stride" (u): The number of bytes per row. Available only if the
image type is "raw"
* "format" (u): The image format, as defined in QImage::Format.
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.
-->
<method name="CaptureActiveScreen">
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap" />
<arg name="options" type="a{sv}" direction="in" />
<arg name="pipe" type="h" direction="in" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" />
<arg name="results" type="a{sv}" direction="out" />
</method>
<!-- <!--
CaptureInteractive: CaptureInteractive:
@kind: 0 - window, 1 - screen @kind: 0 - window, 1 - screen
@ -156,6 +272,8 @@
Defaults to false Defaults to false
* "include-decoration" (b): Whether the decoration should be included. * "include-decoration" (b): Whether the decoration should be included.
Defaults to false Defaults to false
* "include-shadow" (b): Whether the shadow should be included.
Defaults to true
* "native-resolution" (b): Whether the screenshot should be in * "native-resolution" (b): Whether the screenshot should be in
native size. Defaults to false native size. Defaults to false
@ -171,6 +289,19 @@
image type is "raw" image type is "raw"
* "format" (u): The image format, as defined in QImage::Format. * "format" (u): The image format, as defined in QImage::Format.
Available only if the image type is "raw" 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:
* "windowId" (s): The window id of the captured window. Available
since version 4
The following results get returned when taking a monitor screenshot:
* "screen" (s): The name of the captured screen, same as QScreen::name().
Available since version 4
--> -->
<method name="CaptureInteractive"> <method name="CaptureInteractive">
<arg name="kind" type="u" direction="in" /> <arg name="kind" type="u" direction="in" />
@ -180,5 +311,48 @@
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" /> <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" />
<arg name="results" type="a{sv}" direction="out" /> <arg name="results" type="a{sv}" direction="out" />
</method> </method>
<!--
CaptureWorkspace:
@options: Optional vardict with screenshot options
@pipe: The pipe file descriptor where the screenshot will be written
Take a screenshot of the workspace, i.e. all screens united. The
application that requests the screenshot must have the org.kde.KWin.ScreenShot2
interface listed in the X-KDE-DBUS-Restricted-Interfaces desktop file
entry.
Supported since version 3.
Available @options include:
* "include-cursor" (b): Whether the cursor should be included.
Defaults to false
* "native-resolution" (b): Whether the screenshot should be in
native size. Defaults to false
The following results get returned via the @results vardict:
* "type" (s): The type of the image written to the pipe. Currently,
the only supported type is "raw"
* "width" (u): The width of the image. Available only if the image
type is "raw"
* "height" (u): The height of the image. Available only if the image
type is "raw"
* "stride" (u): The number of bytes per row. Available only if the
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.
-->
<method name="CaptureWorkspace">
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap" />
<arg name="options" type="a{sv}" direction="in" />
<arg name="pipe" type="h" direction="in" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" />
<arg name="results" type="a{sv}" direction="out" />
</method>
</interface> </interface>
</node> </node>

View file

@ -88,6 +88,7 @@ void ScreenShotUtil::takeScreenShot()
// We don't have access to the ScreenPool so we'll just take the first screen // We don't have access to the ScreenPool so we'll just take the first screen
QVariantMap options; QVariantMap options;
options.insert(QStringLiteral("native-resolution"), true); options.insert(QStringLiteral("native-resolution"), true);
options.insert(QStringLiteral("hide-caller-windows"), false);
auto pendingCall = m_screenshotInterface->CaptureScreen(qGuiApp->screens().constFirst()->name(), options, QDBusUnixFileDescriptor(lPipeFds[1])); auto pendingCall = m_screenshotInterface->CaptureScreen(qGuiApp->screens().constFirst()->name(), options, QDBusUnixFileDescriptor(lPipeFds[1]));
close(lPipeFds[1]); close(lPipeFds[1]);