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

wayland: Implement RaiseWindow with xdg-activation #4413

Merged
merged 2 commits into from
Jun 2, 2021

Conversation

flibitijibibo
Copy link
Collaborator

@flibitijibibo flibitijibibo commented Jun 2, 2021

This is a draft of Wayland RaiseWindow support - I say "draft" because I have no way of testing to make sure this works. Will mark as ready to merge once that's done.

Other than that, there's not much to see - the protocol implements window raising as an "activation token" which we send to the compositor and it may or may not honor our request depending on how it feels. Worst case it makes our window blink in the taskbar instead of actually raising it, which is better than nothing I suppose.

Test is here. Use ./run.sh to run with Wayland, alt-tab to a different window, and in 3 seconds the RaiseWindow call should occur.

app_name = "SDL Application";
}

xdg_activation_token_v1_set_surface(wind->activation_token, wind->surface);
Copy link

@emersion emersion Jun 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, call xdg_activation_token_v1_set_serial with the seat+serial of the event (e.g. click or key press) that triggered the activation. Some compositors might only raise toplevels if they do this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note regarding the serial - this call is technically arbitrary and not based on reactions to any events, so we won't have a serial readily available. That said, it's okay if this gets mostly ignored, especially since it's arbitrary.

@jadahl
Copy link
Contributor

jadahl commented Jun 2, 2021

Would be useful to also call "activate(token)" with the token from the corresponding env var, if set, to make sure the SDL application gets focused correctly on startup.

@flibitijibibo
Copy link
Collaborator Author

I was able to build sway locally and can confirm the latest works as intended!

Would be useful to also call "activate(token)" with the token from the corresponding env var, if set, to make sure the SDL application gets focused correctly on startup.

Is there a specific place we should do this? I wasn't able to find any existing examples for this.

@emersion
Copy link

emersion commented Jun 2, 2021

Is there a specific place we should do this?

When creating the xdg_toplevel maybe?

@emersion
Copy link

emersion commented Jun 2, 2021

Nice, this PR looks pretty good to me!

@flibitijibibo
Copy link
Collaborator Author

Latest commit now checks for XDG_ACTIVATION_TOKEN, re-tested on sway and everything looked okay - @jadahl, as long as the added commit looks good to you this is ready to go!

@flibitijibibo flibitijibibo marked this pull request as ready for review June 2, 2021 18:45
@jadahl
Copy link
Contributor

jadahl commented Jun 2, 2021

When creating the xdg_toplevel maybe?

Something like that. Seems we did an awful job at specifying when exactly it should be called.

@slouken slouken merged commit 2af3f64 into libsdl-org:main Jun 2, 2021
@flibitijibibo flibitijibibo deleted the xdg-activation branch June 2, 2021 19:59
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.

4 participants