-
Notifications
You must be signed in to change notification settings - Fork 787
gtk: implement global shortcuts #7083
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
base: main
Are you sure you want to change the base?
Conversation
I wonder what the diff would look like if we used libportal |
Well... libportal doesn't implement this yet, and it doesn't seem like anyone else is interested. (There's an open PR from July 2024, but nobody's left a single comment yet: flatpak/libportal#153) Would make my day a whole lot easier if it were the case to be honest It also would've been a lot easier if they made the API extensible so that you could write your own portal extensions via libportal, but sadly we can't have nice things |
c043fcd
to
2479f30
Compare
It's been a lot of D-Bus related pain and suffering, but here it is. I'm not sure about how well this is integrated inside App, but I'm fairly proud of the standalone logic.
Compiling this list of known supported and unsupported platforms has been amazingly painful. Never change, Linux desktop.
2479f30
to
620e718
Compare
|
||
/// Returns a XDG-compliant shortcuts string from a trigger. | ||
/// Spec: https://specifications.freedesktop.org/shortcuts-spec/latest/ | ||
pub fn xdgShortcutFromTrigger(buf: []u8, trigger: input.Binding.Trigger) !?[:0]const u8 { |
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.
should we write tests for this function?
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.
Oh yeah that would be a good idea. Will do it tomorrow as it's quite late here
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.
Excellent work. That fact it's so encapsulated is really well done. I agree with @tristan957 on the test request for the one function, then I just hit the "red" button to consider the ArrayHashMap
change.
/// Currently the unique ID is simply the serialized representation of the | ||
/// trigger that was used for the action as triggers are unique in the keymap, | ||
/// but this may change in the future. | ||
map: std.StringHashMapUnmanaged(Binding.Action) = .{}, |
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.
Should this be an ArrayHashMap to avoid the tombstone issue for very long running Ghostty instances? ziglang/zig#17851
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 wasn't even aware that this was a thing! Yeah in that case we should go for 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.
Yeah. In this case it'd be pretty pathological because you only clear and re-add when settings are reloaded so a user would have to reload a lot but I've been bit enough by this bug that I instinctively think "why not"
var trigger_buf: [256]u8 = undefined; | ||
|
||
self.map.clearRetainingCapacity(); | ||
var it = self.app.config.keybind.set.bindings.iterator(); |
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.
Note to self: create better API for this, I don't think the apprt's should be doing this level of introspection. Its totally fine for this PR, but I'll get around to a better API soon, because its in the hot path of me implementing global shortcuts on macOS that don't require special permissions (that they do today).
It's been a lot of D-Bus related pain and suffering, but here it is.
I'm not sure about how well this is integrated inside App, but I'm fairly
proud of the standalone logic.