#[non_exhaustive]pub enum WindowIdentifier {
}Expand description
Most portals interact with the user by showing dialogs.
These dialogs should generally be placed on top of the application window
that triggered them. To arrange this, the compositor needs to know about the
application window. Many portal requests expect a WindowIdentifier for
this reason.
Under X11, the WindowIdentifier should have the form x11:XID, where
XID is the XID of the application window in hexadecimal. Under Wayland, it
should have the form wayland:HANDLE, where HANDLE is a surface handle
obtained with the xdg-foreign protocol.
See also Parent window identifiers.
§Usage
§From an X11 XID
let identifier = WindowIdentifier::from_xid(212321);
/// Open some portals§From a Wayland Surface
The wayland feature must be enabled. The exported surface handle will be
unexported on Drop.
// let wl_surface = some_surface;
// let identifier = WindowIdentifier::from_wayland(wl_surface).await;
/// Open some portalsOr using a raw wl_surface pointer
// let wl_surface_ptr = some_surface;
// let wl_display_ptr = corresponding_display;
// let identifier = WindowIdentifier::from_wayland_raw(wl_surface_ptr, wl_display_ptr).await;
/// Open some portals§With GTK 4
The feature gtk4 must be enabled. You can get a
WindowIdentifier from a IsA<gtk4::Native> using WindowIdentifier::from_native
let widget = gtk4::Button::new();
let ctx = glib::MainContext::default();
ctx.spawn_async(async move {
let identifier = WindowIdentifier::from_native(&widget.native().unwrap()).await;
/// Open some portals
});The constructor should return a valid identifier under both X11 and Wayland
and fallback to the Default implementation otherwise.
§Other Toolkits
If you have access to RawWindowHandle you can convert it to a
WindowIdentifier with
let handle = RawWindowHandle::Xlib(XlibHandle::empty());
let identifier = WindowIdentifier::from_raw_handle(handle, None);
/// Open some portalsImplementations§
Source§impl WindowIdentifier
impl WindowIdentifier
Sourcepub fn from_xid(xid: c_ulong) -> Self
pub fn from_xid(xid: c_ulong) -> Self
Create an instance of WindowIdentifier from an X11 window’s XID.