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

Proxy tags #705

Open
jgcodes2020 opened this issue Mar 5, 2024 · 3 comments
Open

Proxy tags #705

jgcodes2020 opened this issue Mar 5, 2024 · 3 comments

Comments

@jgcodes2020
Copy link

jgcodes2020 commented Mar 5, 2024

relevant docs: https://wayland.freedesktop.org/docs/html/apb.html#Client-classwl__proxy

libwayland-client offers functions for associating a tag with a proxy:

  • const char* const* wl_proxy_get_tag(struct wl_proxy* proxy)
  • void wl_proxy_set_tag(struct wl_proxy* proxy, const char* const* tag)

According to the docs, one obtains the const char* const* by creating a const C string, then taking a pointer to that pointer:

const char* const my_tag = "com.github.smithay.wayland_rs";

// placeholder function that takes a proxy and attaches my_tag to it
void attach_tag(struct wl_proxy* proxy) {
  wl_proxy_set_tag(proxy, &my_tag);
}

I'm opening this issue to discuss how we could wrap this functionality into a safe Rust API. I don't believe there's a nice way to convert &'static &'static ::std::ffi::CStr to the corresponding pointer.

@elinorbgr
Copy link
Member

Mostly, the core question I'd have is: do you have some use-case in mind for this?

My understanding is that such tags are useful as a way to bring back some semblance of type-safety in the mix, allowing to "typecheck" a proxy before trying to access its user-data. However wayland-rs already provides means to do so, thanks to the Rust type system.

So yeah, what kind of usecase would that cover that is not already covered by the wayland-rs API?

@jgcodes2020
Copy link
Author

jgcodes2020 commented Mar 5, 2024

winit currently treats every surface it doesn't know about as belonging to an SCTK decoration frame when dispatching events. However, this assumption breaks when someone else creates their own subsurface.

I need a way to check "Is this surface part of an SCTK frame?", and this seems like the best way, as it requires no knowledge of the surface's user data type.

EDIT: Note that this is intended for a future PR that introduces some backend work that will make implementing subsurfaces and popups easier in winit.

@elinorbgr
Copy link
Member

I need a way to check "Is this surface part of an SCTK frame?"

This is an API that should be trivial for SCTK itself to provide though, without requiring any change to wayland-rs

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

No branches or pull requests

2 participants