Skip to content
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

Global hotkeys do not work in Wayland + Plasma 6 environment #1412

Open
UM-Li opened this issue Mar 7, 2024 · 9 comments
Open

Global hotkeys do not work in Wayland + Plasma 6 environment #1412

UM-Li opened this issue Mar 7, 2024 · 9 comments
Labels
Wayland Linux desktop's future.

Comments

@UM-Li
Copy link

UM-Li commented Mar 7, 2024

描述 bug

调出主窗口的热键设为 Ctrl+F12,翻译剪贴板单词的热键设为 Ctrl+C Ctrl+C
这两个热键在 KDE Plasma 6 + Wayland 环境下均失效,按下没有反应。

系统和软件版本

系统为 Arch Linux,Plasma 版本 v6.0.1。

Goldendict-ng 24.02.16.8f77f2a7 at 2024-03-01T05:32:34
Qt 6.6.2 GCC 13.2.1 20230801 arch linux 6.7.8-arch1-1 x86_64-little_endian-lp64
Flags:USE_XAPIAN MAKE_ZIM_SUPPORT USE_ICONV MAKE_CHINESE_CONVERSION_SUPPORT
Copy link
Contributor

github-actions bot commented Mar 7, 2024

Bot detected the issue body's language is not English, translate it automatically.

Describe bug

The hotkey to bring up the main window is set to Ctrl+F12, and the hotkey to translate clipboard words is set to Ctrl+C Ctrl+C.
These two hotkeys are invalid in the KDE Plasma 6 + Wayland environment, and there is no response when pressed.

System and Software Version

The system is Arch Linux, Plasma version v6.0.1.

Goldendict-ng 24.02.16.8f77f2a7 at 2024-03-01T05:32:34
Qt 6.6.2 GCC 13.2.1 20230801 arch linux 6.7.8-arch1-1 x86_64-little_endian-lp64
Flags:USE_XAPIAN MAKE_ZIM_SUPPORT USE_ICONV MAKE_CHINESE_CONVERSION_SUPPORT

@github-actions github-actions bot changed the title Wayland + Plasma 6 环境下全局热键失效 Global hotkeys do not work in Wayland + Plasma 6 environment Mar 7, 2024
@UM-Li
Copy link
Author

UM-Li commented Mar 7, 2024

再做测试发现这两个热键只在 GD 主窗口打开且获得焦点时可用,即按 Ctrl+F12 可以关闭主窗口但不能在其已经关闭时调出;Ctrl+C Ctrl+C 只能用于复制查询 GD 主窗口里的单词。

Copy link
Contributor

github-actions bot commented Mar 7, 2024

Bot detected the issue body's language is not English, translate it automatically.

After further testing, I found that these two hotkeys are only available when the GD main window is open and has focus. That is, pressing Ctrl+F12 can close the main window but cannot be called out when it has been closed; Ctrl+C Ctrl+ C can only be used to copy words in the main window of the query GD.

@shenlebantongying shenlebantongying added the Wayland Linux desktop's future. label Mar 8, 2024
@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Mar 8, 2024

Sadly, there are various tasks to make GD works natively on Wayland without bugs.

At the same time, XWayland is getting more restrictive than before. This is probably intended. XWayland can no longer monitor and intercept global shortcuts. Also, If a window is not focused, there will be no clipboard change event anymore.

Although we call it "broken", I guess desktop environment developers like KDE call it "Wayland properly implemented" :)


Anyway, a temporal workaround is enabling global shortcut at KDE level:

Bind a script that reads from clipboard and pass it to Goldendict.

Then you can use, for example, Ctrl+C,Meta+C

image

image

@shenlebantongying
Copy link
Collaborator

wl-paste appears to support primary selection clipboard.

You can also bind goldendict $(wl-paste --primary) to a single shortcut, like Meta+C to select and open translate selection in GD.

@UM-Li
Copy link
Author

UM-Li commented Mar 8, 2024

Thank you for the tips @shenlebantongying, for now the KDE shortcut works well.
It's a bit of a shame things have become this restrictive under Wayland :-(

@CoelacanthusHex
Copy link

CoelacanthusHex commented Mar 9, 2024

@shenlebantongying
Copy link
Collaborator

Here is my insanely bad and awful code to test org.freedesktop.portal.GlobalShortcuts:

https://github.com/SourceReviver/qt_wayland_globalshortcut_via_portal

It will register shortcuts and response to them when triggered on KDE/Wayland.

A better implementation can be found https://invent.kde.org/libraries/xdg-portal-test-kde

I am still not sure about how to handle errors, app shutdown...


So far,

@dc-me
Copy link

dc-me commented May 21, 2024

It also does not work in fedora 40(Gnome Desktop) with flatpak version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wayland Linux desktop's future.
Projects
None yet
Development

No branches or pull requests

4 participants