From 383ad27b5964c8ff14330bf702c68d1f9928f96f Mon Sep 17 00:00:00 2001 From: Prajna Sariputra Date: Sun, 28 Jan 2024 14:00:05 +0000 Subject: [PATCH] [plugins/mousepad]: Add support for the persistence feature of the RemoteDesktop portal This allows us to avoid asking the user for permission for remote control on Wayland every time kdeconnectd is restarted for whatever reason (for example logging out or rebooting), at least in theory. The idea is that the SelectDevices call now also accepts a restore token, and if the user grants permission to persist a restore token will be returned in the response of the Start call. Currently https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/merge_requests/265 is required for this to work at all with Plasma 6, and even then persistence only works in the same session (for example if I restart kdeconnectd then I only get the notification instead of the permissions prompt), if I reboot the system then the token gets invalidated and the permissions dialog appears again, not sure if the issue is with what I'm doing here or if that's a bug in the portal. Things that need to be checked: - What happens if the portal implementation only has v1 of the protocol and not v2 (the one with persistence)? - In particular what happens for the SelectDevices call if a restore token is given despite the portal not supporting it - Seems fine with xdg-desktop-portal 1.14.4 at least - For the Start call we'll need to handle the case of the user denying the persistence request anyway - Where and how should the restore token be stored? - ~~I used KConfig just so I have something to test, but the restore token isn't really a setting~~ - Updated to use `KSharedConfig::openStateConfig` - Most of KDE Connect's settings and data appear to be for each connected device - The device name is a global setting, but it's implemented using QSettings rather than KConfig, and currently only setName and getName is exposed in `core/kdeconnectconfig.h` BUG: 479013 --- .../org.freedesktop.portal.RemoteDesktop.xml | 155 ++++++++++++++++-- plugins/mousepad/waylandremoteinput.cpp | 30 +++- plugins/mousepad/waylandremoteinput.h | 1 + 3 files changed, 174 insertions(+), 12 deletions(-) diff --git a/interfaces/systeminterfaces/org.freedesktop.portal.RemoteDesktop.xml b/interfaces/systeminterfaces/org.freedesktop.portal.RemoteDesktop.xml index 054ea2b63..c60d45d4f 100644 --- a/interfaces/systeminterfaces/org.freedesktop.portal.RemoteDesktop.xml +++ b/interfaces/systeminterfaces/org.freedesktop.portal.RemoteDesktop.xml @@ -1,14 +1,17 @@ @@ -17,22 +20,34 @@ @@ -108,10 +161,12 @@ @parent_window: Identifier for the application window, see Common Conventions @options: Vardict with optional further information @handle: Object path for the #org.freedesktop.portal.Request object representing this call + Start the remote desktop session. This will typically result in the portal presenting a dialog letting the user select what to share, including devices and optionally screen content if screen cast sources was selected. + Supported keys in the @options vardict include: @@ -123,6 +178,7 @@ + The following results get returned via the #org.freedesktop.portal.Request::Response signal: @@ -132,7 +188,26 @@ A bitmask of the devices selected by the user. + + clipboard_enabled b + + A boolean for whether the clipboard was enabled ('true') or not ('false'). + See the #org.freedesktop.portal.Clipboard documentation for more information. + Since version 2. + + + + restore_token s + + The restore token. This token is a single use token that can later + be used to restore a session. See + org.freedesktop.portal.RemoteDesktop.SelectDevices() for details. + + This response option was added in version 2 of this interface. + + + If a screen cast source was selected, the results of the #org.freedesktop.portal.ScreenCast.Start response signal may be included. @@ -150,6 +225,7 @@ @options: Vardict with optional further information @dx: Relative movement on the x axis @dy: Relative movement on the y axis + Notify about a new relative pointer motion event. The (dx, dy) vector represents the new pointer position in the streams logical coordinate space. @@ -168,6 +244,7 @@ @stream: The PipeWire stream node the coordinate is relative to @x: Pointer motion x coordinate @y: Pointer motion y coordinate + Notify about a new absolute pointer motion event. The (x, y) position represents the new pointer position in the streams logical coordinate space (see the logical_size stream property in @@ -187,9 +264,12 @@ @options: Vardict with optional further information @button: The pointer button was pressed or released @state: The new state of the button + The pointer button is encoded according to Linux Evdev button codes. + May only be called if POINTER access was provided after starting the session. + Available button states: 0: Released @@ -209,11 +289,14 @@ @options: Vardict with optional further information @dx: Relative axis movement on the x axis @dy: Relative axis movement on the y axis + The axis movement from a 'smooth scroll' device, such as a touchpad. When applicable, the size of the motion delta should be equivalent to the motion vector of a pointer motion done using the same advice. + May only be called if POINTER access was provided after starting the session. + Supported keys in the @options vardict include: @@ -239,8 +322,10 @@ @options: Vardict with optional further information @axis: The axis that was scrolled @steps: The number of steps scrolled + May only be called if POINTER access was provided after starting the session. + Available axes: 0: Vertical scroll @@ -259,10 +344,12 @@ @session_handle: Object path for the #org.freedesktop.portal.Session object @options: Vardict with optional further information @keycode: Keyboard code that was pressed or released - @state: New state of keyboard keysym + @state: New state of keyboard keycode + May only be called if KEYBOARD access was provided after starting the session. - Available keyboard keysym states: + + Available keyboard keycode states: 0: Released 1: Pressed @@ -281,8 +368,10 @@ @options: Vardict with optional further information @keysym: Keyboard symbol that was pressed or released @state: New state of keyboard keysym + May only be called if KEYBOARD access was provided after starting the session. + Available keyboard keysym states: 0: Released @@ -304,8 +393,10 @@ @slot: Touch slot where touch point appeared @x: Touch down x coordinate @y: Touch down y coordinate + May only be called if TOUCHSCREEN access was provided after starting the session. + Notify about a new touch down event. The (x, y) position represents the new touch point position in the streams logical coordinate space (see the logical_size stream property in @@ -328,8 +419,10 @@ @slot: Touch slot where touch point appeared @x: Touch motion x coordinate @y: Touch motion y coordinate + May only be called if TOUCHSCREEN access was provided after starting the session. + Notify about a new touch motion event. The (x, y) position represents where the touch point position in the streams logical coordinate space moved (see the logical_size stream property in @@ -349,8 +442,10 @@ @session_handle: Object path for the #org.freedesktop.portal.Session object @options: Vardict with optional further information @slot: Touch slot where touch point appeared + May only be called if TOUCHSCREEN access was provided after starting the session. + Notify about a new touch up event. --> @@ -359,9 +454,47 @@ + + + + + + + + + + +