srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/config/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'crates/config/src/engine')
-rw-r--r--crates/config/src/engine/register.rs1
-rw-r--r--crates/config/src/engine/window.rs20
2 files changed, 21 insertions, 0 deletions
diff --git a/crates/config/src/engine/register.rs b/crates/config/src/engine/register.rs
index 77aede9..1bbe706 100644
--- a/crates/config/src/engine/register.rs
+++ b/crates/config/src/engine/register.rs
@@ -41,6 +41,7 @@ impl Engine {
window.set("toggle_pin", self.fn_window_action(WindowAction::TogglePin)?)?;
window.set("focus", self.fn_window_focus_direction()?)?;
window.set("move", self.fn_window_move_direction()?)?;
+ window.set("resize", self.fn_window_resize_direction()?)?;
window.set("next", self.fn_window_cycle(true)?)?;
window.set("prev", self.fn_window_cycle(false)?)?;
window.set("set_decorations", self.fn_window_set_decorations()?)?;
diff --git a/crates/config/src/engine/window.rs b/crates/config/src/engine/window.rs
index 61e7b89..7aa2085 100644
--- a/crates/config/src/engine/window.rs
+++ b/crates/config/src/engine/window.rs
@@ -66,6 +66,26 @@ impl Engine {
})?)
}
+ /// `srd.window.resize("right", "grow")` - grow or shrink the focused
+ /// window one step along that axis. The second argument defaults to
+ /// growing, so `srd.window.resize("right")` reads naturally.
+ pub(super) fn fn_window_resize_direction(&self) -> Result<mlua::Function<'_>> {
+ let state = self.state.clone();
+ Ok(self.lua.create_function(move |_, (direction, mode): (String, Option<String>)| {
+ let dir = parse_direction(&direction, "srd.window.resize")?;
+ let grow = match mode.as_deref() {
+ None | Some("grow") => true,
+ Some("shrink") => false,
+ Some(other) => {
+ return Err(mlua::Error::RuntimeError(format!("srd.window.resize: expected \"grow\" or \"shrink\", got {other:?}")))
+ }
+ };
+ let wm = state.borrow().wm.clone();
+ wm.borrow_mut().resize_window_direction(dir, grow);
+ Ok(())
+ })?)
+ }
+
/// `srd.window.next()` / `srd.window.prev()` - cycle focus through the
/// windows on the current workspace (Hyprland's `cyclenext`).
pub(super) fn fn_window_cycle(&self, forward: bool) -> Result<mlua::Function<'_>> {