miracle_plugin/
application.rs

1use super::bindings;
2use std::ffi::CStr;
3
4/// Identifies the application that owns a window.
5#[derive(Debug, Clone)]
6pub struct ApplicationInfo {
7    /// The name of the application.
8    pub name: String,
9
10    /// The internal id of the application
11    pub internal: u64,
12}
13
14impl ApplicationInfo {
15    #[doc(hidden)]
16    pub unsafe fn from_c(value: &bindings::miracle_application_info_t) -> Self {
17        let name = if value.application_name.is_null() {
18            String::new()
19        } else {
20            unsafe {
21                CStr::from_ptr(value.application_name)
22                    .to_string_lossy()
23                    .into_owned()
24            }
25        };
26        Self {
27            name,
28            internal: value.internal,
29        }
30    }
31}