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

WIP: FEAT(client): Add support to XDG Desktop Portal GlobalShortcuts #5976

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aleixpol
Copy link

This makes it possible to have global shortcuts on systems running the XDG Desktop Portal service. This is especially relevant on Wayland where we are not able to run a system-wide keylogger to get the global shortcuts triggers.

Fixes #5257

Checks

WIP because I'm not very familiar because this is a codebase alien to me and I'm aware it's doing some nasty things. Still, I'd prefer to know how the maintainers want to do it rather than imagining myself what they want instead.

Note the GlobalShortcuts portal is merged to master but it still isn't released.

Copy link
Member

@Krzmbrzl Krzmbrzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the implementation using the name "xdp" rather than "xdg"?

And I'm wondering: Given that this is such a new feature, do we want to keep the old wayland notice in-place and show, if on wayland and if the new impl is not available?

src/EnvUtils.h Outdated Show resolved Hide resolved
Comment on lines 844 to 828
qt_add_dbus_interface(mumble_xdp_SRCS org.freedesktop.portal.GlobalShortcuts.xml globalshortcuts_portal_interface)
find_file(PORTALSREQUEST_XML share/dbus-1/interfaces/org.freedesktop.portal.Request.xml PATH_SUFFIXES share PATHS /usr ${CMAKE_INSTALL_PREFIX})
qt_add_dbus_interface(mumble_xdp_SRCS ${PORTALSREQUEST_XML} portalsrequest_interface)
target_sources(mumble_client_object_lib PRIVATE ${mumble_xdp_SRCS})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be outsourced into a dedicated cmake function implemented in a file inside the cmake directory. Then this place here could simply call that function.

Plus, it seems that we currently don't handle the case when the searched for file can't be found.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved both files to auxiliary_files.

I am not sure what you mean by adding the function. Do you still want it if we are not looking it up?

src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.h Outdated Show resolved Hide resolved
src/mumble/org.freedesktop.portal.GlobalShortcuts.xml Outdated Show resolved Hide resolved
@Krzmbrzl
Copy link
Member

And out of curiosity: Will this be a flatpak-specific thing or will this (likely) solve the issue for Wayland users in general (also for non-flatpak apps)?

@aleixpol
Copy link
Author

And out of curiosity: Will this be a flatpak-specific thing or will this (likely) solve the issue for Wayland users in general (also for non-flatpak apps)?

Yes, this should solve it for every Wayland system. Also it can work on X11 provided it's properly implemented in the backend like we are doing in KDE/Plasma and I expect others will too.

Copy link
Member

@Krzmbrzl Krzmbrzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay since my last review - I have been rather busy

src/mumble/GlobalShortcut.cpp Show resolved Hide resolved
src/mumble/GlobalShortcut_unix.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_unix.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
src/mumble/GlobalShortcut_xdp.h Outdated Show resolved Hide resolved
Comment on lines -556 to -561
#ifdef Q_OS_LINUX
if (EnvUtils::waylandIsUsed()) {
// Due to the issues we're currently having on Wayland, we disable shortcuts by default
bShortcutEnable = false;
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably get the same treatment as the note in the settings UI

src/mumble/GlobalShortcut_xdp.cpp Outdated Show resolved Hide resolved
Comment on lines +149 to +150
// TODO
return {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just marking this so we don't lose track of this TODO

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to address this TODO we'll need to use an interface like this:
https://invent.kde.org/libraries/xdg-portal-test-kde/-/merge_requests/18

This means depending on Qt::GuiPrivate and libwaylandclient. If you are interested in this I can include it in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. This seems rather hacky. What are the implications of simply leaving the implementation as it is? Aka: what exactly is the parent window ID being used for?
Will this perhaps only become relevant when dealing with multiple Mumble instances?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent window is simply to inform the portal who is calling this and which window the dialog should be on top.

The dialog will appear on top and focussed anyway, so it shouldn't be a big deal. FWIW, there will be public API for this in Qt 6 (6.5, if I'm not mistaken). If you don't want to depend on private API, just delaying until Qt 6 is a good option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay in that case it indeed seems a good idea to simply delay this 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aleixpol aleixpol force-pushed the work/xdp-support branch 2 times, most recently from 6fbe414 to 62bb6d9 Compare January 2, 2023 15:10
This makes it possible to have global shortcuts on systems running the
XDG Desktop Portal service. This is especially relevant on Wayland where
we are not able to run a system-wide keylogger to get the global
shortcuts triggers.

Fixes mumble-voip#5257
@CounterPillow
Copy link

Two awkward things I've noticed which may or may not be related to the implementation in this PR:

  1. you can't bind mouse buttons to global shortcuts. I assume this is either a deficiency specifically with this PR or with KDE's GlobalShortcuts interface ignoring all mouse presses
  2. pressing a modifier while pressing a key does not allow for that key to be picked up by the shortcut, so if I bind F13 (or as KDE calls it, "Tools") to push-to-talk, I also need to bind shift+Tools, shift+ctrl+Tools, ctrl+Tools, alt+tools, ... which may be a deficiency in the entire protocol.

@aleixpol
Copy link
Author

you can't bind mouse buttons to global shortcuts.

Correct, we don't have global shortcuts triggered my mouse in Plasma. It should be supported by Plasma or the Desktop Environment of choice of the user anyway.

pressing a modifier while pressing a key does not allow for that key to be picked up by the shortcut,

Again, this is Plasma deciding that they are not the same shortcut and not triggering it. There's not much we can (or should) do from this side. I suggest we continue this discussion in the bug report you created: https://bugs.kde.org/show_bug.cgi?id=465867

I suggest explaining a bit more on the bug report why it's important for anymodifier to trigger the subject's shortcut. If we have clear use cases it will be easier to get it acted on.

@SopaDeMacaco-UmaDelicia

What's the status of this PR? Can't wait to enjoy global shortcuts in Mumble using KDE Wayland.

@k3d3
Copy link

k3d3 commented Jul 31, 2024

Has any more progress been made on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client feature-request This issue or PR deals with a new feature GlobalShortcuts linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts don't work on Wayland
6 participants