CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
44 lines
1.9 KiB
Rust
44 lines
1.9 KiB
Rust
use eframe::egui;
|
|
use x11rb::connection::Connection;
|
|
use x11rb::protocol::randr;
|
|
use x11rb::protocol::xproto::{AtomEnum, ConnectionExt};
|
|
|
|
#[derive(PartialEq)]
|
|
pub enum Backend { X11, Wayland }
|
|
|
|
pub fn choose_backend() -> Backend {
|
|
let has_x11 = std::env::var_os("DISPLAY").is_some_and(|value| !value.is_empty());
|
|
let has_wayland = std::env::var_os("WAYLAND_DISPLAY").is_some_and(|value| !value.is_empty());
|
|
if has_x11 {
|
|
if has_wayland { std::env::remove_var("WAYLAND_DISPLAY"); }
|
|
Backend::X11
|
|
} else {
|
|
Backend::Wayland
|
|
}
|
|
}
|
|
|
|
pub fn primary_work_area(pixels_per_point: f32) -> Option<egui::Rect> {
|
|
let (connection, screen_number) = x11rb::connect(None).ok()?;
|
|
let root = connection.setup().roots.get(screen_number)?.root;
|
|
|
|
let monitors = randr::get_monitors(&connection, root, true).ok()?.reply().ok()?.monitors;
|
|
let monitor = monitors.iter().find(|monitor| monitor.primary).or_else(|| monitors.first())?;
|
|
let mut area = egui::Rect::from_min_size(
|
|
egui::pos2(monitor.x as f32, monitor.y as f32),
|
|
egui::vec2(monitor.width as f32, monitor.height as f32),
|
|
);
|
|
|
|
let atom = connection.intern_atom(false, b"_NET_WORKAREA").ok()?.reply().ok()?.atom;
|
|
let reply = connection.get_property(false, root, atom, AtomEnum::CARDINAL, 0, 4).ok()?.reply().ok()?;
|
|
if let Some(mut values) = reply.value32() {
|
|
if let (Some(x), Some(y), Some(width), Some(height)) = (values.next(), values.next(), values.next(), values.next()) {
|
|
let work = egui::Rect::from_min_size(egui::pos2(x as f32, y as f32), egui::vec2(width as f32, height as f32));
|
|
area = area.intersect(work);
|
|
}
|
|
}
|
|
if area.width() <= 0.0 || area.height() <= 0.0 { return None; }
|
|
|
|
let scale = 1.0 / pixels_per_point;
|
|
Some(egui::Rect::from_min_max(egui::pos2(area.left() * scale, area.top() * scale), egui::pos2(area.right() * scale, area.bottom() * scale)))
|
|
}
|