|
@@ -155,6 +155,13 @@ impl<R: Runtime> Window<R> {
|
|
|
}
|
|
|
|
|
|
/// Creates a new webview window.
|
|
|
+ ///
|
|
|
+ /// # Panics
|
|
|
+ ///
|
|
|
+ /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
+ /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
+ ///
|
|
|
+ /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn create_window<F>(
|
|
|
&mut self,
|
|
|
label: String,
|
|
@@ -310,37 +317,16 @@ impl<R: Runtime> Window<R> {
|
|
|
}
|
|
|
|
|
|
/// Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn scale_factor(&self) -> crate::Result<f64> {
|
|
|
self.window.dispatcher.scale_factor().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Returns the position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn inner_position(&self) -> crate::Result<PhysicalPosition<i32>> {
|
|
|
self.window.dispatcher.inner_position().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Returns the position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn outer_position(&self) -> crate::Result<PhysicalPosition<i32>> {
|
|
|
self.window.dispatcher.outer_position().map_err(Into::into)
|
|
|
}
|
|
@@ -348,13 +334,6 @@ impl<R: Runtime> Window<R> {
|
|
|
/// Returns the physical size of the window's client area.
|
|
|
///
|
|
|
/// The client area is the content of the window, excluding the title bar and borders.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn inner_size(&self) -> crate::Result<PhysicalSize<u32>> {
|
|
|
self.window.dispatcher.inner_size().map_err(Into::into)
|
|
|
}
|
|
@@ -362,73 +341,31 @@ impl<R: Runtime> Window<R> {
|
|
|
/// Returns the physical size of the entire window.
|
|
|
///
|
|
|
/// These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn outer_size(&self) -> crate::Result<PhysicalSize<u32>> {
|
|
|
self.window.dispatcher.outer_size().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Gets the window's current fullscreen state.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn is_fullscreen(&self) -> crate::Result<bool> {
|
|
|
self.window.dispatcher.is_fullscreen().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Gets the window's current maximized state.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn is_maximized(&self) -> crate::Result<bool> {
|
|
|
self.window.dispatcher.is_maximized().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Gets the window’s current decoration state.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn is_decorated(&self) -> crate::Result<bool> {
|
|
|
self.window.dispatcher.is_decorated().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Gets the window’s current resizable state.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn is_resizable(&self) -> crate::Result<bool> {
|
|
|
self.window.dispatcher.is_resizable().map_err(Into::into)
|
|
|
}
|
|
|
|
|
|
/// Gets the window's current vibility state.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn is_visible(&self) -> crate::Result<bool> {
|
|
|
self.window.dispatcher.is_visible().map_err(Into::into)
|
|
|
}
|
|
@@ -440,13 +377,6 @@ impl<R: Runtime> Window<R> {
|
|
|
/// ## Platform-specific
|
|
|
///
|
|
|
/// - **Linux:** Unsupported
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn current_monitor(&self) -> crate::Result<Option<Monitor>> {
|
|
|
self
|
|
|
.window
|
|
@@ -463,13 +393,6 @@ impl<R: Runtime> Window<R> {
|
|
|
/// ## Platform-specific
|
|
|
///
|
|
|
/// - **Linux:** Unsupported
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn primary_monitor(&self) -> crate::Result<Option<Monitor>> {
|
|
|
self
|
|
|
.window
|
|
@@ -484,13 +407,6 @@ impl<R: Runtime> Window<R> {
|
|
|
/// ## Platform-specific
|
|
|
///
|
|
|
/// - **Linux:** Unsupported
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn available_monitors(&self) -> crate::Result<Vec<Monitor>> {
|
|
|
self
|
|
|
.window
|
|
@@ -501,25 +417,11 @@ impl<R: Runtime> Window<R> {
|
|
|
}
|
|
|
|
|
|
/// Returns the native handle that is used by this window.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
#[cfg(target_os = "macos")]
|
|
|
pub fn ns_window(&self) -> crate::Result<*mut std::ffi::c_void> {
|
|
|
self.window.dispatcher.ns_window().map_err(Into::into)
|
|
|
}
|
|
|
/// Returns the native handle that is used by this window.
|
|
|
- ///
|
|
|
- /// # Panics
|
|
|
- ///
|
|
|
- /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
- /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
- ///
|
|
|
- /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
#[cfg(windows)]
|
|
|
pub fn hwnd(&self) -> crate::Result<*mut std::ffi::c_void> {
|
|
|
self
|
|
@@ -628,6 +530,12 @@ impl<R: Runtime> Window<R> {
|
|
|
}
|
|
|
|
|
|
/// Closes this window.
|
|
|
+ /// # Panics
|
|
|
+ ///
|
|
|
+ /// - Panics if the event loop is not running yet, usually when called on the [`setup`](crate::Builder#method.setup) closure.
|
|
|
+ /// - Panics when called on the main thread, usually on the [`run`](crate::App#method.run) closure.
|
|
|
+ ///
|
|
|
+ /// You can spawn a task to use the API using [`crate::async_runtime::spawn`] or [`std::thread::spawn`] to prevent the panic.
|
|
|
pub fn close(&self) -> crate::Result<()> {
|
|
|
self.window.dispatcher.close().map_err(Into::into)
|
|
|
}
|