1
0
mirror of https://github.com/emersion/kanshi synced 2024-11-23 00:02:16 +01:00

Adjusted syntax to match sway and added flipping

This commit is contained in:
mlbullett 2018-11-27 12:06:24 +01:00
parent 359313bf2e
commit e77b444448
2 changed files with 16 additions and 15 deletions

@ -41,14 +41,15 @@ impl SwayFrontend {
if saved.width > 0 && saved.height > 0 {
l += &format!(" resolution {}x{}", saved.width, saved.height);
}
if saved.rotation > 0 {
l += &format!(" transform {}", saved.rotation);
let mut v = ["90".to_string(),"180".into(),"270".into(),"flipped".into(),"flipped-90".into(),"flipped-180".into(),"flipped-270".into()];
if v.contains(&saved.transform) {
l += &format!(" transform {}", saved.transform.trim());
} else {
l += &format!(" transform normal");
}
if saved.scale > 0. {
l += &format!(" scale {}", saved.scale);
}
}
cmds.push(l);
if saved.primary {

@ -22,7 +22,7 @@ pub struct SavedOutput {
pub rate: f32,
pub x: i32,
pub y: i32,
pub rotation: i32,
pub transform: String,
//pub reflect_x: bool,
//pub reflect_y: bool,
pub primary: bool,
@ -91,10 +91,10 @@ impl Store for GnomeStore {
}
if let Some(c) = e.get_child("rotation") {
match c.text.as_ref().unwrap().trim() {
"right" => o.rotation = 90,
"inverted" => o.rotation = 180,
"left" => o.rotation = 270,
_ => o.rotation = 0,
"right" => o.transform = "90".to_string(),
"inverted" => o.transform = "180".to_string(),
"left" => o.transform = "270".to_string(),
_ => o.transform = "normal".to_string(),
};
}
if let Some(c) = e.get_child("primary") {
@ -133,7 +133,7 @@ enum OutputArg {
Disable,
Resolution(i32, i32),
Position(i32, i32),
Rotation(i32),
Transform(String),
Scale(f32),
}
@ -154,7 +154,7 @@ fn parse_output_with_args(name: String, args: Vec<OutputArg>) -> SavedOutput {
o.x = x;
o.y = y;
},
OutputArg::Rotation(r) => o.rotation = r,
OutputArg::Transform(t) => o.transform = t,
OutputArg::Scale(f) => o.scale = f,
}
}
@ -211,11 +211,11 @@ named!(parse_position<&[u8], OutputArg>, do_parse!(
>> (OutputArg::Position(x, y))
));
named!(parse_rotation<&[u8], OutputArg>, do_parse!(
tag!("rotation")
named!(parse_transform<&[u8], OutputArg>, do_parse!(
tag!("transform")
>> parse_space
>> r: parse_i32
>> (OutputArg::Rotation(r))
>> t: parse_string
>> (OutputArg::Transform(t))
));
named!(parse_f32<&[u8], f32>, ws!(nom::float));
@ -229,7 +229,7 @@ named!(parse_scale<&[u8], OutputArg>, do_parse!(
named!(parse_output_arg<&[u8], OutputArg>, alt!(
parse_vendor | parse_product | parse_serial |
parse_disable | parse_resolution | parse_position | parse_rotation | parse_scale
parse_disable | parse_resolution | parse_position | parse_transform | parse_scale
));
enum ConfigurationArg {