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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::translate::*;
use std::fmt;

glib::wrapper! {
    /// The Wayland implementation of [`gdk::Display`][crate::gdk::Display].
    ///
    /// Beyond the regular [`gdk::Display`][crate::gdk::Display] API, the Wayland implementation
    /// provides access to Wayland objects such as the `wl_display` with
    /// [``wl_display()``][`Self::wl_display()`], the `wl_compositor` with
    /// [``wl_compositor()``][`Self::wl_compositor()`].
    ///
    /// You can find out what Wayland globals are supported by a display
    /// with [``query_registry()``][`Self::query_registry()`].
    ///
    /// # Implements
    ///
    /// [`trait@gdk::prelude::DisplayExt`]
    #[doc(alias = "GdkWaylandDisplay")]
    pub struct WaylandDisplay(Object<ffi::GdkWaylandDisplay, ffi::GdkWaylandDisplayClass>) @extends gdk::Display;

    match fn {
        type_ => || ffi::gdk_wayland_display_get_type(),
    }
}

impl WaylandDisplay {
    /// Gets the startup notification ID for a Wayland display, or [`None`]
    /// if no ID has been defined.
    ///
    /// # Returns
    ///
    /// the startup notification ID for `self`
    #[doc(alias = "gdk_wayland_display_get_startup_notification_id")]
    #[doc(alias = "get_startup_notification_id")]
    pub fn startup_notification_id(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::gdk_wayland_display_get_startup_notification_id(
                self.to_glib_none().0,
            ))
        }
    }

    /// Returns [`true`] if the the interface was found in the display
    /// `wl_registry.global` handler.
    /// ## `global`
    /// global interface to query in the registry
    ///
    /// # Returns
    ///
    /// [`true`] if the global is offered by the compositor
    #[doc(alias = "gdk_wayland_display_query_registry")]
    pub fn query_registry(&self, global: &str) -> bool {
        unsafe {
            from_glib(ffi::gdk_wayland_display_query_registry(
                self.to_glib_none().0,
                global.to_glib_none().0,
            ))
        }
    }

    /// Sets the cursor theme for the given `self`.
    /// ## `name`
    /// the new cursor theme
    /// ## `size`
    /// the size to use for cursors
    #[doc(alias = "gdk_wayland_display_set_cursor_theme")]
    pub fn set_cursor_theme(&self, name: &str, size: i32) {
        unsafe {
            ffi::gdk_wayland_display_set_cursor_theme(
                self.to_glib_none().0,
                name.to_glib_none().0,
                size,
            );
        }
    }

    /// Sets the startup notification ID for a display.
    ///
    /// This is usually taken from the value of the `DESKTOP_STARTUP_ID`
    /// environment variable, but in some cases (such as the application not
    /// being launched using `exec()`) it can come from other sources.
    ///
    /// The startup ID is also what is used to signal that the startup is
    /// complete (for example, when opening a window or when calling
    /// `Gdk::`Display::notify_startup_complete()``).
    /// ## `startup_id`
    /// the startup notification ID (must be valid utf8)
    #[doc(alias = "gdk_wayland_display_set_startup_notification_id")]
    pub fn set_startup_notification_id(&self, startup_id: &str) {
        unsafe {
            ffi::gdk_wayland_display_set_startup_notification_id(
                self.to_glib_none().0,
                startup_id.to_glib_none().0,
            );
        }
    }
}

impl fmt::Display for WaylandDisplay {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("WaylandDisplay")
    }
}