From eff41ab716dd36cbcf13cae2484907e01a14bbcc Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 30 Sep 2025 08:33:43 +0300 Subject: config: Add merging for SwitchBinds --- niri-config/src/binds.rs | 14 +++++++++++++- niri-config/src/lib.rs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'niri-config/src') diff --git a/niri-config/src/binds.rs b/niri-config/src/binds.rs index c5b4e6ff..8a09445d 100644 --- a/niri-config/src/binds.rs +++ b/niri-config/src/binds.rs @@ -12,7 +12,7 @@ use smithay::input::keyboard::keysyms::KEY_NoSymbol; use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE}; use smithay::input::keyboard::Keysym; -use crate::utils::expect_only_children; +use crate::utils::{expect_only_children, MergeWith}; #[derive(Debug, Default, PartialEq)] pub struct Binds(pub Vec); @@ -77,6 +77,18 @@ pub struct SwitchBinds { pub tablet_mode_off: Option, } +impl MergeWith for SwitchBinds { + fn merge_with(&mut self, part: &SwitchBinds) { + merge_clone_opt!( + (self, part), + lid_open, + lid_close, + tablet_mode_on, + tablet_mode_off, + ); + } +} + #[derive(knuffel::Decode, Debug, Clone, PartialEq)] pub struct SwitchAction { #[knuffel(child, unwrap(arguments))] diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 14a93332..44b22a18 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -195,7 +195,7 @@ where "gestures" => m_replace!(gestures), "overview" => m_replace!(overview), "xwayland-satellite" => m_replace!(xwayland_satellite), - "switch-events" => m_replace!(switch_events), + "switch-events" => m_merge!(switch_events), "debug" => m_replace!(debug), // Multipart sections. -- cgit