#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
mod linux;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(windows)]
mod windows;
use crate::monitor::MonitorExt;
pub trait WindowExt {
fn set_enabled(&self, enabled: bool);
fn is_enabled(&self) -> bool;
fn center(&self) {}
#[cfg(windows)]
fn draw_surface(
&self,
surface: &mut softbuffer::Surface<
std::sync::Arc<tao::window::Window>,
std::sync::Arc<tao::window::Window>,
>,
background_color: Option<tao::window::RGBA>,
);
}
#[cfg(mobile)]
impl WindowExt for tao::window::Window {
fn set_enabled(&self, _: bool) {}
fn is_enabled(&self) -> bool {
true
}
}
pub fn calculate_window_center_position(
window_size: tao::dpi::PhysicalSize<u32>,
target_monitor: tao::monitor::MonitorHandle,
) -> tao::dpi::PhysicalPosition<i32> {
let work_area = target_monitor.work_area();
tao::dpi::PhysicalPosition::new(
(work_area.size.width as i32 - window_size.width as i32) / 2 + work_area.position.x,
(work_area.size.height as i32 - window_size.height as i32) / 2 + work_area.position.y,
)
}