microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.12k stars 303 forks source link

select to copy does not work over the bondaries of WSLg [PRIMARY selection support] #642

Open Brettdah opened 2 years ago

Brettdah commented 2 years ago

Environment

Windows build number: 10.0.22000.0
Your Distribution version: 20.04
Your WSLg version: 1.0.26

Steps to reproduce

On WSL distro :

Actual behavior

I have to, right click and on this menu click copy too actualy copy the text over windows applications.

Expected behavior

Thank you :)

hideyukn88 commented 2 years ago

@Brettdah, thanks for reporting the issue. Yes, currently PRIMARY selection in X11 is not shared with outside of X world, that said, it is not just cross WSLg boundary to Windows side, but it is also not shared with Wayland native application. Thanks!

Brettdah commented 2 years ago

Hi I found that to copy from Windows to linux I can do it with CTRL + Shift + V A good explaination about that : here

Michael-Sinz commented 2 years ago

The problem I have is that the X11 clipboard and the Windows clipboard in WSL2 on Windows 11 do not interoperate.

In Windows 10 I had to run the VcXsrv X11 server on Windows in order to get X11 applications to display on Windows. This does have the clipboard connected such that I can highlight in one xterm window and paste in a Windows window (and the reverse too)

With Windows 11 and the built-in X11 support, this does not work.

hideyukn88 commented 2 years ago

@Michael-Sinz, currently WSLg only support text (utf-8) for X11 and Windows clipboard exchange, or do you observe the problem with text? For wayland-native applications, WSLg does support limited HTML and bitmap formats in addition to text. Thanks!

Michael-Sinz commented 2 years ago

The problem is with simple ascii text - but it is on the primary selection which seems to be the problem.

ianzhang366 commented 2 years ago

I'm having the same issue as well.

Copy from x11 app to windows works fine. Copy from windows to x11 won't work.

With VcXsrv(PRIMARY selection enabled) + wsl, copy between windows and x11 app works fine.

I wonder if there's a workaround to config the wslg to make sure x11 app and window clipboard know each other.

tmottershead commented 1 year ago

In Windows 11 + wslg, copying some text from an Eclipse editor, running under linux, displaying in Wayland/Windows and right-click pasting into Ubuntu shell in Windows Terminal Preview doesn't work. Pasting the same into a Windows app (Notepad++) does work. Re-coping the text from the Windows app and then pasting into Windows Terminal Preview does work.

PS C:> wsl -v
WSL version: 0.70.4.0
Kernel version: 5.15.68.1
WSLg version: 1.0.45
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.819

Windows Terminal Preview Version: 1.16.2642.0
michael-jedlicka commented 1 year ago

I had the same issue after upgrading, used to work before but then stopped after Windows upgrade to 11. I found that in terminator the option to "Copy on Selection" was not selected which resolved my issue

Michael-Sinz commented 1 year ago

I have been successfully using the following in my system. Within WSL, I run a build of autocutsel (https://github.com/sigmike/autocutsel) with the following:

others=$(ps a | grep auto[c]utsel | awk '{print $1}')
[[ -n ${others} ]] && kill -9 ${others} 2>/dev/null
$(dirname $0)/autocutsel -s CLIPBOARD &
$(dirname $0)/autocutsel -s PRIMARY   -buttonup &

The reason I don't use the -fork option is that I want it connected to the console/window/process for lifetime management and for any error message output that may happen. (This is a window I normally run minimized but if there are problems, I can check on it - it has some other bits in it too)

I also have it kill prior versions just in case (easiest way to restart it all is to run the script again)

This syncs the clipboard with the primary selection but will only update the primary selection on button up (mainly to prevent clipboard change storms)

I have been using this for over 6 months now and it has served me well.

smprather commented 1 year ago

I have been successfully using the following in my system. Within WSL, I run a build of autocutsel (https://github.com/sigmike/autocutsel) with the following: I have been using this for over 6 months now and it has served me well.

Thanks @Michael-Sinz . This is the only thing that has worked for me so far! I have confirmed bi-directional operation with no glitches / down-sides so far.

FredSRichardson commented 11 months ago

I set up autocutsel as a user systemd process and it seems to launch correctly. The problem I'm having is that copy/paste still doesn't work reliably to/from an xterm. It does seem to work to/from my X11 emacs though.

Michael-Sinz commented 4 months ago

I have been successfully using the following in my system. Within WSL, I run a build of autocutsel (https://github.com/sigmike/autocutsel) with the following:

others=$(ps a | grep auto[c]utsel | awk '{print $1}')
[[ -n ${others} ]] && kill -9 ${others} 2>/dev/null
$(dirname $0)/autocutsel -s CLIPBOARD &
$(dirname $0)/autocutsel -s PRIMARY   -buttonup &

The reason I don't use the -fork option is that I want it connected to the console/window/process for lifetime management and for any error message output that may happen. (This is a window I normally run minimized but if there are problems, I can check on it - it has some other bits in it too)

I also have it kill prior versions just in case (easiest way to restart it all is to run the script again)

This syncs the clipboard with the primary selection but will only update the primary selection on button up (mainly to prevent clipboard change storms)

I have been using this for over 6 months now and it has served me well.

One problem is that sometimes it will not copy a second time in a given direction until you copy (does not need to paste) from the other side.

What I see is that I sometimes don't get a new item from the Linux rxvt/xterm window into Windows but after I select and copy into the clipboard something different on the Windows side I can again copy something new from the Linux side.

I have not had a chance to track down the problem - but I think it is an issue of who thinks who is up-to-date but it is easily worked around.

I still would want to have the X11 support built into Windows working better.

I have actually started switching back to https://github.com/marchaesen/vcxsrv (which has continued to work rather well, even on Windows 11 and WSL2, albeit you have to configure it in special ways)