YaLTeR / wl-clipboard-rs

A safe Rust crate for working with the Wayland clipboard.
Apache License 2.0
223 stars 16 forks source link

Implement hack/workaround for missing wlr-data-control #39

Open jarod opened 8 months ago

jarod commented 8 months ago
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.10
Release:        23.10
Codename:       mantic

$ echo "$XDG_SESSION_TYPE"
wayland

$ wl-copy --version
wl-copy 0.8.0

$ echo "test" | WAYLAND_DEBUG=1 ./wl-copy
[1699667777.010009] -> wl_display@1.get_registry (wl_registry@2)
[1699667777.010185] -> wl_display@1.sync (wl_callback@3)
[1699667777.010765] <- wl_registry@2.global, (1, Some("wl_compositor"), 5)
[1699667777.011061] <- wl_registry@2.global, (2, Some("wl_drm"), 2)
[1699667777.011369] <- wl_registry@2.global, (3, Some("wl_shm"), 1)
[1699667777.011578] <- wl_registry@2.global, (4, Some("wl_output"), 4)
[1699667777.011810] <- wl_registry@2.global, (5, Some("zxdg_output_manager_v1"), 3)
[1699667777.012101] <- wl_registry@2.global, (6, Some("wl_data_device_manager"), 3)
[1699667777.012395] <- wl_registry@2.global, (7, Some("zwp_primary_selection_device_manager_v1"), 1)
[1699667777.012876] <- wl_registry@2.global, (8, Some("wl_subcompositor"), 1)
[1699667777.013146] <- wl_registry@2.global, (9, Some("xdg_wm_base"), 6)
[1699667777.013386] <- wl_registry@2.global, (10, Some("gtk_shell1"), 5)
[1699667777.013611] <- wl_registry@2.global, (11, Some("wp_viewporter"), 1)
[1699667777.013843] <- wl_registry@2.global, (12, Some("wp_fractional_scale_manager_v1"), 1)
[1699667777.014208] <- wl_registry@2.global, (13, Some("zwp_pointer_gestures_v1"), 3)
[1699667777.014514] <- wl_registry@2.global, (14, Some("zwp_tablet_manager_v2"), 1)
[1699667777.014815] <- wl_registry@2.global, (15, Some("wl_seat"), 8)
[1699667777.015022] <- wl_registry@2.global, (16, Some("zwp_relative_pointer_manager_v1"), 1)
[1699667777.015646] <- wl_registry@2.global, (17, Some("zwp_pointer_constraints_v1"), 1)
[1699667777.016015] <- wl_registry@2.global, (18, Some("zxdg_exporter_v2"), 1)
[1699667777.016283] <- wl_registry@2.global, (19, Some("zxdg_importer_v2"), 1)
[1699667777.016544] <- wl_registry@2.global, (20, Some("zxdg_exporter_v1"), 1)
[1699667777.016811] <- wl_registry@2.global, (21, Some("zxdg_importer_v1"), 1)
[1699667777.017076] <- wl_registry@2.global, (22, Some("zwp_linux_dmabuf_v1"), 4)
[1699667777.017357] <- wl_registry@2.global, (23, Some("wp_single_pixel_buffer_manager_v1"), 1)
[1699667777.017741] <- wl_registry@2.global, (24, Some("zwp_keyboard_shortcuts_inhibit_manager_v1"), 1)
[1699667777.018166] <- wl_registry@2.global, (25, Some("zwp_text_input_manager_v3"), 1)
[1699667777.018511] <- wl_registry@2.global, (26, Some("wp_presentation"), 1)
[1699667777.018768] <- wl_registry@2.global, (27, Some("xdg_activation_v1"), 1)
[1699667777.019035] <- wl_registry@2.global, (28, Some("zwp_idle_inhibit_manager_v1"), 1)
[1699667777.019426] <- wl_callback@3.done, (2857)
[1699667777.019544] <- wl_display@1.delete_id, (3)
Error: A required Wayland protocol (zwlr_data_control_manager_v1 version 1) is not supported by the compositor

while wl-clipboard 2.2.0 works fine on the same system.

YaLTeR commented 8 months ago

I'm guessing this is GNOME? It is expected that wl-clipboard-rs doesn't work there since mutter doesn't implement the wlr-data-control protocol. The way wl-clipboard works is with a hack where it spawns a 1x1 window for a splitsecond, then relies on the compositor to give it focus automatically, and uses the standard Wayland clipboard protocol. This hack is not implemented in wl-clipboard-rs.

jarod commented 8 months ago

I'm guessing this is GNOME? It is expected that wl-clipboard-rs doesn't work there since mutter doesn't implement the wlr-data-control protocol. The way wl-clipboard works is with a hack where it spawns a 1x1 window for a splitsecond, then relies on the compositor to give it focus automatically, and uses the standard Wayland clipboard protocol. This hack is not implemented in wl-clipboard-rs.

Thanks for explaining the cause. My machine is running on Ubuntu with GNOME. Is there a plan to implement the hack for wl-clipboard-rs? it will making wl-clipboard-rs a more useful tool.

YaLTeR commented 8 months ago

No concrete plans.

thiagokokada commented 6 months ago

Same issue with Crostini (Linux VMs in ChromeOS), and yes, wl-clipboard works fine there.