#![allow(dead_code, unreachable_pub)]
#[allow(warnings)]
mod image_utils;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "windows")]
use windows as backend;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
use macos as backend;
#[cfg(target_os = "linux")]
mod linux_x11;
#[cfg(target_os = "linux")]
mod linux_wayland;
use image::RgbaImage;
#[derive(Debug, Clone)]
pub struct Screen {
pub id: u32,
pub x: i32,
pub y: i32,
pub width: u32,
pub height: u32,
pub scale_factor: f32,
}
impl Screen {
pub fn all() -> Result<Vec<Screen>, String> {
#[cfg(target_os = "linux")]
{
if crate::screens::linux_wayland::is_wayland() {
return crate::screens::linux_wayland::all();
}
return crate::screens::linux_x11::all();
}
#[cfg(not(target_os = "linux"))]
{
backend::all()
}
}
pub fn capture(&self) -> Result<RgbaImage, String> {
#[cfg(target_os = "linux")]
{
if crate::screens::linux_wayland::is_wayland() {
return crate::screens::linux_wayland::capture(self);
}
return crate::screens::linux_x11::capture(self);
}
#[cfg(not(target_os = "linux"))]
{
backend::capture(self)
}
}
pub fn capture_area(&self, x: i32, y: i32, width: u32, height: u32) -> Result<RgbaImage, String> {
#[cfg(target_os = "linux")]
{
if crate::screens::linux_wayland::is_wayland() {
return crate::screens::linux_wayland::capture_area(self, x, y, width, height);
}
return crate::screens::linux_x11::capture_area(self, x, y, width, height);
}
#[cfg(not(target_os = "linux"))]
{
backend::capture_area(self, x, y, width, height)
}
}
}