GemTalk / JadeiteForPharo

IDE for GemStone Smalltalk application development in Pharo using Rowan code management
MIT License
1 stars 1 forks source link

Copy code from JfP to linux window or JfD #41

Open ericwinger opened 1 year ago

ericwinger commented 1 year ago

Need to be able to easily copy code from a pharo code browser and paste into a linux window or JfD window. Not sure why this just doesn't work.

ericwinger commented 1 year ago

I reproduced Dale's bug - roughly characterized by the inability to copy out of Pharo into a JfD windows environment. My reproduction case didn't need a JfD window. I could see the problem copying to WordPad on Windows 10. Note - I could not get any text to copy from Pharo to Windows 7 Wordpad.

Reproduction case:

I've traced the copy/paste code going into and coming out of the FFI call to the SDL2 library used by Pharo to do clipboard operations. The smalltalk code is accurate both ways. That implies a bug in the SDL2 library.

This may be a bug in the SDL2 library. The SDL2 library installed by Pharo seems quite out of date - 2.0.10. Latest release is 2.28.5 (https://github.com/libsdl-org/SDL/releases)

ewinger@uffda:~/Pharo/vms/110-x64/lib$ dpkg -l *libsdl*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version        Architecture Description
+++-===================-==============-============-=================================
un  libsdl-1.3-0        <none>         <none>       (no description available)
ii  libsdl2-2.0-0:amd64 2.0.10+dfsg1-3 amd64        Simple DirectMedia Layer

Installed version from Pharo:

ewinger@uffda:~/Pharo/vms/110-x64/lib$ ls -lart | grep SDL
-rwxr-xr-x 1 ewinger smalltalk  9314480 May  9  2023 libSDL2.so*
-rwxr-xr-x 1 ewinger smalltalk  9314480 May  9  2023 libSDL2-2.0.so.0.2400.1*
-rwxr-xr-x 1 ewinger smalltalk  9314480 May  9  2023 libSDL2-2.0.so.0*
ewinger@uffda:~/Pharo/vms/110-x64/lib$ pwd
/home/ewinger/Pharo/vms/110-x64/lib
dalehenrich commented 1 year ago

While you are in the area, does it make sense to look into enable the linux feature that puts selected text into the X past buffer? Like most linux applications do... Just a thought ...

ericwinger commented 11 months ago

FWIW - I renamed the libSDL2.so library so it wouldn't be found by Pharo but the problem still exists.

ericwinger commented 9 months ago

Another note in passing. Copying from Pharo and pasting into a linux vim window is ok (and vice versa). Host is running both vim window and pharo image.

image

ericwinger commented 6 days ago

I did a little more experimentation copying from linux to windows. A few notes:

tukanos commented 6 days ago

Just adding my 2c with these questions.
@ericwinger

ericwinger commented 5 days ago

Hi @tukanos, Thanks for chiming in.

Are you using Wayland on your Ubuntu (this version allows both protocols)?

No - (from /etc/gdm3/custom.conf)

...
[daemon]
# Uncomment the line below to force the login screen to use Xorg
WaylandEnable=false
...
Is your Windows instance in a VM or other way around?

Windows 10 - VM on same Ubuntu host.

How exactly do you copy and paste (e.g. using keyboard shortcuts and/or mouse)?

When I open the copy buffer in Windows, I don't actually have to do the paste to see if the copy worked. From Pharo, I've used both the context menu copy item and Ctrl-C. Behavior is consistently bizarre.

tukanos commented 4 days ago

HI @ericwinger ,

I would be happy if my contribution could help you diagnose the issue. I have today tried the copy workflow you mentioned above.

My configuration (which differs from yours):

I have tried these combinations (copy & paste): Linux Pharo 12 <=> Win WordPad Win Pharo 12 <=> Linux Pharo 12 Gnome's Text Editor <=> Win WordPad Gnomes' Text Editor <=> Win Pharo 12

For me every single combination worked flawlessly. I have tried them multiple times.

Here is a screenshot of the clipboard: Screenshot From 2024-11-21 11-29-43

That brings me to think there is an issue either with your zazu (QEMU) and Windows clipboard integration or maybe some weird in the clipboard libraries.

P.S. Out of curiosity. If you start the ancient xclipboard application, and leave it open, during your tests when pasting. Does that help with the pasting?

ericwinger commented 4 days ago

Thanks for the input. From your list, there is one that consistently "kind-of" doesn't work.

Copy from linux Pharo 12 into Windows

I can copy from linux Pharo 12 once and see it in the Windows clipboard buffer. However, subsequent copies don't show up in the Windows clipboard buffer.

P.S. Out of curiosity. If you start the ancient xclipboard application, and leave it open, during your tests when pasting. Does that help with the pasting?

Interestingly enough, when I turn on xclipboard, copying from linux Pharo 12 does seem to consistently show up in the Windows paste buffer.

tukanos commented 4 days ago

Interestingly enough, when I turn on xclipboard, copying from linux Pharo 12 does seem to consistently show up in the Windows paste buffer.

I thought that might be the case. I have had a X application which would show exactly the same symptoms as you have described. The only "workaround" was to run xclipboard. This was most probably connected to XWayland code, which was fixed few months ago. The copy&paste for the X application started working without any issues.

tukanos commented 3 days ago

Sigh, I have retested it today with the above mentioned X application. It suffers again from the same behavior. I wish knew what was causing it.

ericwinger commented 3 days ago

It's bizarre, isn't it. Did running xclipboard in the background make a difference like it seems to have for me?

tukanos commented 1 day ago

It's bizarre, isn't it. Did running xclipboard in the background make a difference like it seems to have for me?

It is definitely bizarre. I was using xclipboard in the background, as workaround, for months. At some time, I'm not using the X application everyday, the issue was fixed. Now it appears to re-emerge again.

I thought the bug maybe somewhere in the XWayland layer. Since you are using Xorg only, it brings me to an idea that there is bug somewhere deep within the clipboard internals of X11 which seem to be rather complex.

janvrany commented 20 hours ago

Hi folks, accidental maintainer of that "X application that shows the same symptoms" here :-)

Not sure if it helps, but I did some digging. Looking deep into Mutter source code it looks that at least under Wayland / XWayland the issue may be that Mutter only reacts to XFixesSelection* events, ignoring the other X clipboard protocols. Since the "X application" does not use XFixes, Mutter does not notice something was copied into X clipboard so nothing is "synchronized" to Wayland clipboard (and same may be with Windows clipboard, but I have no idea). Since xclipboard intercepts X clipboard, it may re-offer the clipboard using XFixes protocol as well which would explain why it works. Looking into xclipboard source did not reveal anything useful yet, though. Just guessing, though.

I not fully understand the issue yet - it has been a long time since I was doing X11 programming and all my X11 books are in different country - but if I manage to fix it, I'll get back here.