use image::RgbaImage;
use crate::{Monitor, error::XCapResult, platform::impl_window::ImplWindow};
#[derive(Debug, Clone)]
pub struct Window {
pub(crate) impl_window: ImplWindow,
}
impl Window {
pub(crate) fn new(impl_window: ImplWindow) -> Window {
Window { impl_window }
}
}
impl Window {
pub fn all() -> XCapResult<Vec<Window>> {
let windows = ImplWindow::all()?
.iter()
.map(|impl_window| Window::new(impl_window.clone()))
.collect();
Ok(windows)
}
}
impl Window {
pub fn id(&self) -> XCapResult<u32> {
self.impl_window.id()
}
pub fn pid(&self) -> XCapResult<u32> {
self.impl_window.pid()
}
pub fn app_name(&self) -> XCapResult<String> {
self.impl_window.app_name()
}
pub fn title(&self) -> XCapResult<String> {
self.impl_window.title()
}
pub fn current_monitor(&self) -> XCapResult<Monitor> {
Ok(Monitor::new(self.impl_window.current_monitor()?))
}
pub fn x(&self) -> XCapResult<i32> {
self.impl_window.x()
}
pub fn y(&self) -> XCapResult<i32> {
self.impl_window.y()
}
pub fn z(&self) -> XCapResult<i32> {
self.impl_window.z()
}
pub fn width(&self) -> XCapResult<u32> {
self.impl_window.width()
}
pub fn height(&self) -> XCapResult<u32> {
self.impl_window.height()
}
pub fn is_minimized(&self) -> XCapResult<bool> {
self.impl_window.is_minimized()
}
pub fn is_maximized(&self) -> XCapResult<bool> {
self.impl_window.is_maximized()
}
pub fn is_focused(&self) -> XCapResult<bool> {
self.impl_window.is_focused()
}
}
impl Window {
pub fn capture_image(&self) -> XCapResult<RgbaImage> {
self.impl_window.capture_image()
}
}