hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.26k stars 430 forks source link

Wayland: No clipboard content #1243

Open tuxedotje opened 4 years ago

tuxedotje commented 4 years ago

copyq copyq copyq

Describe the bug A clear and concise description of what the bug is. copy some text from different sources, try to read the content of clipboard in CopyQ, nothing. To Reproduce Steps to reproduce the behavior:

  1. Go to '.some text..'
  2. Click on 'ctrl c...'
  3. Scroll down to '...'
  4. See nothing in copyq

Expected behavior A clear and concise description of what you expected to happen. content from clipboard in copyq Screenshots If applicable, add screenshots to help explain your problem. CopyQ Clipboard Manager v3.9.2 Version, OS and Environment Fedora 31 beta

Additional context Add any other context about the problem here. on trying to start copyq in terminal " Warning: CopyQ server is already running."

hluk commented 4 years ago

What do you mean by "See nothing in copyq"? Can you be more specific?

tuxedotje commented 4 years ago

Today copyq will not start, I would like to use it. I remove copyq from PC (Fedora 31 beta) and install new. try to open copyq. Click on icon and nothing happens. type copyq in terminal message: Warning: CopyQ server is already running. GUI of copyq opens when I type in terminal It says <0> EMPTY I copy a text (select and CTRL-C) after that in GUI of copyq I open Show Clipboard Content, a new window opens. without any content.

hluk commented 4 years ago

If CopyQ is running, you can run copyq show to show the main window.

Run copyq logs|tail -50 to list recent logs. There might be some warnings or errors.

tuxedotje commented 4 years ago

copyq logs|tail -50 CopyQ Warning [2019-10-28 06:44:45.887] : Failed to retrieve selection data (try 3/3) CopyQ ERROR [2019-10-28 06:44:47.314] : Null data in selection. CopyQ Warning [2019-10-28 06:44:47.314] : Failed to retrieve selection data (try 3/3) CopyQ Warning [2019-10-28 06:46:31.757] : CopyQ server is already running. CopyQ ERROR [2019-10-28 06:47:18.197] : Null data in selection. CopyQ Warning [2019-10-28 06:47:18.197] : Failed to retrieve selection data (try 1/3) CopyQ ERROR [2019-10-28 06:47:26.896] : Null data in selection. CopyQ Warning [2019-10-28 06:47:26.896] : Failed to retrieve selection data (try 1/3) CopyQ ERROR [2019-10-28 06:47:26.896] : Null data in selection. CopyQ Warning [2019-10-28 06:47:26.896] : Failed to retrieve selection data (try 2/3) CopyQ ERROR [2019-10-28 06:47:27.848] : Null data in selection. CopyQ Warning [2019-10-28 06:47:27.848] : Failed to retrieve selection data (try 3/3) CopyQ ERROR [2019-10-28 06:47:29.275] : Null data in selection. CopyQ Warning [2019-10-28 06:47:29.275] : Failed to retrieve selection data (try 3/3) CopyQ Warning [2019-10-28 06:50:47.966] : CopyQ server is already running. CopyQ Warning [2019-10-28 06:51:35.903] : CopyQ server is already running. CopyQ Warning [2019-10-28 08:13:05.015] : CopyQ server is already running. CopyQ ERROR [2019-10-28 14:32:34.037] : Null data in selection. CopyQ Warning [2019-10-28 14:32:34.038] : Failed to retrieve selection data (try 1/3) CopyQ ERROR [2019-10-28 14:32:34.038] : Null data in selection. CopyQ Warning [2019-10-28 14:32:34.038] : Failed to retrieve selection data (try 2/3) CopyQ ERROR [2019-10-28 14:32:35.090] : Null data in selection. CopyQ Warning [2019-10-28 14:32:35.090] : Failed to retrieve selection data (try 3/3) CopyQ ERROR [2019-10-28 14:32:36.667] : Null data in selection. CopyQ Warning [2019-10-28 14:32:36.667] : Failed to retrieve selection data (try 3/3) CopyQ Warning [2019-10-28 14:32:40.413] : CopyQ server is already running. CopyQ Warning [2019-10-28 14:33:47.563] : CopyQ server is already running. CopyQ Warning [2019-10-28 14:34:19.202] : CopyQ server is already running. CopyQ Warning [2019-10-28 14:34:38.191] : CopyQ server is already running. CopyQ ERROR [2019-10-28 20:57:15.940] : QtFatal: The Wayland connection broke. Did the Wayland compositor die? (:0, ) CopyQ ERROR [2019-10-29 14:21:08.766] : Null data in selection. CopyQ Warning [2019-10-29 14:21:08.774] : Failed to retrieve selection data (try 1/3) CopyQ ERROR [2019-10-29 14:21:08.774] : Null data in selection. CopyQ Warning [2019-10-29 14:21:08.774] : Failed to retrieve selection data (try 2/3) CopyQ ERROR [2019-10-29 14:21:09.726] : Null data in selection. CopyQ Warning [2019-10-29 14:21:09.726] : Failed to retrieve selection data (try 3/3) CopyQ ERROR [2019-10-29 14:21:11.208] : Null data in selection. CopyQ Warning [2019-10-29 14:21:11.208] : Failed to retrieve selection data (try 3/3) CopyQ Warning [2019-10-29 14:22:05.585] : CopyQ server is already running. CopyQ ERROR [2019-10-29 16:06:02.923] : QtFatal: The Wayland connection broke. Did the Wayland compositor die? (:0, ) CopyQ ERROR [2019-10-30 15:02:50.435] : Null data in selection. CopyQ Warning [2019-10-30 15:02:50.435] : Failed to retrieve selection data (try 1/3) CopyQ ERROR [2019-10-30 15:02:50.435] : Null data in selection. CopyQ Warning [2019-10-30 15:02:50.436] : Failed to retrieve selection data (try 2/3) CopyQ ERROR [2019-10-30 15:02:51.386] : Null data in selection. CopyQ Warning [2019-10-30 15:02:51.386] : Failed to retrieve selection data (try 3/3) CopyQ ERROR [2019-10-30 15:02:52.812] : Null data in selection. CopyQ Warning [2019-10-30 15:02:52.812] : Failed to retrieve selection data (try 3/3) CopyQ Warning [2019-10-30 15:03:29.529] : CopyQ server is already running. CopyQ Warning [2019-10-30 15:06:15.425] : CopyQ server is already running.

hluk commented 4 years ago

Looks like CopyQ cannot access clipboard for some reason -- or more specifically mouse selection. It seems you are running Wayland (as opposed to X11) and I thought it doesn't support selection.

You can try disabling all options under "Clipboard Manipulation" except "Store Clipboard" in CopyQ configuration:

image

rgarcia89 commented 4 years ago

That is unfortunately not working neither.

CopyQ Warning [2019-10-31 16:13:56.013] <Server-1796987>: Failed to set global shortcut "Ctrl+Shift+G" for command "Google".
CopyQ ERROR [2019-10-31 16:13:56.085] <monitorClipboard-1796997>: Null data in selection.
CopyQ Warning [2019-10-31 16:13:56.085] <monitorClipboard-1796997>: Failed to retrieve selection data (try 1/3)
CopyQ ERROR [2019-10-31 16:13:56.085] <monitorClipboard-1796997>: Null data in selection.
CopyQ Warning [2019-10-31 16:13:56.086] <monitorClipboard-1796997>: Failed to retrieve selection data (try 2/3)
CopyQ ERROR [2019-10-31 16:13:57.114] <monitorClipboard-1796997>: Null data in selection.
CopyQ Warning [2019-10-31 16:13:57.115] <monitorClipboard-1796997>: Failed to retrieve selection data (try 3/3)
CopyQ ERROR [2019-10-31 16:13:58.615] <monitorClipboard-1796997>: Null data in selection.
CopyQ Warning [2019-10-31 16:13:58.615] <monitorClipboard-1796997>: Failed to retrieve selection data (try 3/3)
CopyQ Warning [2019-10-31 16:14:44.884] <Server-1798041>: CopyQ server is already running.
CopyQ Warning [2019-10-31 16:15:22.008] <Server-1796987>: Failed to set global shortcut "Ctrl+Shift+G" for command "Google".
CopyQ ERROR [2019-10-31 16:15:22.069] <monitorClipboard-1798772>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:22.069] <monitorClipboard-1798772>: Failed to retrieve selection data (try 1/3)
CopyQ ERROR [2019-10-31 16:15:22.070] <monitorClipboard-1798772>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:22.070] <monitorClipboard-1798772>: Failed to retrieve selection data (try 2/3)
CopyQ ERROR [2019-10-31 16:15:23.122] <monitorClipboard-1798772>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:23.122] <monitorClipboard-1798772>: Failed to retrieve selection data (try 3/3)
CopyQ Warning [2019-10-31 16:15:23.673] <Server-1796987>: Failed to set global shortcut "Ctrl+Shift+G" for command "Google".
CopyQ ERROR [2019-10-31 16:15:23.790] <monitorClipboard-1798834>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:23.790] <monitorClipboard-1798834>: Failed to retrieve selection data (try 1/3)
CopyQ ERROR [2019-10-31 16:15:23.790] <monitorClipboard-1798834>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:23.790] <monitorClipboard-1798834>: Failed to retrieve selection data (try 2/3)
CopyQ ERROR [2019-10-31 16:15:24.742] <monitorClipboard-1798834>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:24.743] <monitorClipboard-1798834>: Failed to retrieve selection data (try 3/3)
CopyQ ERROR [2019-10-31 16:15:26.168] <monitorClipboard-1798834>: Null data in selection.
CopyQ Warning [2019-10-31 16:15:26.169] <monitorClipboard-1798834>: Failed to retrieve selection data (try 3/3)
hluk commented 4 years ago

Oh, sorry, I pasted wrong screenshot. The configuration to avoid checking mouse selection should be like this:

image

@rgarcia89 Can you please check again?

rgarcia89 commented 4 years ago

Doesn't work neither. It is also not able to set the shortcuts like you can see here

 Failed to set global shortcut "Ctrl+Shift+G" for command "Google".
hluk commented 4 years ago

It is also not able to set the shortcuts like you can see here

Setting global shortcuts in Wayland is not supported (not sure if they already have a generic API for it).

rgarcia89 commented 4 years ago

So this means that nothing of copyq is currently usable under fedora 31 and wayland... Thats really bad 🙈

hluk commented 4 years ago

So this means that nothing of copyq is currently usable under fedora 31 and wayland... Thats really bad see_no_evil

I'm going to update to F31 soon and see if Wayland is finally usable for me. I'll try to fix these issues while I'm at it. :)

hluk commented 4 years ago

OK, I've upgraded to F31.

Looks like it's not possible to access clipboard with Qt unless the window requesting the access is focused.

This is also somewhat related: Custom notifications (a "tooltip" window) gets focused when they pop up and it doesn't seem to be possible to show them without focus (I messed around with window attributes). Couple of other Qt applications are broken because they use some special window behaviors (e.g. smplayer cannot embed video player window, konsole doesn't show menus).

It could be a bug in Gnome.

Below is short snippet to test the clipboard access (uses PyQt5). If you click "Update" button it gets formats currently in clipboard. Clicking "Get" gets the selected format. You can select the format in combo box, but opening the combo list somehow breaks clipboard access so Get and Update buttons no longer work unless the window is deactivated and activated again.

#!/usr/bin/env python3
import sys

from PyQt5 import QtCore
from PyQt5 import QtGui
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)

def update_format_list(combo):
    combo.clear()
    data = app.clipboard().mimeData()
    for mime in data.formats():
        combo.addItem(mime)

def get_format(combo, label):
    mime = combo.currentText()
    data = app.clipboard().mimeData().data(mime)
    if mime.startswith('image'):
        image = QtGui.QImage.fromData(data)
        pixmap = QtGui.QPixmap.fromImage(image)
        label.setPixmap(pixmap)
    else:
        text = data.data().decode()
        label.setText(text)

combo = QtWidgets.QComboBox()
update_format_list(combo)

label = QtWidgets.QLabel()
label.setAlignment(QtCore.Qt.AlignCenter)

get_button = QtWidgets.QPushButton('&Get')
get_button.clicked.connect(lambda: get_format(combo, label))

update_button = QtWidgets.QPushButton('&Update')
update_button.clicked.connect(lambda: update_format_list(combo))

hlayout = QtWidgets.QHBoxLayout()
hlayout.addWidget(combo, stretch=1)
hlayout.addWidget(get_button)
hlayout.addWidget(update_button)

vlayout = QtWidgets.QVBoxLayout()
vlayout.addLayout(hlayout)
vlayout.addWidget(label)

window = QtWidgets.QWidget()
window.setLayout(vlayout)

window.show()
app.exec_()
hluk commented 4 years ago

Workaround is to set QT_QPA_PLATFORM environment variable and use Xwayland (xorg-x11-server-Xwayland fedora package) to handle X11 apps.

E.g. launch CopyQ with:

env QT_QPA_PLATFORM=xcb copyq

If CopyQ autostarts, you can change Exec=... line in ~/.config/autostart/copyq.desktop:

Exec=env QT_QPA_PLATFORM=xcb copyq
rgarcia89 commented 4 years ago

@hluk this way copied text is stored in copyq. The only thing not working right now is storing text selected by the mouse. Thanks figuring out that workaround

hluk commented 4 years ago

The only thing not working right now is storing text selected by the mouse.

@rgarcia89 Mouse selections should work only from other X11 apps. AFAIK, Wayland doesn't support them.

See also: https://wiki.gnome.org/Initiatives/Wayland/PrimarySelection

Spacewalker2 commented 3 years ago

I use Arch Linux with Sway. After the last update all the above described behavior happens here too now.

hhlp commented 3 years ago

if I launch in this way works:

E.g. launch CopyQ with:

env QT_QPA_PLATFORM=xcb copyq

if I add in desktop file doesn't works

Exec=env QT_QPA_PLATFORM=xcb copyq

fedora 33 any clue?

Regards.,

hluk commented 3 years ago

For Fedora (32 and 33), there is development package with much better Wayland support.

You can install the package using:

sudo dnf install 'dnf-command(copr)'
sudo dnf copr enable lholecek/copyq
sudo dnf install copyq
tigerjack commented 3 years ago

For Archlinux, the copyq-git package in the AUR works as expected.

123swk123 commented 1 year ago

assuming you installed to defrault system path

Exec=/usr/bin/env -S "QT_QPA_PLATFORM=xcb /usr/bin/copyq"

for different path

Exec=/usr/bin/env -S "QT_QPA_PLATFORM=xcb <your installed path>/bin/copyq"
securerootd commented 1 year ago

It still happens with me in Fedora 38 with Gnome 44.2 Wayland session

$ -> copyq
Warning: [default] QtWarning: QSocketNotifier: Can only be used with threads started with QThread
Warning: [qt.qpa.qgnomeplatform.theme] QtWarning: The desktop style for QtQuick Controls 2 applications is not available on the system (qqc2-desktop-style). The application may look broken.
Warning: [default] QtWarning: Activating Wayland clipboard took 5000 ms
ERROR: [default] QtCritical: Failed to activate Wayland clipboard
Warning: Failed to set global shortcut "Ctrl+Alt+V" for command "Show main window under mouse cursor".
$ -> sudo dnf info copyq
Last metadata expiration check: 0:25:46 ago on Sunday 18 June 2023 08:56:15 AM.
Installed Packages
Name         : copyq
Version      : 7.0.0
Release      : 1.fc38
Architecture : x86_64
Size         : 9.0 M
Source       : copyq-7.0.0-1.fc38.src.rpm
Repository   : @System
From repo    : updates
Summary      : Advanced clipboard manager
URL          : https://github.com/hluk/CopyQ
License      : GPL-3.0-or-later
Description  : CopyQ is advanced clipboard manager with searchable and editable history with
             : support for image formats, command line control and more.
frankhuurman commented 11 months ago

Same here, found out it happens to the Flatpak version (7.0.0) I installed. Just nothing showing up in the clipboard when you try to copy things, nothing gets added.

flatpak run com.github.hluk.copyq 
Warning: [default] QtWarning: QSocketNotifier: Can only be used with threads started with QThread
Warning: [default] QtWarning: Activating Wayland clipboard took 5000 ms
ERROR: [default] QtCritical: Failed to activate Wayland clipboard
Warning: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()

Installing an older copyq with apt on Ubuntu 22.04 made it work though.

hluk commented 11 months ago

I believe that the normal clipboard access does not work in Gnome Wayland session. It would need to be implemented somehow using Gnome Shell extensions.

You can verify if the clipboard access works with wl-paste CLI (on Fedora 38 it is part of wl-clipboard package).

Same here, found out it happens to the Flatpak version (7.0.0) I installed.

If you have this problem only with Flatpak version, it is possible that some arguments/permissions are missing in the specification:

https://github.com/flathub/com.github.hluk.copyq/blob/ea7d14484ab2b5d6f6fcf4fd10d0b31dbcde1fa1/com.github.hluk.copyq.yaml#L8-L15

I could not reproduce the problem, but I've only tested it in Sway.

marcotama commented 10 months ago

I am also experiencing the same problem after installing from apt on Ubuntu 23.04:

CopyQ Warning [2023-08-22 13:41:54.682] <Server-9243>: [default] QtWarning: Activating Wayland clipboard took 5000 ms
CopyQ ERROR [2023-08-22 13:41:54.692] <Server-9243>: [default] QtCritical: Failed to activate Wayland clipboard
CopyQ Warning [2023-08-22 13:41:54.881] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
CopyQ Warning [2023-08-22 13:41:59.920] <monitorClipboard-9268>: [default] QtWarning: Activating Wayland clipboard took 5000 ms
CopyQ ERROR [2023-08-22 13:41:59.925] <monitorClipboard-9268>: [default] QtCritical: Failed to activate Wayland clipboard
CopyQ Warning [2023-08-22 13:45:08.616] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
CopyQ Warning [2023-08-22 13:45:26.711] <monitorClipboard-9381>: [default] QtWarning: Activating Wayland clipboard took 5000 ms
CopyQ ERROR [2023-08-22 13:45:26.719] <monitorClipboard-9381>: [default] QtCritical: Failed to activate Wayland clipboard
CopyQ Warning [2023-08-22 13:45:29.941] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
CopyQ Warning [2023-08-22 13:45:29.945] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
AdrianScharff commented 8 months ago

I am also experiencing the same problem after installing from apt on Ubuntu 23.04:

CopyQ Warning [2023-08-22 13:41:54.682] <Server-9243>: [default] QtWarning: Activating Wayland clipboard took 5000 ms
CopyQ ERROR [2023-08-22 13:41:54.692] <Server-9243>: [default] QtCritical: Failed to activate Wayland clipboard
CopyQ Warning [2023-08-22 13:41:54.881] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
CopyQ Warning [2023-08-22 13:41:59.920] <monitorClipboard-9268>: [default] QtWarning: Activating Wayland clipboard took 5000 ms
CopyQ ERROR [2023-08-22 13:41:59.925] <monitorClipboard-9268>: [default] QtCritical: Failed to activate Wayland clipboard
CopyQ Warning [2023-08-22 13:45:08.616] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
CopyQ Warning [2023-08-22 13:45:26.711] <monitorClipboard-9381>: [default] QtWarning: Activating Wayland clipboard took 5000 ms
CopyQ ERROR [2023-08-22 13:45:26.719] <monitorClipboard-9381>: [default] QtCritical: Failed to activate Wayland clipboard
CopyQ Warning [2023-08-22 13:45:29.941] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()
CopyQ Warning [2023-08-22 13:45:29.945] <Server-9243>: [qt.qpa.wayland] QtWarning: Wayland does not support QWindow::requestActivate()

Me too, I'm having the same problem, the solution would be to switch to X11 instead of Wayland, but I don' t know if that can affect any other functionality in my pc

buergi commented 1 month ago

Same for me. I guess it must be a mere configuration issue, otherwise I couldn't understand how this issue is still unsolved after almost 5 years, as it prevents the software from achieving its sole purpose on modern linux distributions. In the search of other tools I found others having the same issue e.g. here (in German) with the final verdict "Failed; on to the next tool."

hluk commented 1 month ago

I guess it must be a mere configuration issue, otherwise I couldn't understand how this issue is still unsolved after almost 5 years, as it prevents the software from achieving its sole purpose on modern linux distributions.

CopyQ supports clipboard management in Wayland via some standard protocol, but (as mentioned before) Gnome Wayland session allows clipboard managers to be implemented only as Gnome Shell Extensions. From a security perspective, it makes sense ...although any other app that has focus can access the clipboard.

I believe, the workaround is to start CopyQ under XWayland with the following command (if it is supported in your Gnome installation):

env QT_QPA_PLATFORM=xcb copyq

Note: I still use Sway (or KDE occasionally) without any issue, so I don't have a reason to investigate further and fix this myself currently.