In gtkmm 4, how can one get the X Window ID of type XID
as defined in X11/X.h
, from inside a class, that inherits from Gtk::Widget
?
Not all of them have one.
Those widgets that do will implement the GtkNative
interface, which provides the gtk_native_get_surface
function, allowing you to obtain a GdkSurface
. In gtkmm, this will correspond to casting to to Gtk::Native
and calling get_surface
.
To obtain a Window
handle from that, you can use the GDK_SURFACE_XID
macro. For that, I don’t think a C++ wrapper exists; you will have to call Gdk::Surface::gobj
to obtain a GdkSurface *
and use the C API.