-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Add a global shortcut portal #711
Conversation
ad69435
to
472b2dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, personally I could really use a few examples here to better understand what the intention is of this portal. I get that it would address the simple "ctrl+c" shortcut type but it seems overspecced for that simple case. And I think it may be underspecced for the more complex cases that require key repeats. So I'm wondering: what are the specific use-cases you are trying to solve here?
472b2dd
to
b83f56e
Compare
My understanding is that this is for global shortcuts that are always active, even while an unrelated application has keyboard focus. Instead of "copy" or "zoom in", think more like "start recording". While an application has focus, it can receive Ctrl+C (or similar) in the usual X11 or Wayland way, without needing portals. |
b83f56e
to
7986af5
Compare
Lets say we have an application that can control the sun shade of a physical window, and that it wants to bind the actions "roll up sun shade" and "roll down sun shade" using the global shortcut portal to some two key bindings. Could you describe step by step how the application does this, when a portal dialog will be presented, and how the application does the second time it launches? |
7986af5
to
95e7724
Compare
app:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few comments about the design of the API. None of the C code was reviews, I'll review the implementation once we figure out the D-Bus bits.
Something I'd like us to think through is the security model of this API. The current iteration implies that applications would need to request the same shortcuts on startup, and no permissions are stored anywhere. This can be an annoying behavior. On the other hand, allowing any app to request global shortcuts without any extra check is not ideal either. So the question is: how would we implement apps only requesting permissions once?
I agree with @GeorgesStavracas that it'd be good to be able to batch multiple Bind requests into a single Thinking more about the permission model would indeed be good. What needs to be ensured is that: applications should not be allowed to arbitrarily bind shortcuts without user consent; at least the API must make sure that a backend can implement such semantics. It'd also be good to allow an application to be able to request new bindings, or change existing ones, thus the initial set of bindings being set up at session construction is a bit awkward. Given this, maybe we can take inspiration from the screen cast session restore functionality, by making the following changes:
With this, the flow would be altered slightly, but I believe it should be possible to implement the same user interface as you described in the issue:
Edit: github decided to treat some key binding as "save" before the comment was ready, should be fixed now. |
Another question that just popped up: should this protocol support binding the same shortcut to multiple key combinations? |
Sounds like something an impl backend can do without involving any APIs. |
If we want to give apps access to a string which describes what the shortcut is bound to this might not be so straightforward. |
Converted to a Draft so no one (read: me) accidentally merges it |
95e7724
to
e43ee47
Compare
There's no way for an app to register here. We have not even specified how that would work. I'm afraid we might be miscommunicating.
It could be nice to show some UI to let the portal handle the UX for all global shortcuts. I wouldn't expect this to be how every app does it though, as I expect apps to want to show their own UI for listing these shortcuts.
My understanding is that we should keep the shortcuts an app has requested by its name, no need to keep a token. I don't know in which cases we'd consider the application a different one. In practice, we can consider shortcuts to be static in a specific version of an app and could change between versions but it should only change slightly. I do want us to be able to offer a UX that doesn't necessarily have to show UI from the portals, as we've seen this lead us to rather awkward workflows with cross-platform apps. |
e43ee47
to
1c53a39
Compare
You can also give from gnome's portal a Edit: description -> trigger |
I feel like we're set on a path of confusion with the terminology here. I'd like to propose the following:
Objections? |
I still don't get how this is supposed to work. For example if you want to delete a shortcut and the app doesn't delete it but deletes it in its UI you suddenly have a shortcut bound to a trigger which you are not aware of. How does it work if you want to bind multiple triggers? How does it work if you bind triggers which require rich UI? How do you handle conflicts and potential conflicts? All of that is pretty straightforward if you do all of it in the application (X11 style) or all of it in the system UI (portal backend) but you want some kind of hybrid which makes everything much harder. |
1c53a39
to
0b5f041
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate Apol is still working on the previous round of review, but I had a few comments to flush
Did a PoC implementation of the portal. |
5693f05
to
c0318fd
Compare
@handle: Object path for the #org.freedesktop.impl.portal.Request object representing this call | ||
@session_handle: Object path for the #org.freedesktop.impl.portal.Session object representing the session | ||
@parent_window: Identifier for the application window, see <link linkend="parent_window">Common Conventions</link> | ||
@shortcuts: The identifier of the shortcuts we intend to register, empty for all shortcuts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if one tries to bind shortcuts not part of the CreateSession
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should error out. I am not sure how this is generally communicated, do you know what would be a good example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not allowed to bind shortcuts that wasn't specified in CreateSession
the documentation should specify that it'll fail. I guess it will via the response signal.
How would an application that doesn't know its wanted global shortcuts immediately add new ones? Does it have to have one session per added binding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can close the session and start a new one with the previous + the added one. This is how I imagined it at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Re-creating the session is racy; if one triggers a binding right at the time the app decides to recreate the session, it can be lost. Maybe not a big deal since it's very unlikely to happen very often. Then again, could just as well be one session per binding couldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-creating the session is racy; if one triggers a binding right at the time the app decides to recreate the session, it can be lost. Maybe not a big deal since it's very unlikely to happen very often.
Correct. It shouldn't happen though during general runtime of the app.
Then again, could just as well be one session per binding couldn't it?
Yes.
@aleixpol i think this PR now needs to update the Meson files too. Shouldn't be hard to add, and won't impact review too much, but I'd appreciate if you could add it too since next xdg-desktop-portal release will be done with Meson 🙂 |
a656378
to
d37bb4f
Compare
That explains the CI exploding, should be addressed |
It's designed so that applications can register actions that can be triggered globally (i.e. regarless of the system's state, like focus).
d37bb4f
to
283e0d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There still are a few things to correct here, but I think it'll be more productive to do that myself 🙂
Glad to see it's in, I'd have expected a PR into this branch but I guess that will work anyway. Thanks, please poke me for the polishes. |
This protocol is only for system-wide shortcuts. As a foscussed application you can always do as you wish with the input you are given.
No, all the communication to put this together in this Pull Request. |
Would it be possible with this portal for a third party app (KDE Settings/GNOME Settings/other...) to be able to list and manage all global shortcuts from every app using them? |
It's designed so that applications can register actions that can be
triggered globally (i.e. regarless of the system's state, like focus).
WIP because:
Fixes #624