1
0
Fork 0
forked from wry/wry

config: add resize action

This commit is contained in:
Julian Orth 2026-03-20 17:25:48 +01:00
parent 15c157b7a6
commit a1905ab971
14 changed files with 344 additions and 264 deletions

View file

@ -190,6 +190,12 @@ pub enum Action {
RemoveVirtualOutput {
name: String,
},
Resize {
dx1: i32,
dy1: i32,
dx2: i32,
dy2: i32,
},
}
#[derive(Debug, Clone, Default)]

View file

@ -3,7 +3,7 @@ use {
config::{
Action, SimpleCommand,
context::Context,
extractor::{Extractor, ExtractorError, arr, bol, n32, opt, str, val},
extractor::{Extractor, ExtractorError, arr, bol, n32, opt, s32, str, val},
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
parsers::{
StringParser, StringParserError,
@ -495,6 +495,21 @@ impl ActionParser<'_> {
name: name.value.to_string(),
})
}
fn parse_resize(&mut self, ext: &mut Extractor<'_>) -> ParseResult<Self> {
let (dx1, dy1, dx2, dy2) = ext.extract((
opt(s32("dx1")),
opt(s32("dy1")),
opt(s32("dx2")),
opt(s32("dy2")),
))?;
Ok(Action::Resize {
dx1: dx1.despan().unwrap_or(0),
dy1: dy1.despan().unwrap_or(0),
dx2: dx2.despan().unwrap_or(0),
dy2: dy2.despan().unwrap_or(0),
})
}
}
impl Parser for ActionParser<'_> {
@ -556,6 +571,7 @@ impl Parser for ActionParser<'_> {
"latch-mode" => self.parse_latch_mode(&mut ext),
"create-virtual-output" => self.parse_create_virtual_output(&mut ext),
"remove-virtual-output" => self.parse_remove_virtual_output(&mut ext),
"resize" => self.parse_resize(&mut ext),
v => {
ext.ignore_unused();
return Err(ActionParserError::UnknownType(v.to_string()).spanned(ty.span));

View file

@ -482,6 +482,9 @@ impl Action {
}
Action::CreateVirtualOutput { name } => b.new(move || create_virtual_output(&name)),
Action::RemoveVirtualOutput { name } => b.new(move || remove_virtual_output(&name)),
Action::Resize { dx1, dy1, dx2, dy2 } => {
window_or_seat!(s, s.resize(dx1, dy1, dx2, dy2))
}
}
}
}