1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::WaylandSurface;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
glib::wrapper! {
/// The Wayland implementation of [`gdk::Toplevel`][crate::gdk::Toplevel].
///
/// Beyond the [`gdk::Toplevel`][crate::gdk::Toplevel] API, the Wayland implementation
/// has API to set up cross-process parent-child relationships between
/// surfaces with [`export_handle()`][Self::export_handle()] and
/// [`set_transient_for_exported()`][Self::set_transient_for_exported()].
///
/// # Implements
///
/// [`WaylandSurfaceExt`][trait@crate::prelude::WaylandSurfaceExt], [`trait@gdk::prelude::SurfaceExt`], [`trait@gdk::prelude::ToplevelExt`], [`WaylandSurfaceExtManual`][trait@crate::prelude::WaylandSurfaceExtManual]
#[doc(alias = "GdkWaylandToplevel")]
pub struct WaylandToplevel(Object<ffi::GdkWaylandToplevel>) @extends WaylandSurface, gdk::Surface, @implements gdk::Toplevel;
match fn {
type_ => || ffi::gdk_wayland_toplevel_get_type(),
}
}
impl WaylandToplevel {
/// Asynchronously obtains a handle for a surface that can be passed
/// to other processes.
///
/// When the handle has been obtained, @callback will be called.
///
/// It is an error to call this function on a surface that is already
/// exported.
///
/// When the handle is no longer needed, [`unexport_handle()`][Self::unexport_handle()]
/// should be called to clean up resources.
///
/// The main purpose for obtaining a handle is to mark a surface
/// from another surface as transient for this one, see
/// [`set_transient_for_exported()`][Self::set_transient_for_exported()].
///
/// Note that this API depends on an unstable Wayland protocol,
/// and thus may require changes in the future.
/// ## `callback`
/// callback to call with the handle
///
/// # Returns
///
/// [`true`] if the handle has been requested, [`false`] if
/// an error occurred.
#[doc(alias = "gdk_wayland_toplevel_export_handle")]
pub fn export_handle<P: Fn(&WaylandToplevel, &str) + 'static>(&self, callback: P) -> bool {
let callback_data: Box_<P> = Box_::new(callback);
unsafe extern "C" fn callback_func<P: Fn(&WaylandToplevel, &str) + 'static>(
toplevel: *mut ffi::GdkWaylandToplevel,
handle: *const libc::c_char,
user_data: glib::ffi::gpointer,
) {
let toplevel = from_glib_borrow(toplevel);
let handle: Borrowed<glib::GString> = from_glib_borrow(handle);
let callback: &P = &*(user_data as *mut _);
(*callback)(&toplevel, handle.as_str());
}
let callback = Some(callback_func::<P> as _);
unsafe extern "C" fn destroy_func_func<P: Fn(&WaylandToplevel, &str) + 'static>(
data: glib::ffi::gpointer,
) {
let _callback: Box_<P> = Box_::from_raw(data as *mut _);
}
let destroy_call3 = Some(destroy_func_func::<P> as _);
let super_callback0: Box_<P> = callback_data;
unsafe {
from_glib(ffi::gdk_wayland_toplevel_export_handle(
self.to_glib_none().0,
callback,
Box_::into_raw(super_callback0) as *mut _,
destroy_call3,
))
}
}
/// Sets the application id on a [`gdk::Toplevel`][crate::gdk::Toplevel].
/// ## `application_id`
/// the application id for the @self
#[doc(alias = "gdk_wayland_toplevel_set_application_id")]
pub fn set_application_id(&self, application_id: &str) {
unsafe {
ffi::gdk_wayland_toplevel_set_application_id(
self.to_glib_none().0,
application_id.to_glib_none().0,
);
}
}
/// Marks @self as transient for the surface to which the given
/// @parent_handle_str refers.
///
/// Typically, the handle will originate from a
/// [`export_handle()`][Self::export_handle()] call in another process.
///
/// Note that this API depends on an unstable Wayland protocol,
/// and thus may require changes in the future.
/// ## `parent_handle_str`
/// an exported handle for a surface
///
/// # Returns
///
/// [`true`] if the surface has been marked as transient,
/// [`false`] if an error occurred.
#[doc(alias = "gdk_wayland_toplevel_set_transient_for_exported")]
pub fn set_transient_for_exported(&self, parent_handle_str: &str) -> bool {
unsafe {
from_glib(ffi::gdk_wayland_toplevel_set_transient_for_exported(
self.to_glib_none().0,
parent_handle_str.to_glib_none().0,
))
}
}
/// Destroys the handle that was obtained with
/// gdk_wayland_toplevel_export_handle().
///
/// It is an error to call this function on a surface that
/// does not have a handle.
///
/// Note that this API depends on an unstable Wayland protocol,
/// and thus may require changes in the future.
#[doc(alias = "gdk_wayland_toplevel_unexport_handle")]
pub fn unexport_handle(&self) {
unsafe {
ffi::gdk_wayland_toplevel_unexport_handle(self.to_glib_none().0);
}
}
}
impl fmt::Display for WaylandToplevel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("WaylandToplevel")
}
}