From 0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:56:00 +0200 Subject: Checkpoint: preserve all uncommitted rust-rewrite worktree work Safety commit before reconciling this worktree with main, which has diverged with its own separate fixes today. Nothing here is reviewed or curated yet - this exists purely so none of this work can be lost to a git operation, disk issue, or worktree cleanup while that reconciliation happens. --- crates/config/src/engine/general.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'crates/config/src/engine/general.rs') diff --git a/crates/config/src/engine/general.rs b/crates/config/src/engine/general.rs index 98cfebe..94b029b 100644 --- a/crates/config/src/engine/general.rs +++ b/crates/config/src/engine/general.rs @@ -194,6 +194,41 @@ impl Engine { })?) } + /// `srd.monitor.split(name, parts[, direction])` - divides connector + /// `name`'s real output into `parts` equal logical monitors for + /// placement/tiling purposes ("monitors inside monitors"), no new + /// `wl_output` involved - see `srdwm_core::monitor::MonitorSplit`'s + /// own doc comment for exactly what that does and doesn't give a + /// client. `direction` is `"columns"` (default, side-by-side) or + /// `"rows"` (stacked); any other value is treated as `"columns"` + /// rather than erroring, same "malformed value falls back to a + /// sensible default" stance other config setters already take. + /// `parts <= 1` clears an existing split for `name`. + pub(super) fn fn_monitor_split(&self) -> Result> { + let state = self.state.clone(); + Ok(self.lua.create_function(move |_, (name, parts, direction): (String, u32, Option)| { + let rows = matches!(direction.as_deref(), Some("rows")); + state.borrow().wm.borrow_mut().set_monitor_split(name, parts, rows); + Ok(()) + })?) + } + + /// `srd.monitor.scale(name, factor)` - sets connector `name`'s + /// output scale, applied the next time a backend brings that head up + /// (startup, hotplug, or re-enable). A physically large monitor with + /// the same pixel count as a smaller one (a big low-DPI external + /// display next to a small high-DPI laptop panel, say) can run below + /// `1.0` to show more logical desktop space rather than just larger + /// text at the same resolution. `factor <= 0` clears an existing + /// override. + pub(super) fn fn_monitor_scale(&self) -> Result> { + let state = self.state.clone(); + Ok(self.lua.create_function(move |_, (name, factor): (String, f64)| { + state.borrow().wm.borrow_mut().set_monitor_scale(name, factor); + Ok(()) + })?) + } + pub(super) fn fn_load(&self) -> Result> { let state = self.state.clone(); Ok(self.lua.create_function(move |lua, module: String| { -- cgit v1.2.3