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

Window activation support #2279

Closed
kchibisov opened this issue May 3, 2022 · 5 comments · Fixed by #2955
Closed

Window activation support #2279

kchibisov opened this issue May 3, 2022 · 5 comments · Fixed by #2955
Assignees
Labels
C - needs discussion Direction must be ironed out DS - wayland DS - x11 S - api Design and usability

Comments

@kchibisov
Copy link
Member

On Wayland for link to raise window(e.g. when clicking a link in application, the launcher application should be opened with some env variable set to specific token).

Both X11 and Wayland has concept like that, see

https://wayland.app/protocols/xdg-activation-v1 and its XDG_ACTIVATION_TOKEN variable.

And X11
https://cgit.freedesktop.org/startup-notification/tree/doc/startup-notification.txt

I'm not sure whether macOS or Windows have something like that, but they probably should.

For now, to account for Wayland, we should add a method on WindowBuilder::with_activation_token(<Option<String>>) and add a method on a particular window to request activation token.

The first will be used when the application is raised from other process or in multiwindow context. The later to run launchers e.g. xdg-open or same in multiwindow context.

cc @ArturKovacs @maroider @madsmtm

--

I'll send Wayland impl and impl it in alacritty, since it looks pretty straightforward.

@kchibisov
Copy link
Member Author

I was a bit wrong wrt API, given that Wayland is async here and you must creating a token is a request to compositor leaving you wait until the request is done means that it should reply to application async via some event...

@madsmtm
Copy link
Member

madsmtm commented May 4, 2022

Not sure I understand, is the "activation token" equivalent to an "application id" (macOS has those)? If no, how do they differ? Would this allow a similar thing as #1751?

@kchibisov
Copy link
Member Author

No, it's completely different thing. It's basically what Window::focus_window does. And if you pass it to a launcher, launched window can read this token and request focus.

Example, clicking on links in terminal will switch focus to a browser or mark it as urgent(depends on compositor). Without token passing it's impossible to know where the link opened or what actually launched.

It could be passed to other winit window, so it'll get focus or if you want to switch focus to other winit window when feel like.

@kchibisov kchibisov added this to the Version 0.29.0 milestone Jul 11, 2023
@kchibisov kchibisov self-assigned this Jul 11, 2023
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 12, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
@psychon
Copy link
Contributor

psychon commented Jul 12, 2023

Are you sure that xdg-activation and startup-notification do similar things? The xdg-activation spec begins with:

The way for a client to pass focus to another toplevel is as follows.

startup-notification... doesn't have any explanation that I can find. So, instead I found: https://developer-old.gnome.org/platform-overview/stable/dev-launching-startupnotify.html.en

Notify the user when your application has finished starting up.

GNOME implements the Startup Notification protocol, to give feedback to the user when application startup finishes.

GTK applications automatically support startup notification, and by default notify that application startup is complete when the first window is shown. Your application must declare that it supports startup notification by adding StartupNotify=true to its desktop file.

More complicated startup scenarios, such as showing a splash screen during startup, would need custom handling with gdk_notify_startup_complete().

I understand this as a completely different use case. Basically, I vaguely remember that KDE would change my mouse cursor when I started an application via the menu, showing the app's icon next to the mouse cursor while the app was starting. I bet it doesn't do that anymore, so just imagine an hourglass as mouse cursor between "the app is started" and "the app is done starting".

I am not saying that something somewhere does some focus-passing via sn events, but I am trying to say that these two protocols (xdg-activation and startup-notification) don't seem closely related to me.

@kchibisov
Copy link
Member Author

@psychon it's wired the same in GTK if you read its code and it's wired the same inside the firefox. The Wayland spec refers to X11 spec and wayland compositors use the tokens from xdg-activation for DESKTOP_STARTUP_ID.

notgull pushed a commit to forkgull/winit that referenced this issue Jul 13, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 13, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 13, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
notgull pushed a commit to forkgull/winit that referenced this issue Jul 15, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov pushed a commit to kchibisov/winit that referenced this issue Jul 20, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 20, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 20, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 20, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit to kchibisov/winit that referenced this issue Jul 20, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.
kchibisov added a commit that referenced this issue Jul 20, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes #2279.

Co-authored-by: John Nunley <jtnunley01@gmail.com>
kchibisov added a commit to kchibisov/winit that referenced this issue Aug 14, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes rust-windowing#2279.

Co-authored-by: John Nunley <jtnunley01@gmail.com>
kchibisov added a commit that referenced this issue Aug 15, 2023
The utils in this module should help the users to activate the windows
they create, as well as manage activation tokens environment variables.

The API is essential for Wayland in the first place, since some
compositors may decide initial focus of the window based on whether
the activation token was during the window creation.

Fixes #2279.

Co-authored-by: John Nunley <jtnunley01@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - needs discussion Direction must be ironed out DS - wayland DS - x11 S - api Design and usability
Development

Successfully merging a pull request may close this issue.

3 participants