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-client: add easier way to create object from wl_proxy pointer #704

Open
i509VCB opened this issue Mar 3, 2024 · 1 comment
Open

Comments

@i509VCB
Copy link
Member

i509VCB commented Mar 3, 2024

Though this is possible via wayland-backend, users often do not immediately see how this can be done.

My proposal to make this work is an extension trait that is only implemented when a client_system feature is enabled. This would be easy to see in documentation.

pub trait WlProxyFromPtr: Proxy {
    unsafe fn from_ptr(conn: &Connection, ptr: *mut wl_proxy) -> Self;
}

#[cfg(feature = "client_system")]
impl<T: Proxy> WlProxyFromPtr for T {
    unsafe fn from_ptr(conn: &Connection, ptr: *mut wl_proxy) -> Self {
        let id = unsafe { ObjectId::from_ptr(Self::interface(), ptr) };
        Self::from_id(conn, id)
    }
}
@i509VCB i509VCB changed the title wayland-client add easier way to create object from wl_proxy pointer wayland-client: add easier way to create object from wl_proxy pointer Mar 3, 2024
@elinorbgr
Copy link
Member

users often do not immediately see how this can be done

I wonder if this may be solved through documentation instead?

There is imo a strong appeal in having the *_system features contained to a single crate, as this removes a lot of surprises and headaches.

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