Skip to content

Commit

Permalink
Add Window::to_standard_api_type helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopyl committed Jun 9, 2024
1 parent fdcc90c commit 404adaf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions extensions/src/gui/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ impl HostGui {
}
}

// TODO: use GuiSize?
/// Requests the host to resize the parent window's client area to the given size.
///
/// The host doesn't have to call the plugin's `set_size` method after accepting the request.
Expand Down
15 changes: 15 additions & 0 deletions extensions/src/gui/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ impl<'a> Window<'a> {
_api_lifetime: PhantomData,
}
}

/// Matches this window's GUI API to one of the standard APIs.
///
/// If the value matches one of the [`WIN32`](GuiApiType::WIN32), [`COCOA`](GuiApiType::COCOA),
/// [`X11`](GuiApiType::X11), or [`WAYLAND`](GuiApiType::WAYLAND) constants, then a window
/// with that constant as its API type is returned. Otherwise, [`None`] is returned.
pub fn to_standard_api_type(&self) -> Option<Window<'static>> {
Some(Window {
raw: clap_window {
api: self.api_type().to_standard_api()?.0.as_ptr(),
specific: self.raw.specific,
},
_api_lifetime: PhantomData,
})
}
}

#[cfg(feature = "raw-window-handle_05")]
Expand Down

0 comments on commit 404adaf

Please sign in to comment.