slint
slint copied to clipboard
Add app_id property to Window
On Wayland this will be passed to set_app_id in xdg-shell
On X11 this will be passed to wmclass
It is used by desktop environments to identify the application
Fixes #1332
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
I think it’s a good idea to add support for this.
Implementation wise I think yon might need some platform cfg guards. Which platforms support this or how this maps to the platforms should be documented.
I’m not entirely sure if this API belongs into the UI design or if it should be API on slint::Window that’s for programmers dealing with platform integration (color me torn :)
I’m not entirely sure if this API belongs into the UI design or if it should be API on slint::Window that’s for programmers dealing with platform integration (color me torn :)
I would not expect an UI designer to care for OS-specific details like this, so I would expect this to be set with code somehow.
Thanks for the pull request. The code looks good (appart from the missing #[cfg(unix)]
).
But as the other already said, this is probably not something that should be configured in the .slint file.
We should add an API to the slint::Window
instead.
But the problem is that form my limited understanding of that property, we need to specify it before creating the window. So before we actually have a slint::Window. So that might not be possible? then perhaps a global function should be use like slint::set_app_id or set_xdg_id or something like that.
we need to specify it before creating the window. So before we actually have a slint::Window. So that might not be possible?
Right, we need to know the id before creating the winit::Window
. We create that when calling show()
on the slint::Window
, so I think it's okay to have API on slint::Window
and document that it needs to be set before calling show()
(or run()
).
then perhaps a global function should be use like slint::set_app_id or set_xdg_id or something like that.
Ah, you're right - this isn't per window anyway. In Qt it's also a global of the application object. So slint::set_xdg_app_id
sounds good to me.
In Qt it's also a global of the application object
In Wayland (and X11 too) it's a per-window (as in toplevel-window) property though. But I have never personally encountered a case where it being global in Qt was a problem
Could the ID String be passed to the generated constructor for the window?
How do we proceed here? Do we make it a global or per-window property?
It's a bit of a complex situation. The native window system APIs support it to be per-window, but Qt can only do it globally
I still maintain that this is best handled as a global property. The common case is that one process has one or multiple windows that belong to the same application id (matching the .desktop file).
One rare case I can imagine is that multiple .desktop files map to the same process, but there the app id could be a command line parameter that's then passed to the API we're talking about.
So the only scenario that I can think of that wouldn't work is one where multiple .desktop files end up re-using the same process but show are supposed to represent distinct applications.
I'm still in favor of slint::set_xdg_app_id
.