Skip to content
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 app_id property to Window #1333

Closed
wants to merge 1 commit into from

Conversation

nicolasfella
Copy link

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

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 slint-ui#1332
@CLAassistant
Copy link

CLAassistant commented Jun 10, 2022

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.

@tronical
Copy link
Member

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

@hunger
Copy link
Member

hunger commented Jun 17, 2022

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.

@ogoffart
Copy link
Member

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.

@tronical
Copy link
Member

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
Copy link
Member

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.

@nicolasfella
Copy link
Author

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

@Be-ing
Copy link
Contributor

Be-ing commented Jun 27, 2022

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

@nicolasfella
Copy link
Author

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

@tronical
Copy link
Member

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.

@LucaCoduriV
Copy link

Hello, any news about this ?

@tronical
Copy link
Member

One way of achieving this today is by using the winit backend private API:

use i_slint_backend_winit::winit::platform::wayland::WindowAttributesExtWayland;
let mut backend = i_slint_backend_winit::Backend::new().unwrap();
backend.window_builder_hook = Some(Box::new(|builder| builder.with_name(your_app_id)));
slint::platform::set_platform(Box::new(backend));

@ogoffart
Copy link
Member

This PR is a bit old and out of date so i'm going to close it.
I think, as we discussed, this doesn't belong in the .slint file, but should be either an API of slint::Window, or a parameter for the whole app.

The issue #1332 remains open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A way to set app_id on Wayland is needed
7 participants