-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XWayland Clipboard Proxy #454
Comments
It is not a perfect solution, but until clipboard is better handled in Wayland it would do: we could have a text area accessible from the gnome menu where we paste the text we want and it can be sent to the clipboard on the phone. At the same time, the phone clipboard is sent to desktop and the text area content is updated with it. |
I had two thoughts about how to do this. The first was just to run a mini XWayland process that used stdin/stdout pipes to communicate clipboard changes with the daemon. So in GSConnect there would just be a singleton with a signal and a few methods. The second was something that occurred to me when I found out they built keypress simulation into gnome-shell's Clutter to make their new OSK work in Wayland. Since StClipboard also works in Wayland I thought it would be possible to export those both over DBus. That would kind of kill two birds with one stone, but the DBus interface would have to be always-on, and probably when Atspi works on Wayland we'd want to revert back anyways.
Probably this wouldn't be a bad idea anyways, since it would be a more accessible way to sync clipboard content on demand. I guess I just worry about UI clutter and we'd need a way to inject the StEntry since the device menu is built from a GMenu. |
I like your second idea, although I don't know if dbus messaging will be fast enough for mouse and keyboard events. |
That's good point, although direct DBus connection is an option and still easier than writing some pipe protocol. On the other hand, I just saw this MR although haven't had time to really look at it (https://gitlab.gnome.org/GNOME/mutter/merge_requests/320). I'm guessing because of how things like clipboards work in Wayland they don't have a choice but to build it into the compositor/mutter. |
I came across the new release of the Sway compositor for Wayland, and I saw that they included this library for interacting with the clipboard: https://github.com/bugaevc/wl-clipboard Not sure if it'll work with Gnome, but it might be worth a look. |
@ArtyomZorin I looked at
|
Ugh, so I was looking into StClipboard since it seems to work in Wayland by way of some XWayland hackery, but unfortunately it doesn't have any signals like GtkClipboard. Dealing with this in GJS means polling in gnome-shell's main thread, which is what Clipboard Indicator does. Although a idle GSource with low priority probably shouldn't be intrusive, we then have to pass it over DBus as well. Presumably GtkClipboard should actually work in Wayland (from what I can tell), however in Gtk/Gdk4 the clipboard seems to have been moved to Gdk. I might have a look into GtkClipboard, because I'd much rather this get fixed upstream before they stop doing releases of Gtk3, but I really have no idea what the plan is. |
I'm not sure if I mentioned this previously, apologies if I'm being redundant. In my testing, CopyQ appeared to be fully-functional (or, at least, has the full functionality GSConnect would require in order to do clipboard sync, meaning selection/copy buffer capture and update) when it's running as an XWayland application. But...
|
I had a look at the source of CopyQ, but it looks like it only really supports X11, and probably just works on XWayland because of GNOME using a little hidden GDK window. |
This idea has not really been discussed yet:
IMHO, I very much like this as a workaround. |
It's a less ideal solution, for the reason that it will require arbitrarily injecting a text entry into the menu. Currently, the whole device menu is exported over DBus using GMenu, which is very convenient and all done using pre-existing C code. We simply add and remove menu items and submenus in the service and they're picked up by the shell extension. I have a branch somewhere with a partially working menu editor, which will be necessary if we ever want users to have the option of customizing the menu items. If we start injecting elements into the menu in this way, that will become a lot less feasible to do. It's also not very HIG, and complaints about that before was why I removed the circular battery graphic. More generally, the problem with Wayland and KDE Connect is that it presumes access to desktop resources that often directly contradicts to the application isolation that Wayland presumes. I think the simplest way to fix it for now is just to run a small XWayland process and pipe the changes back and forth, I just haven't had time to do it. |
Since GtkClipboard isn't working well under Wayland, we start a small subprocess and force the GdkX11 backend. We then pipe clipboard changes back and forth over stdin/stdout. closes #454
I threw together a quick fix sitting in the xwayland-clipboard branch. If something goes wrong, and it might, it will probably go very wrong and could spin up your CPU and use enough memory to start swapping out. Here's a build for |
I'm still running X on my daily-driver (Nvidia card, binary kernel module), but I'll fire up my laptop w/ F30/Wayland later and give it a try. Been a while since I've visited a coal mine... |
Hmm. I installed the zipfile version you provided, @andyholmes, but something's being weird... I paired the phone to my laptop no problem, and everything looks normal (and enabled) from that end. But in the phone I'm only getting a tiny subset of plugins even AVAILABLE. And clipboard sync isn't one of them. Everything is normal with the pairing to my desktop, still. Maybe I need to unpair/disconnect the other machine? |
Nope, same thing with the other computer unpaired. I've also restarted on both sides of the connection. I'll grab a debug log of the handshaking and pairing process when I get a chance. |
Since GtkClipboard isn't working well under Wayland, we start a small subprocess and force the GdkX11 backend. We then pipe clipboard changes back and forth over stdin/stdout. closes #454
Oops, sorry. There was a logic inversion mistake in there. Here's an updated ZIP: |
@andyholmes
The All in all, looks good so far! Very cool. |
I'd consider 40MB for a simply clipboard proxy service pretty much… 🤔 |
For me it was only about 9MB RSS, which I think is ~5 for the gjs engine and ~4 for the libraries, was yours really about 40? |
Yeah, well... that's what ETA: Looks like |
Since GtkClipboard isn't working well under Wayland, we start a small subprocess and force the GdkX11 backend. We then pipe clipboard changes back and forth over stdin/stdout. closes #454
I've merged this in, since I haven't heard anyone complain. I'll spin up a RC sometime soon and see how that goes. |
@andyholmes for GNOME 3.34 you would be able to use https://gitlab.gnome.org/GNOME/mutter/merge_requests/320 |
Holy crap, that MR has a longer history than the city of Rome! 😆 All resolved in the end, I guess. (Though that note from the initial comment, "but it may work on both x11 and wayland" — emphasis mine — is vaguely concerning. Maybe I'm just reading it too literally.) |
I tried the new v25-rc1 prerelease on my Ubuntu 18.04 LTS with GNOME 3.28 Wayland session. And guess what, clipboard still doesn't work! 😞 When copying from desktop, I get a {} on phone and nothing otherwise. |
@HEXcube Hmm. I tested on 3.32.2... possibly 3.28 is missing some functionality. Can you do this test, for starters? Open a terminal, and inside it run: $ cd ~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/components/
$ ./xclipboard It'll just sit there doing nothing (possibly after a version warning message or two), but then after that, anytime you copy text it should be instantly output to the terminal where For example: $ ~/.local/.../gsconnect@andyholmes.github.io/service/components/xclipboard
Gjs-Message: 05:06:49.193: JS WARNING: [./xclipboard 5]: Requiring Gdk but it ha
s 2 versions available; use imports.gi.versions to pick one
anytime you copy text&gave the replacement zip a quick spin, inside it run:
```sh#Text typed into GEdit can be copied^C (...As I went around this page and copied some selected text a few times.) Reopening for possible 3.28 compatibility issues. |
Oops. For the email readers, I messed up my commands in the previous message. The correct commands would be: $ cd ~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/components/
$ ./xclipboard (Forgot the all-important |
* clarify process pipe names * watch stderr for errors * cleanup `xclipboard` and comments addresses #454
Here's an updated Zip with a little more corner-cases covered: |
This is what I got on v25-rc1: ./xclipboard
Gtk-Message: 16:17:48.052: Failed to load module "appmenu-gtk-module"
Gtk-Message: 16:17:48.054: Failed to load module "appmenu-gtk-module"
dointerminal�outputL(...As I went around this page and copied some selected text a few times.) |
With the new v25-rc2: ~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/components/xclipboard
Gtk-Message: 16:32:18.035: Failed to load module "appmenu-gtk-module"
Gtk-Message: 16:32:18.036: Failed to load module "appmenu-gtk-module"
email re� output to the terMxclipboard is running. Then just hit Ctrl+c in the terminal when you're done.Qsit there doing nothing (possibly after a version warning message or two), but th |
When I tried this zip, got this output: ~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/components/xclipboard
Gtk-Message: 18:05:39.682: Failed to load module "appmenu-gtk-module"
Gtk-Message: 18:05:39.683: Failed to load module "appmenu-gtk-module"
output to th� (possibly after a version warning message or two), but then after that, anytime you copy text it should be instantly output to the terminal where xclipboard is running. Then just hit Ctrl+c in the terminal when you're doneUt'll just sit there doing nothing (possibly after a version warning message or two), |
The |
Does generating a support log provide any information as to what's happening? |
Got this: Output of xclipboard: ~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/components/xclipboard
Gtk-Message: 18:30:53.829: Failed to load module "appmenu-gtk-module"
Gtk-Message: 18:30:53.831: Failed to load module "appmenu-gtk-module"
`It'll just sit there doing nothing (possibly after a version warning message or two), but then a4 output to the terminal where xclipboard is running.9 Then just hit Ctrl+c in the terminal when you're done. |
From your log it seems like the
|
I got this from GNOME Logs:
It wasn't displayed immediately after GSconnect activation though. I couldn't find any other references to xclipboard, even after trying multiple copy paste attempts on my notebook and connected phone. |
I don't know if it's related, but gnome-terminal-server outputs this message 😕 :
|
This is because in GDK's Wayland backend the function I'm guessing the error is not showing up in the log because it's a debug message, which won't be logged until Generate Support Log is activated after GSConnect starts. Give this Zip a shot and see if there are any errors during around GSConnect startup: |
After testing this new zip, I got some error messages on log. These are some relevant parts of the log: |
GitHub isn't showing preview for these files, so I thought I'll paste them here directly:
|
Hi, sorry there haven't been any updates on this issue - it's still targetted for v25. @HEXcube So far I think you're the only tester having problems, and you seem to be the only one on 3.28. Could you please try this ZIP here: gsconnect@andyholmes.github.io.zip In particular these lines here: I believe these lines are the proper way to account for +/- 3.28 behaviour, but I haven't had a copy of 3.28 running in awhile. If the clipboard still doesn't work, think this may be the spot causing problems and might need your help with a little debugging. |
I'm marking this as closed since the feature was released in v25. Please open a new issue if problems still occur with v25. |
@andyholmes This bug is now fixed! 😃 I tested the latest update of GSconnect from GNOME Extensions site. I'm running GSConnect v26 now on Ubuntu 18.04 LTS with GNOME 3.28 Wayland session and clipboard sync works smoothly. Thanks a lot! 😘 |
The pull request #422 disabled Clipboard Sharing for Wayland in order to remove the GSConnect dependency on XWayland. This bug is intended to track a possible alternative implementation.
Steps to reproduce the behavior:
Expected behavior to be determined
System Details:
See the pull request linked above for additional details/discussion
The text was updated successfully, but these errors were encountered: