-
Notifications
You must be signed in to change notification settings - Fork 89
feat: add configurable tray icon click actions + double click actions… #1247
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: master
Are you sure you want to change the base?
feat: add configurable tray icon click actions + double click actions… #1247
Conversation
19a68e7 to
f1a334f
Compare
|
For tray I think ideal would be per-item configuration like [tray.items.nm-applet]
on_click_left = "do something"
[tray.items.telegram-desktop]
on_click_right = "do something else"but too complicated + YAGNI. |
|
There is one limitation currently, for tray there's some GTK spam about some CSS errors when opening certain items' menus now (e.g. nm-applet, but not copyq) - IDK what this is and what to do about it, but it's harmless, doesn't seem to be impacting anything. |
JakeStanger
left a comment
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.
Thanks for this, this looks good. A few minor things on first pass.
Are you able to split into two commits please? One for the tray features, and one for the global double-click features.
3ed7db1 to
c5d6d4f
Compare
|
@JakeStanger all feedback addressed. For configuring I chose to keep the default to be 250ms. I think 200ms is too aggressive, I personally struggle with this 😆 |
|
I'm wondering if it might be better to run the single-click action always, which'd avoid the delay. It would potentially be more limited, but it would be more inline with standard double-click behaviour in other applications. |
|
I think it only works for situations where single-click action is some sort of a light toggle, e.g. opening a menu or a popup, where the second click would just cancel it out and trigger the right action. For anything else I think it would basically render it unusable. My personal use cases are covered either way (I only do "toggles" for now), but it would feel quite weird to have it "broken" by the virtue of always performing single click. As for other software, I could only think of file managers where double clicks exist at all (open vs select, rename vs select, and in Nemo go a directory up vs unselect). In these cases, the semantics of actions always allow for this, and they don't expose any sort of configuration to this. Could you remind me of other examples? I also don't really notice any delay with 250ms click interval, feels instant to me. I wouldn't mind making it optional though. OTOH this could be an unnecessary complexity dump onto people casually reading the config guide — might be moved into something like |
|
From kitty docs (which offers freely configurable double/triple clicks):
So they just accept the delay. You prolly already got it from the code, but just in case note that in our implementation, if user only configured single clicks, and no double clicks, then single clicks happen instantly, there's no delay if we're not even waiting for a successive click. |
|
Sorry for the delay - I think going based on Kitty behaviour makes the most sense, since it's the most applicable/similar scenario. |
JakeStanger
left a comment
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.
Two minor bits then we're good to go
| Keyword(DoubleClickTimeKeyword), | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Deserialize)] | ||
| #[cfg_attr(feature = "extras", derive(schemars::JsonSchema))] | ||
| #[serde(rename_all = "lowercase")] | ||
| pub enum DoubleClickTimeKeyword { | ||
| Gtk, | ||
| } |
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 is no need to introduce an additional enum here - we can just create a Gtk variant directly.
| Keyword(DoubleClickTimeKeyword), | |
| } | |
| #[derive(Debug, Clone, Deserialize)] | |
| #[cfg_attr(feature = "extras", derive(schemars::JsonSchema))] | |
| #[serde(rename_all = "lowercase")] | |
| pub enum DoubleClickTimeKeyword { | |
| Gtk, | |
| } | |
| Gtk |
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 don't think it could work without a custom deserializer (which is a lot of new code). This specifically leads to config parsing failing when the value is set to "gtk", only works with null. Is there something I missed, or should I just keep it the current way?
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.
Try including untagged in the enum serde attr
|
fe99eaf is unrelated in terms of scope of the PR, but needed to pass clippy. Let me know if I should revert it 👍 |
- Add double-click support via CommonConfig - Add on_click_left_double, on_click_middle_double, on_click_right_double events - Add reusable connect_pressed_with_double_click() to IronbarGtkExt - Update documentation for double-click configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Add TrayClickAction enum with built-in and custom command support
- Support placeholders in custom commands: {name}, {title}, {icon}, {address}
- Update tray documentation for new click action configuration
Closes JakeStanger#1242
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Remove verbose prefixes from tray click actions: - open_menu -> menu - trigger_default -> default - trigger_secondary -> secondary 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Create TrayClickHandlers struct with flattened serde - Simplify function signatures (removed clippy allow) - Reduce parameter passing throughout codebase 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace manual Deserialize implementation with derived version using nested enum pattern (similar to ScriptInput): - Create ReservedTrayAction enum with snake_case variants - Use #[serde(untagged)] on TrayClickAction - Serde tries Reserved first, falls back to Custom(String) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Add make_handler helper to eliminate repetitive closure setup - Add is_actionable() method to replace verbose None checks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add on_click_right_double and on_click_middle_double to match other modules and provide consistent double-click support across all mouse buttons. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Adds a top-level `double_click_time` configuration option that allows customizing the double-click detection timeout. This improves accessibility for users who need more time between clicks. Configuration accepts either: - A number in milliseconds (e.g., `200`, `5000`) - The string `"gtk"` to use GTK's gtk-double-click-time setting Defaults to 250ms (faster than GTK's 400ms default). When using a custom millisecond value, the implementation also updates GTK's internal gtk-double-click-time setting to ensure GestureClick's n_press detection matches the configured timeout. This synchronization is done lazily on first use to avoid GTK initialization issues. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace standalone default_double_click_time() function with Default trait implementation. Also derive Default for Config struct to simplify the implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Create IconConfig struct to group icon_theme, icon_size, and prefer_theme parameters together. This reduces the on_update function parameter count from 8 to 6, fixing the clippy::too_many_arguments warning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
fe99eaf to
69e4473
Compare
… for all modules
Closes #1242
🤖 Generated with Claude Code