andyholmes / valent

Connect, control and sync devices
https://valent.andyholmes.ca
Other
591 stars 19 forks source link

Clipboard adapter for Wayland environments (e.g. Sway) #624

Open Iss-in opened 8 months ago

Iss-in commented 8 months ago

Current Behavior

clipboard isnt being synced from pc to android until the valent window is focused via mouse.

Since im facing this issue on sway, this might only be related to sway/wlroots compositor behaviour specifically. i faced a similar issue with firefox where subtitles werent being updated when browser window wasnt focused, which is resolved by now.

linking that issue incase its of any help

https://bugzilla.mozilla.org/show_bug.cgi?id=1770429

Expected Behavior

clipboard should sync to android device the moment its changed.

Desktop

Other (please specify)

Other Desktop

Sway/Wlroots

Operating System

Aech

Installed from

Distribution Package

Version

1.0.0.alpha

Devices

KDE Connect (Android), Valent (Desktop Linux)

Plugins

clipboard

Logs

20:57:26.5143                       GLib-GIO:    DEBUG: _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for ‘gsettings-backend’
20:57:26.5150                       GLib-GIO:    DEBUG: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
20:57:26.8288                       GLib-GIO:    DEBUG: _g_io_module_get_default: Found default implementation gvfs (GDaemonVfs) for ‘gio-vfs’
20:57:26.8859                       GLib-GIO:    DEBUG: _g_io_module_get_default: Found default implementation gnutls (GTlsBackendGnutls) for ‘gio-tls-backend’
20:57:26.8864                       GLib-GIO:    DEBUG: Failed to initialize portal (GNetworkMonitorPortal) for gio-network-monitor: Not using portals
20:57:26.8866                       GLib-GIO:    DEBUG: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
20:57:26.8873                       GLib-GIO:    DEBUG: _g_io_module_get_default: Found default implementation networkmanager (GNetworkMonitorNM) for ‘gio-network-monitor’
20:57:34.2562                 valent-battery:    DEBUG: ValentBattery: not a battery
20:57:34.3243            valent-mpris-player:    DEBUG: valent_mpris_player_get_position(): GDBus.Error:org.freedesktop.DBus.Error.NotSupported: /org/mpris/MediaPlayer2.org.mpris.MediaPlayer2.Player Position is not supported
20:57:41.7540        valent-clipboard-plugin:    DEBUG: valent_clipboard_read_text_cb(): text not available
20:57:41.7546        valent-clipboard-plugin:    DEBUG: valent_clipboard_read_text_cb(): text not available

Screenshots

No response

andyholmes commented 8 months ago

That's correct, without a better option, Valent will fallback to the GDK-based clipboard which requires the application to gain focus to acquire the clipboard selection.

For better support, someone will have to contribute a ClipboardAdapter, maybe backed by something like wl-clipboard. Ideally it would be done in code, but a subprocess would be acceptable, too.

orowith2os commented 7 months ago

It may be preferable to use the RemoteDesktop portal, and by that path, request access to the Clipboard portal, rather than relying on Wayland protocols here. It's not intended behavior (in the Wayland protocol) to allow any unfocused Wayland client (yes, that includes wl-clipboard, a shell script) to manipulate the clipboard.