slint icon indicating copy to clipboard operation
slint copied to clipboard

Add app_id property to Window

Open nicolasfella opened this issue 2 years ago • 10 comments

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

nicolasfella avatar Jun 10 '22 14:06 nicolasfella

CLA assistant check
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.

CLAassistant avatar Jun 10 '22 14:06 CLAassistant

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 :)

tronical avatar Jun 11 '22 21:06 tronical

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.

hunger avatar Jun 17 '22 14:06 hunger

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.

ogoffart avatar Jun 27 '22 08:06 ogoffart

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()).

tronical avatar Jun 27 '22 08:06 tronical

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.

tronical avatar Jun 27 '22 08:06 tronical

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

nicolasfella avatar Jun 27 '22 22:06 nicolasfella

Could the ID String be passed to the generated constructor for the window?

Be-ing avatar Jun 27 '22 23:06 Be-ing

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

nicolasfella avatar Sep 21 '22 06:09 nicolasfella

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.

tronical avatar Sep 21 '22 07:09 tronical