YaLTeR / wl-clipboard-rs

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

Can not copy some text #35

Open Zesko opened 1 year ago

Zesko commented 1 year ago
  1. Use KDE Plasma 5.27.4 Wayland on any Arch based distros
  2. Install micro or gvim
  3. Create a new bash script
    
    #!/usr/bin/env bash

SERVICE_NAME="test.service"


4. Open `vim` or `micro` this script.
4. Select all text.
5. Try copying it and pasting it into another text editor e.g. **Kate**, but it does not work.

This is **wl-clipboard-rs** 0.7.0 which has issue copying this text, but no issue copying other text on KDE Wayland

**wl-clipboard** has no issue. (However, it has another [problem](https://github.com/bugaevc/wl-clipboard/issues/149): it hangs **micro** when Klipper (KDE clipboard) is empty.)
YaLTeR commented 1 year ago

Hey, does it work if you call wl-clipboard-rs manually rather than through vim/micro? If so, could you please attach WAYLAND_DEBUG=1 logs when the problem happens, and of the same wl-clipboard invocation which works?

Zesko commented 1 year ago

does it work if you call wl-clipboard-rs manually rather than through vim/micro?

It still does not work.

If so, could you please attach WAYLAND_DEBUG=1 logs when the problem happens

The log is here:

Copy this text has this issue:

#!/usr/bin/env bash

SERVICE_NAME="test.service"

Please can you copy this text if you reproduce the same issue?

$ WAYLAND_DEBUG=1 wl-copy < test.txt

```sh [1681028295.225027] -> wl_display@1.get_registry(2) [1681028295.225038] -> wl_display@1.sync(3) [1681028295.227198] <- wl_display@1.delete_id(3) [1681028295.227204] <- wl_registry@2.global(1, "wl_compositor", 5) [1681028295.227224] <- wl_registry@2.global(3, "zwp_tablet_manager_v2", 1) [1681028295.227246] <- wl_registry@2.global(4, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1) [1681028295.227279] <- wl_registry@2.global(6, "xdg_wm_base", 4) [1681028295.227296] <- wl_registry@2.global(7, "zwlr_layer_shell_v1", 3) [1681028295.227335] <- wl_registry@2.global(8, "zxdg_decoration_manager_v1", 1) [1681028295.227360] <- wl_registry@2.global(9, "wp_viewporter", 1) [1681028295.227377] <- wl_registry@2.global(10, "wp_fractional_scale_manager_v1", 1) [1681028295.227404] <- wl_registry@2.global(11, "wl_shm", 1) [1681028295.227420] <- wl_registry@2.global(12, "wl_seat", 8) [1681028295.227438] -> wl_registry@2.bind(12, "wl_seat", 8, 4) [1681028295.227459] <- wl_registry@2.global(13, "zwp_pointer_gestures_v1", 3) [1681028295.227481] <- wl_registry@2.global(14, "zwp_pointer_constraints_v1", 1) [1681028295.227506] <- wl_registry@2.global(15, "zwp_relative_pointer_manager_v1", 1) [1681028295.227534] <- wl_registry@2.global(16, "wl_data_device_manager", 3) [1681028295.227554] <- wl_registry@2.global(17, "zwlr_data_control_manager_v1", 2) [1681028295.227579] <- wl_registry@2.global(18, "zwp_primary_selection_device_manager_v1", 1) [1681028295.227611] <- wl_registry@2.global(19, "org_kde_kwin_idle", 1) [1681028295.227633] <- wl_registry@2.global(20, "zwp_idle_inhibit_manager_v1", 1) [1681028295.227662] <- wl_registry@2.global(21, "ext_idle_notifier_v1", 1) [1681028295.227682] <- wl_registry@2.global(22, "org_kde_plasma_shell", 8) [1681028295.227701] <- wl_registry@2.global(23, "org_kde_kwin_appmenu_manager", 1) [1681028295.227727] <- wl_registry@2.global(24, "org_kde_kwin_server_decoration_palette_manager", 1) [1681028295.227759] <- wl_registry@2.global(26, "org_kde_plasma_virtual_desktop_management", 2) [1681028295.227791] <- wl_registry@2.global(28, "org_kde_kwin_shadow_manager", 2) [1681028295.227813] <- wl_registry@2.global(29, "org_kde_kwin_dpms_manager", 1) [1681028295.227834] <- wl_registry@2.global(30, "org_kde_kwin_server_decoration_manager", 1) [1681028295.227866] <- wl_registry@2.global(31, "kde_output_management_v2", 3) [1681028295.227899] <- wl_registry@2.global(32, "zxdg_output_manager_v1", 3) [1681028295.227924] <- wl_registry@2.global(33, "wl_subcompositor", 1) [1681028295.227942] <- wl_registry@2.global(34, "zxdg_exporter_v2", 1) [1681028295.227963] <- wl_registry@2.global(35, "zxdg_importer_v2", 1) [1681028295.227982] <- wl_registry@2.global(38, "xdg_activation_v1", 1) [1681028295.228003] <- wl_registry@2.global(40, "wp_content_type_manager_v1", 1) [1681028295.228027] <- wl_registry@2.global(41, "wp_tearing_control_manager_v1", 1) [1681028295.228055] <- wl_registry@2.global(43, "wl_drm", 2) [1681028295.228070] <- wl_registry@2.global(44, "zwp_linux_dmabuf_v1", 4) [1681028295.228090] <- wl_registry@2.global(46, "kde_output_device_v2", 2) [1681028295.228110] <- wl_registry@2.global(47, "kde_output_device_v2", 2) [1681028295.228132] <- wl_registry@2.global(48, "wl_output", 4) [1681028295.228148] <- wl_registry@2.global(49, "wl_output", 4) [1681028295.228168] <- wl_registry@2.global(50, "wp_drm_lease_device_v1", 1) [1681028295.228193] <- wl_registry@2.global(51, "kde_output_order_v1", 1) [1681028295.228213] <- wl_registry@2.global(52, "zwp_text_input_manager_v1", 1) [1681028295.228237] <- wl_registry@2.global(53, "zwp_text_input_manager_v2", 1) [1681028295.228264] <- wl_registry@2.global(54, "zwp_text_input_manager_v3", 1) [1681028295.228285] <- wl_registry@2.global(56, "org_kde_kwin_slide_manager", 1) [1681028295.228307] <- wl_callback@3.done(1295) [1681028295.228317] -> wl_registry@2.bind(17, "zwlr_data_control_manager_v1", 1, 3) [1681028295.228344] -> zwlr_data_control_manager_v1@3.get_data_device(5, 4) [1681028295.228355] -> wl_display@1.sync(6) [1681028295.228478] <- wl_display@1.delete_id(6) [1681028295.228500] <- wl_seat@4.capabilities(7) [1681028295.228515] <- wl_seat@4.name("") [1681028295.228537] <- zwlr_data_control_device_v1@5.data_offer(4278190080) [1681028295.228556] <- zwlr_data_control_offer_v1@4278190080.offer("text/html") [1681028295.228588] <- zwlr_data_control_offer_v1@4278190080.offer("STRING") [1681028295.228608] <- zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [1681028295.228648] <- zwlr_data_control_offer_v1@4278190080.offer("TEXT") [1681028295.228671] <- zwlr_data_control_offer_v1@4278190080.offer("UTF8_STRING") [1681028295.228698] <- zwlr_data_control_offer_v1@4278190080.offer("text/plain") [1681028295.228723] <- zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [1681028295.228753] <- zwlr_data_control_device_v1@5.selection(4278190080) [1681028295.228762] <- wl_callback@6.done(1295) [1681028295.230260] -> zwlr_data_control_manager_v1@3.create_data_source(6) [1681028295.230269] -> zwlr_data_control_source_v1@6.offer("application/x-shellscript") [1681028295.230282] -> zwlr_data_control_device_v1@5.set_selection(6) [1681028295.230422] <- zwlr_data_control_device_v1@5.data_offer(4278190081) [1681028295.230441] <- zwlr_data_control_offer_v1@4278190081.offer("application/x-shellscript") [1681028295.230468] <- zwlr_data_control_device_v1@5.selection(4278190081) ```

VS.

Copying other text has no issue:

SERVICE_NAME="test.service"
$ WAYLAND_DEBUG=1 wl-copy < test.txt

```sh [1681028580.224614] -> wl_display@1.get_registry(2) [1681028580.224625] -> wl_display@1.sync(3) [1681028580.226635] <- wl_display@1.delete_id(3) [1681028580.226641] <- wl_registry@2.global(1, "wl_compositor", 5) [1681028580.226655] <- wl_registry@2.global(3, "zwp_tablet_manager_v2", 1) [1681028580.226673] <- wl_registry@2.global(4, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1) [1681028580.226694] <- wl_registry@2.global(6, "xdg_wm_base", 4) [1681028580.226707] <- wl_registry@2.global(7, "zwlr_layer_shell_v1", 3) [1681028580.226723] <- wl_registry@2.global(8, "zxdg_decoration_manager_v1", 1) [1681028580.226744] <- wl_registry@2.global(9, "wp_viewporter", 1) [1681028580.226757] <- wl_registry@2.global(10, "wp_fractional_scale_manager_v1", 1) [1681028580.226779] <- wl_registry@2.global(11, "wl_shm", 1) [1681028580.226789] <- wl_registry@2.global(12, "wl_seat", 8) [1681028580.226801] -> wl_registry@2.bind(12, "wl_seat", 8, 4) [1681028580.226817] <- wl_registry@2.global(13, "zwp_pointer_gestures_v1", 3) [1681028580.226836] <- wl_registry@2.global(14, "zwp_pointer_constraints_v1", 1) [1681028580.226854] <- wl_registry@2.global(15, "zwp_relative_pointer_manager_v1", 1) [1681028580.226876] <- wl_registry@2.global(16, "wl_data_device_manager", 3) [1681028580.226896] <- wl_registry@2.global(17, "zwlr_data_control_manager_v1", 2) [1681028580.226921] <- wl_registry@2.global(18, "zwp_primary_selection_device_manager_v1", 1) [1681028580.226946] <- wl_registry@2.global(19, "org_kde_kwin_idle", 1) [1681028580.226962] <- wl_registry@2.global(20, "zwp_idle_inhibit_manager_v1", 1) [1681028580.226982] <- wl_registry@2.global(21, "ext_idle_notifier_v1", 1) [1681028580.226998] <- wl_registry@2.global(22, "org_kde_plasma_shell", 8) [1681028580.227017] <- wl_registry@2.global(23, "org_kde_kwin_appmenu_manager", 1) [1681028580.227038] <- wl_registry@2.global(24, "org_kde_kwin_server_decoration_palette_manager", 1) [1681028580.227065] <- wl_registry@2.global(26, "org_kde_plasma_virtual_desktop_management", 2) [1681028580.227091] <- wl_registry@2.global(28, "org_kde_kwin_shadow_manager", 2) [1681028580.227113] <- wl_registry@2.global(29, "org_kde_kwin_dpms_manager", 1) [1681028580.227131] <- wl_registry@2.global(30, "org_kde_kwin_server_decoration_manager", 1) [1681028580.227156] <- wl_registry@2.global(31, "kde_output_management_v2", 3) [1681028580.227177] <- wl_registry@2.global(32, "zxdg_output_manager_v1", 3) [1681028580.227195] <- wl_registry@2.global(33, "wl_subcompositor", 1) [1681028580.227211] <- wl_registry@2.global(34, "zxdg_exporter_v2", 1) [1681028580.227227] <- wl_registry@2.global(35, "zxdg_importer_v2", 1) [1681028580.227242] <- wl_registry@2.global(38, "xdg_activation_v1", 1) [1681028580.227257] <- wl_registry@2.global(40, "wp_content_type_manager_v1", 1) [1681028580.227278] <- wl_registry@2.global(41, "wp_tearing_control_manager_v1", 1) [1681028580.227298] <- wl_registry@2.global(43, "wl_drm", 2) [1681028580.227311] <- wl_registry@2.global(44, "zwp_linux_dmabuf_v1", 4) [1681028580.227325] <- wl_registry@2.global(46, "kde_output_device_v2", 2) [1681028580.227342] <- wl_registry@2.global(47, "kde_output_device_v2", 2) [1681028580.227358] <- wl_registry@2.global(48, "wl_output", 4) [1681028580.227374] <- wl_registry@2.global(49, "wl_output", 4) [1681028580.227389] <- wl_registry@2.global(50, "wp_drm_lease_device_v1", 1) [1681028580.227409] <- wl_registry@2.global(51, "kde_output_order_v1", 1) [1681028580.227433] <- wl_registry@2.global(52, "zwp_text_input_manager_v1", 1) [1681028580.227458] <- wl_registry@2.global(53, "zwp_text_input_manager_v2", 1) [1681028580.227480] <- wl_registry@2.global(54, "zwp_text_input_manager_v3", 1) [1681028580.227499] <- wl_registry@2.global(56, "org_kde_kwin_slide_manager", 1) [1681028580.227517] <- wl_callback@3.done(2109) [1681028580.227526] -> wl_registry@2.bind(17, "zwlr_data_control_manager_v1", 1, 3) [1681028580.227550] -> zwlr_data_control_manager_v1@3.get_data_device(5, 4) [1681028580.227557] -> wl_display@1.sync(6) [1681028580.227589] <- wl_display@1.delete_id(6) [1681028580.227596] <- wl_seat@4.capabilities(7) [1681028580.227604] <- wl_seat@4.name("") [1681028580.227612] <- wl_callback@6.done(2109) [1681028580.229034] -> zwlr_data_control_manager_v1@3.create_data_source(6) [1681028580.229045] -> zwlr_data_control_source_v1@6.offer("UTF8_STRING") [1681028580.229058] -> zwlr_data_control_source_v1@6.offer("text/plain") [1681028580.229073] -> zwlr_data_control_source_v1@6.offer("text/plain;charset=utf-8") [1681028580.229089] -> zwlr_data_control_source_v1@6.offer("TEXT") [1681028580.229099] -> zwlr_data_control_source_v1@6.offer("STRING") [1681028580.229109] -> zwlr_data_control_device_v1@5.set_selection(6) [1681028580.229354] <- zwlr_data_control_device_v1⏎ @5.data_offer(4278190080) [1681028580.229379] <- zwlr_data_control_offer_v1@4278190080.offer("UTF8_STRING") [1681028580.229404] <- zwlr_data_control_offer_v1@4278190080.offer("text/plain") [1681028580.229431] <- zwlr_data_control_offer_v1@4278190080.offer("text/plain;charset=utf-8") [1681028580.229464] <- zwlr_data_control_offer_v1@4278190080.offer("TEXT") [1681028580.229482] <- zwlr_data_control_offer_v1@4278190080.offer("STRING") [1681028580.229497] <- zwlr_data_control_device_v1@5.selection(4278190080) [1681028580.229607] <- zwlr_data_control_source_v1@6.send("text/plain;charset=utf-8", 4) [1681028580.230435] <- zwlr_data_control_source_v1@6.send("text/plain;charset=utf-8", 4) ```

bugaevc commented 1 year ago

application/x-shellscript

wl-clipboard treats all types ending with script as textual, so that explains it.

We hope to eventually switch to using file(1) to determine the textuality (is that a word?) in a more reliable way, see https://github.com/bugaevc/wl-clipboard/pull/97.

YaLTeR commented 1 year ago

Thanks, yeah, that would be the reason.

We hope to eventually switch to using file(1) to determine the textuality (is that a word?) in a more reliable way, see https://github.com/bugaevc/wl-clipboard/pull/97.

How does file determine the charset though? If it's just reading a few first bytes then for wl-clipboard-rs it makes sense to just do that manually without relying on file I think.