config: Extract gestures
Browse files at this commit3c11004515d5c1b6773c0ddc7c44ecfa0e451ca2Parent: 02e3f9f2 changed files +59 -56
- niri-config/src/gestures.rs +57 -0
- niri-config/src/lib.rs +2 -56
niri-config/src/gestures.rsadded+57 -0
| @@ -0,0 +1,57 @@ | |||
| 1 | +use crate::FloatOrInt; | ||
| 2 | + | ||
| 3 | +#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)] | ||
| 4 | +pub struct Gestures { | ||
| 5 | + #[knuffel(child, default)] | ||
| 6 | + pub dnd_edge_view_scroll: DndEdgeViewScroll, | ||
| 7 | + #[knuffel(child, default)] | ||
| 8 | + pub dnd_edge_workspace_switch: DndEdgeWorkspaceSwitch, | ||
| 9 | + #[knuffel(child, default)] | ||
| 10 | + pub hot_corners: HotCorners, | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 14 | +pub struct DndEdgeViewScroll { | ||
| 15 | + #[knuffel(child, unwrap(argument), default = Self::default().trigger_width)] | ||
| 16 | + pub trigger_width: FloatOrInt<0, 65535>, | ||
| 17 | + #[knuffel(child, unwrap(argument), default = Self::default().delay_ms)] | ||
| 18 | + pub delay_ms: u16, | ||
| 19 | + #[knuffel(child, unwrap(argument), default = Self::default().max_speed)] | ||
| 20 | + pub max_speed: FloatOrInt<0, 1_000_000>, | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +impl Default for DndEdgeViewScroll { | ||
| 24 | + fn default() -> Self { | ||
| 25 | + Self { | ||
| 26 | + trigger_width: FloatOrInt(30.), // Taken from GTK 4. | ||
| 27 | + delay_ms: 100, | ||
| 28 | + max_speed: FloatOrInt(1500.), | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 34 | +pub struct DndEdgeWorkspaceSwitch { | ||
| 35 | + #[knuffel(child, unwrap(argument), default = Self::default().trigger_height)] | ||
| 36 | + pub trigger_height: FloatOrInt<0, 65535>, | ||
| 37 | + #[knuffel(child, unwrap(argument), default = Self::default().delay_ms)] | ||
| 38 | + pub delay_ms: u16, | ||
| 39 | + #[knuffel(child, unwrap(argument), default = Self::default().max_speed)] | ||
| 40 | + pub max_speed: FloatOrInt<0, 1_000_000>, | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | +impl Default for DndEdgeWorkspaceSwitch { | ||
| 44 | + fn default() -> Self { | ||
| 45 | + Self { | ||
| 46 | + trigger_height: FloatOrInt(50.), | ||
| 47 | + delay_ms: 100, | ||
| 48 | + max_speed: FloatOrInt(1500.), | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)] | ||
| 54 | +pub struct HotCorners { | ||
| 55 | + #[knuffel(child)] | ||
| 56 | + pub off: bool, | ||
| 57 | +} | ||
niri-config/src/lib.rsmodified+2 -56
| @@ -21,6 +21,7 @@ use smithay::input::keyboard::Keysym; | |||
| 21 | 21 | ||
| 22 | pub mod animations; | 22 | pub mod animations; |
| 23 | pub mod appearance; | 23 | pub mod appearance; |
| 24 | +pub mod gestures; | ||
| 24 | pub mod input; | 25 | pub mod input; |
| 25 | pub mod layer_rule; | 26 | pub mod layer_rule; |
| 26 | pub mod layout; | 27 | pub mod layout; |
| @@ -32,6 +33,7 @@ pub use crate::animations::{ | |||
| 32 | Animation, AnimationCurve, AnimationKind, Animations, EasingParams, SpringParams, | 33 | Animation, AnimationCurve, AnimationKind, Animations, EasingParams, SpringParams, |
| 33 | }; | 34 | }; |
| 34 | pub use crate::appearance::*; | 35 | pub use crate::appearance::*; |
| 36 | +pub use crate::gestures::Gestures; | ||
| 35 | pub use crate::input::{Input, ModKey, ScrollMethod, TrackLayout, WarpMouseToFocusMode, Xkb}; | 37 | pub use crate::input::{Input, ModKey, ScrollMethod, TrackLayout, WarpMouseToFocusMode, Xkb}; |
| 36 | pub use crate::layer_rule::LayerRule; | 38 | pub use crate::layer_rule::LayerRule; |
| 37 | pub use crate::layout::*; | 39 | pub use crate::layout::*; |
| @@ -154,62 +156,6 @@ pub struct Clipboard { | |||
| 154 | pub disable_primary: bool, | 156 | pub disable_primary: bool, |
| 155 | } | 157 | } |
| 156 | 158 | ||
| 157 | -#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)] | ||
| 158 | -pub struct Gestures { | ||
| 159 | - #[knuffel(child, default)] | ||
| 160 | - pub dnd_edge_view_scroll: DndEdgeViewScroll, | ||
| 161 | - #[knuffel(child, default)] | ||
| 162 | - pub dnd_edge_workspace_switch: DndEdgeWorkspaceSwitch, | ||
| 163 | - #[knuffel(child, default)] | ||
| 164 | - pub hot_corners: HotCorners, | ||
| 165 | -} | ||
| 166 | - | ||
| 167 | -#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 168 | -pub struct DndEdgeViewScroll { | ||
| 169 | - #[knuffel(child, unwrap(argument), default = Self::default().trigger_width)] | ||
| 170 | - pub trigger_width: FloatOrInt<0, 65535>, | ||
| 171 | - #[knuffel(child, unwrap(argument), default = Self::default().delay_ms)] | ||
| 172 | - pub delay_ms: u16, | ||
| 173 | - #[knuffel(child, unwrap(argument), default = Self::default().max_speed)] | ||
| 174 | - pub max_speed: FloatOrInt<0, 1_000_000>, | ||
| 175 | -} | ||
| 176 | - | ||
| 177 | -impl Default for DndEdgeViewScroll { | ||
| 178 | - fn default() -> Self { | ||
| 179 | - Self { | ||
| 180 | - trigger_width: FloatOrInt(30.), // Taken from GTK 4. | ||
| 181 | - delay_ms: 100, | ||
| 182 | - max_speed: FloatOrInt(1500.), | ||
| 183 | - } | ||
| 184 | - } | ||
| 185 | -} | ||
| 186 | - | ||
| 187 | -#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 188 | -pub struct DndEdgeWorkspaceSwitch { | ||
| 189 | - #[knuffel(child, unwrap(argument), default = Self::default().trigger_height)] | ||
| 190 | - pub trigger_height: FloatOrInt<0, 65535>, | ||
| 191 | - #[knuffel(child, unwrap(argument), default = Self::default().delay_ms)] | ||
| 192 | - pub delay_ms: u16, | ||
| 193 | - #[knuffel(child, unwrap(argument), default = Self::default().max_speed)] | ||
| 194 | - pub max_speed: FloatOrInt<0, 1_000_000>, | ||
| 195 | -} | ||
| 196 | - | ||
| 197 | -impl Default for DndEdgeWorkspaceSwitch { | ||
| 198 | - fn default() -> Self { | ||
| 199 | - Self { | ||
| 200 | - trigger_height: FloatOrInt(50.), | ||
| 201 | - delay_ms: 100, | ||
| 202 | - max_speed: FloatOrInt(1500.), | ||
| 203 | - } | ||
| 204 | - } | ||
| 205 | -} | ||
| 206 | - | ||
| 207 | -#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)] | ||
| 208 | -pub struct HotCorners { | ||
| 209 | - #[knuffel(child)] | ||
| 210 | - pub off: bool, | ||
| 211 | -} | ||
| 212 | - | ||
| 213 | #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | 159 | #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] |
| 214 | pub struct Overview { | 160 | pub struct Overview { |
| 215 | #[knuffel(child, unwrap(argument), default = Self::default().zoom)] | 161 | #[knuffel(child, unwrap(argument), default = Self::default().zoom)] |