Open emigr2k1 opened 3 years ago
You can get the display by calling https://gtk-rs.org/docs/gdkx11/struct.X11Window.html#method.get_display
But I need a pointer to the xlib display, something I can use across FFI boundaries for programs that expect an xlib display structure.
I believe get_display
only returns a Rust type which is a wrapper around the actual pointer? Unless I'm misunderstanding something.
It returns an x11::xlib::Display
. I don't actually know how to use that or how to get the underlying raw pointer out of that again.
@GuillaumeGomez ?
xlib crate doesn't provide any safe bindings, just raw pointers so that should be fine for your use case?
How does this even work then? The function returns a Display
, not a *mut Display
. And Display
is an opaque enum Display {}
:)
Maybe the function should actually return a *mut Display
?
That's also UB btw, enum Display {}
has no variants, so there can't be a value of that type and you also can't have a pointer to such a value (because such a value can't exist!). Not our bug, but maybe something to fix in the x11
crate...
Also why is there no
get_display()
in git anymore?
it was never there https://github.com/gtk-rs/gtk-rs/blob/46ed982c1698e6657e455ebc697cc3596ebb4da0/gdkx11/Gir.toml#L96
Why does it exist in the docs then: https://gtk-rs.org/docs/gdkx11/struct.X11Window.html#method.get_display ?
It returns an
x11::xlib::Display
. I don't actually know how to use that or how to get the underlying raw pointer out of that again.
Oh. I was checking the docs here and here it says it returns a gdk::Display
.
I'll see if I can make it work
@emi2k01 Any updates here?
Should be very similar to the changes at https://github.com/gtk-rs/gtk4-rs/pull/281 btw :)
I was trying to get the pointer in similar manner this morning. Here's how I did it if anyone is interested https://github.com/wusyong/gtk-widget-in-x11-window/blob/main/src/main.rs#L17
I'm trying to use GDK_DISPLAY_XDISPLAY() or gdk_x11_display_get_xdisplay () but I can't find a way to get a raw pointer to the xlib display using gdkx11.
The purpose of this is to use it in raw-window-handle
How can I do it?
Thanks!