aboutsummaryrefslogtreecommitdiff
path: root/niri-ipc
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-28 11:40:16 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commit6c52077d922dce3a9b57c6785647b6befb700ac9 (patch)
treeedc2edb081630600c95e9356be9e43d5a2eea240 /niri-ipc
parent73bf7b1730e6911adb09d8253035f4510d83dbe0 (diff)
downloadniri-6c52077d922dce3a9b57c6785647b6befb700ac9.tar.gz
niri-6c52077d922dce3a9b57c6785647b6befb700ac9.tar.bz2
niri-6c52077d922dce3a9b57c6785647b6befb700ac9.zip
Add move-floating-window action
Diffstat (limited to 'niri-ipc')
-rw-r--r--niri-ipc/src/lib.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs
index 8ff2ba5c..30704b40 100644
--- a/niri-ipc/src/lib.rs
+++ b/niri-ipc/src/lib.rs
@@ -476,6 +476,29 @@ pub enum Action {
FocusTiling {},
/// Toggles the focus between the floating and the tiling layout.
SwitchFocusBetweenFloatingAndTiling {},
+ /// Move a floating window on screen.
+ #[cfg_attr(feature = "clap", clap(about = "Move the floating window on screen"))]
+ MoveFloatingWindow {
+ /// Id of the window to move.
+ ///
+ /// If `None`, uses the focused window.
+ #[cfg_attr(feature = "clap", arg(long))]
+ id: Option<u64>,
+
+ /// How to change the X position.
+ #[cfg_attr(
+ feature = "clap",
+ arg(short, long, default_value = "+0", allow_negative_numbers = true)
+ )]
+ x: PositionChange,
+
+ /// How to change the Y position.
+ #[cfg_attr(
+ feature = "clap",
+ arg(short, long, default_value = "+0", allow_negative_numbers = true)
+ )]
+ y: PositionChange,
+ },
}
/// Change in window or column size.
@@ -492,6 +515,16 @@ pub enum SizeChange {
AdjustProportion(f64),
}
+/// Change in floating window position.
+#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
+#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
+pub enum PositionChange {
+ /// Set the position in logical pixels.
+ SetFixed(f64),
+ /// Add or subtract to the current position in logical pixels.
+ AdjustFixed(f64),
+}
+
/// Workspace reference (id, index or name) to operate on.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
@@ -992,6 +1025,25 @@ impl FromStr for SizeChange {
}
}
+impl FromStr for PositionChange {
+ type Err = &'static str;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ let value = s;
+ match value.bytes().next() {
+ Some(b'-' | b'+') => {
+ let value = value.parse().map_err(|_| "error parsing value")?;
+ Ok(Self::AdjustFixed(value))
+ }
+ Some(_) => {
+ let value = value.parse().map_err(|_| "error parsing value")?;
+ Ok(Self::SetFixed(value))
+ }
+ None => Err("value is missing"),
+ }
+ }
+}
+
impl FromStr for LayoutSwitchTarget {
type Err = &'static str;