CopyQ icon indicating copy to clipboard operation
CopyQ copied to clipboard

copyq fails to paste into wayland native windows and pastes to previously acitive X-window (Ubuntu 22.04)

Open mikedlr opened this issue 2 years ago • 13 comments

Describe the bug When attempting to type into a terminal window by selecting an item with the enter key, CopyQ pastes to the window directly behind. This applies both to terminator and to gnome terminal

To Reproduce

  1. switch to a web browser window
  2. select a terminal window and type into it
  3. pop up copyq with a keyboard shortcut (command "copyq show")
  4. select item
  5. press enter key

Actual behavior

copyq minimises and the terminal window is sent one layer behind, the typing of the selected item happens into the window behind (e.g. the web browser)

Expected behavior

I expected copyq to paste into the terminal window as happened for me in previous versions of Ubuntu.

Screenshots can create video if needed - there's not really a single screenshot to show this

Version, OS and Environment (Get details from copyq version command if possible.)

  • Application Version 6.0.1
  • OS Ubuntu 22.04.1 LTS
  • Wayland with Gnome 42.4 with default install setup

Additional context Copyq package info from apt: Package: copyq Version: 6.0.1-1 Priority: optional Section: universe/utils Origin: Ubuntu Maintainer: Ubuntu Developers [email protected] Original-Maintainer: Boyuan Yang [email protected] Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 5,305 kB Depends: libc6 (>= 2.34), libgcc-s1 (>= 3.3.1), libkf5notifications5 (>= 5.69.0), libqt5core5a (>= 5.15.1), libqt5gui5 (>= 5.14.1) | libqt5gui5-gles (>= 5.14.1), libqt5network5 (>= 5.15.1), libqt5qml5 (>= 5.12.2), libqt5svg5 (>= 5.6.0~beta), libqt5waylandclient5 (>= 5.10.1), libqt5widgets5 (>= 5.15.1), libqt5x11extras5 (>= 5.6.0), libstdc++6 (>= 11), libwayland-client0 (>= 1.9.91), libx11-6, libxtst6 Recommends: copyq-plugins (= 6.0.1-1) Suggests: copyq-doc Homepage: https://hluk.github.io/CopyQ/ Download-Size: 1,507 kB APT-Manual-Installed: yes APT-Sources: http://gb.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages Description: Advanced clipboard manager with editing and scripting features CopyQ monitors system clipboard and saves its content in customized tabs. Saved clipboard can be later copied and pasted directly into any application.

mikedlr avatar Oct 10 '22 09:10 mikedlr

Updated to latest version of copyq via the PPA (6.3.2~jammy)

~This no longer selects the wrong window so the result is changed~

Actual behavior

Copyq goes into the background as it should and the terminal window remains on front, however nothing is pasted into the terminal window.

Package info

Package: copyq Version: 6.3.2~jammy Priority: optional Section: utils Maintainer: Lukas Holecek [email protected] Installed-Size: 7,636 kB

mikedlr avatar Oct 10 '22 10:10 mikedlr

Correction, after the upgrade, initially behavior is as in the second comment, after a while, though it reverts to the same behavior as initially.

mikedlr avatar Oct 10 '22 10:10 mikedlr

I confirm this issue.

CopyQ Clipboard Manager 6.3.2~jammy Qt: 5.15.3 KNotifications: 5.92.0 Compiler: GCC Arch: x86_64-little_endian-lp64 OS: Ubuntu 22.04.1 LTS

cioma avatar Oct 14 '22 12:10 cioma

Pasting does not work in Wayland apps: https://copyq.readthedocs.io/en/latest/known-issues.html#on-linux-global-shortcuts-pasting-or-clipboard-monitoring-does-not-work

Pasting to a wrong window sounds like some strange problems with X11-compatibility layer (XWayland). Not sure if I can do anything about that.

hluk avatar Nov 06 '22 09:11 hluk

Issue opened at Freedesktop.org for Xwayland - https://gitlab.freedesktop.org/xorg/xserver/-/issues/1405 - I have provided a link back to this issue so please leave it open in case someone wants to comment.

mikedlr avatar Nov 07 '22 11:11 mikedlr

It is worth noting that CopyQ tries to remember any newly active window whenever it receives an X event. If you switch to a Wayland native app, CopyQ (if it is running as X11 app) would probably think that any previously active X11 app still has focus. Before pasting, CopyQ tries to make sure that the last window is active. This can be disabled by turning off "Focus last window" in "History" config tab.

hluk avatar Nov 07 '22 13:11 hluk

Switching off that option does not really appear to change the behaviour.

mikedlr avatar Nov 07 '22 13:11 mikedlr

I forgot how this works. :)

CopyQ will try to activate the window anyway if it is not active after an interval. The option "Focus last window" only makes the activation/raise action trigger right away.

hluk avatar Nov 07 '22 18:11 hluk

The common factor between terminator and gnome terminal turns out to be the fact that they are both wayland native applications. See also discussion in the freedesktop bug

mikedlr avatar Nov 29 '22 10:11 mikedlr

I have been using Terminator in Kali Linux (my Kali is using XFCE, so I am quite sure that it is not running Wayland) and have not noticed this issue. I do also have a two laptops running Pop!_OS (based on Ubuntu 22.04 and Gnome, but it is a System76 modified Gnome). I do not believe that I am seeing this issue there but will have to check.

I am on one of those Pop!_OS laptops right now and am running CopyQ 6.3.2 and copied a command from Terminator and then focused on the web browser window and then back to Terminator, used a hotkey to open CopyQ and then used the enter key to paste and I did not have this issue.

A bit of Googling tells me that Pop!_OS does not appear to enable Wayland. I checked the /etc/gdm3/custom.conf file and WaylandEnable=false on this laptop.

I do not believe that I set this. Pretty sure that it is the default, but would need to check the other laptop configuration.

robertstrom avatar Nov 29 '22 13:11 robertstrom

@mikedlr - I read you post on freedesktop and, this may or may not be something that you're willing to do, I would suggest that you try Pop!_OS. It's Ubuntu and it's a really slick variation of Ubuntu. I've been using it for a couple of years now and it is my go to daily Linux distro. If you're willing to do that then your problem may be solved and you will get the benefit of using an outstanding Linux distro ;-)

robertstrom avatar Nov 29 '22 13:11 robertstrom

@robertstrom thanks for the suggestion, but I think I can achieve pretty much the same effect by just logging into a pure X (non Wayland) session on Ubuntu.

mikedlr avatar Nov 29 '22 14:11 mikedlr

Switching off that option does not really appear to change the behaviour.

I experience the same bug in ubuntu 22.04 with wayland, but switching the focus option off does partly solve the problem (I end up having to hit crtl-v after the copyq window closes), I did have to close and reopen copyq for the changes to take effect

Correction: actually does not consistently work, sometimes it gets back to the switch focus to last window behavior

louisgag avatar Jul 19 '23 18:07 louisgag