forge
Explore
Log in

Don't you dare go Hollow

config: Add merging for SwitchBinds

Browse files at this commit

eff41ab716dd36cbcf13cae2484907e01a14bbccIvan MolodetskikhParent: 0673260
niri-config/src/binds.rsmodified+13 -1
@@ -12,7 +12,7 @@ use smithay::input::keyboard::keysyms::KEY_NoSymbol;
12 use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};12 use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};
13 use smithay::input::keyboard::Keysym;13 use smithay::input::keyboard::Keysym;
14 14
15-use crate::utils::expect_only_children;15+use crate::utils::{expect_only_children, MergeWith};
16 16
17 #[derive(Debug, Default, PartialEq)]17 #[derive(Debug, Default, PartialEq)]
18 pub struct Binds(pub Vec<Bind>);18 pub struct Binds(pub Vec<Bind>);
@@ -77,6 +77,18 @@ pub struct SwitchBinds {
77 pub tablet_mode_off: Option<SwitchAction>,77 pub tablet_mode_off: Option<SwitchAction>,
78 }78 }
79 79
80+impl MergeWith<SwitchBinds> for SwitchBinds {
81+ fn merge_with(&mut self, part: &SwitchBinds) {
82+ merge_clone_opt!(
83+ (self, part),
84+ lid_open,
85+ lid_close,
86+ tablet_mode_on,
87+ tablet_mode_off,
88+ );
89+ }
90+}
91+
80 #[derive(knuffel::Decode, Debug, Clone, PartialEq)]92 #[derive(knuffel::Decode, Debug, Clone, PartialEq)]
81 pub struct SwitchAction {93 pub struct SwitchAction {
82 #[knuffel(child, unwrap(arguments))]94 #[knuffel(child, unwrap(arguments))]
niri-config/src/lib.rsmodified+1 -1
@@ -195,7 +195,7 @@ where
195 "gestures" => m_replace!(gestures),195 "gestures" => m_replace!(gestures),
196 "overview" => m_replace!(overview),196 "overview" => m_replace!(overview),
197 "xwayland-satellite" => m_replace!(xwayland_satellite),197 "xwayland-satellite" => m_replace!(xwayland_satellite),
198- "switch-events" => m_replace!(switch_events),198+ "switch-events" => m_merge!(switch_events),
199 "debug" => m_replace!(debug),199 "debug" => m_replace!(debug),
200 200
201 // Multipart sections.201 // Multipart sections.