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

question: custom rendering to arbitrary wayland surface #2388

Closed
imgurbot12 opened this issue May 4, 2024 · 4 comments
Closed

question: custom rendering to arbitrary wayland surface #2388

imgurbot12 opened this issue May 4, 2024 · 4 comments
Labels
blocked Blocked by another PR/Issue desktop Suggestions related to the desktop renderer enhancement New feature or request

Comments

@imgurbot12
Copy link

imgurbot12 commented May 4, 2024

Feature Request

Hello, I would like to build a custom lockscreen for wayland using dioxus as the backend for building the UI.
Dioxus and its connected webview provide a great deal of flexibility and simplicity in design and configuration that would be challenging to implement from the ground up using wgpu directly or some other way.

However, restrictions around building a lockscreen make it more complicated than simply spawning a desktop window using dioxus-desktop. Lockscreens typically use the wayland ext-session-lock-v1 protocol which assigns a new wayland surface to render to. There are existing libraries that make implementing the protocol fairly straight-forward such as smithay-toolkit: https://github.com/Smithay/client-toolkit/blob/master/examples/session_lock.rs, however I'm not sure how to connect the two libraries together in a meaningful way.

It seems like i need to find some way to invisibly render dioxus's webview to a hidden surface and then copy the internal buffer from dioxus to the lockscreen surface but I'm not sure if there is even a way to go about doing that.

Implement Suggestion

I saw that dioxus supports custom renderers but that seems like overkill or maybe even the wrong direction since I still want to render it to a webview, just translate the pixels from one location to another. Perhaps there could be some way to expose the underlying wayland components in dioxus-desktop? I'm rather ignorant on the complexities for such a thing.

@ealmloff ealmloff added enhancement New feature or request desktop Suggestions related to the desktop renderer labels May 14, 2024
@ealmloff
Copy link
Member

I'm not familiar with wayland lock screens, but wry does expose methods to render a webview inside other windows which may be helpful. Dioxus could probably expose an API that allows you to do something similar

@imgurbot12
Copy link
Author

Thanks for the response. I did actually try using wry directly, unfortunately wry does not yet have support for spawning from an existing window as a child for wayland as of yet.

Wry uses tao, which uses gtk as the backend for their windows on wayland and according to their documentation and examples it doesn't seem possible. quoted from those docs:
If you want to support X11 and Wayland at the same time, we recommend using WebViewExtUnix::new_gtk or WebViewBuilderExtUnix::new_gtk with gtk::Fixed.
their examples integrating with other renderers seems to confirm this as well
https://github.com/tauri-apps/wry/blob/dev/examples/wgpu.rs#L205
https://github.com/tauri-apps/wry/blob/dev/examples/winit.rs#L25

i assume gtk doesn't have the support for using a foreign surface anymore in gtk4 since it appears the exact sort of call i needed has been removed since the transition from gtk3: https://gitlab.gnome.org/GNOME/gtk/-/issues/2132

@ealmloff ealmloff added the blocked Blocked by another PR/Issue label May 14, 2024
@imgurbot12
Copy link
Author

I've unfortunately given up on the idea for the moment and have opted to use iced instead since I can integrate it directly with wgpu which thankfully can use a foreign surface.
https://github.com/Smithay/client-toolkit/blob/master/examples/wgpu.rs#L64

though this means I have to implement my own rendering backend for iced since im not using it through winit which comes with a lot of the extras needed for doing it easily.

I'd be happy to come back to it if there was some other way which is why I've reached out and asked as an issue lol.

@imgurbot12
Copy link
Author

I'm going to close this issue since i ended up going with an alternative solution.

Considering how far downstream the issue ultimately is, as its specific to gtk, i don't think its likely this will change for potentially years even so there seems little value in hoping for an eventual implementation via exposing some method with wry.

It would theoretically be possible via an integration with wgpu using blitz but blitz seems like it would need a ton of enhancements to fully support what I'm hoping to achieve as well.
Thanks for the support :)

lockscreen is complete if anyone's interested!
https://github.com/imgurbot12/dynlock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by another PR/Issue desktop Suggestions related to the desktop renderer enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants