config: Add merging for Debug
Browse files at this commitceaf9408a58d6eee0428116802736f48466daf1fParent: eff41ab2 changed files +71 -19
- niri-config/src/debug.rs +70 -18
- niri-config/src/lib.rs +1 -1
niri-config/src/debug.rsmodified+70 -18
| @@ -1,45 +1,97 @@ | |||
| 1 | use std::path::PathBuf; | 1 | use std::path::PathBuf; |
| 2 | 2 | ||
| 3 | -#[derive(knuffel::Decode, Debug, Default, PartialEq)] | 3 | +use crate::utils::{Flag, MergeWith}; |
| 4 | + | ||
| 5 | +#[derive(Debug, Default, PartialEq)] | ||
| 4 | pub struct Debug { | 6 | pub struct Debug { |
| 7 | + pub preview_render: Option<PreviewRender>, | ||
| 8 | + pub dbus_interfaces_in_non_session_instances: bool, | ||
| 9 | + pub wait_for_frame_completion_before_queueing: bool, | ||
| 10 | + pub enable_overlay_planes: bool, | ||
| 11 | + pub disable_cursor_plane: bool, | ||
| 12 | + pub disable_direct_scanout: bool, | ||
| 13 | + pub keep_max_bpc_unchanged: bool, | ||
| 14 | + pub restrict_primary_scanout_to_matching_format: bool, | ||
| 15 | + pub render_drm_device: Option<PathBuf>, | ||
| 16 | + pub force_pipewire_invalid_modifier: bool, | ||
| 17 | + pub emulate_zero_presentation_time: bool, | ||
| 18 | + pub disable_resize_throttling: bool, | ||
| 19 | + pub disable_transactions: bool, | ||
| 20 | + pub keep_laptop_panel_on_when_lid_is_closed: bool, | ||
| 21 | + pub disable_monitor_names: bool, | ||
| 22 | + pub strict_new_window_focus_policy: bool, | ||
| 23 | + pub honor_xdg_activation_with_invalid_serial: bool, | ||
| 24 | + pub deactivate_unfocused_windows: bool, | ||
| 25 | + pub skip_cursor_only_updates_during_vrr: bool, | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +#[derive(knuffel::Decode, Debug, Default, PartialEq)] | ||
| 29 | +pub struct DebugPart { | ||
| 5 | #[knuffel(child, unwrap(argument))] | 30 | #[knuffel(child, unwrap(argument))] |
| 6 | pub preview_render: Option<PreviewRender>, | 31 | pub preview_render: Option<PreviewRender>, |
| 7 | #[knuffel(child)] | 32 | #[knuffel(child)] |
| 8 | - pub dbus_interfaces_in_non_session_instances: bool, | 33 | + pub dbus_interfaces_in_non_session_instances: Option<Flag>, |
| 9 | #[knuffel(child)] | 34 | #[knuffel(child)] |
| 10 | - pub wait_for_frame_completion_before_queueing: bool, | 35 | + pub wait_for_frame_completion_before_queueing: Option<Flag>, |
| 11 | #[knuffel(child)] | 36 | #[knuffel(child)] |
| 12 | - pub enable_overlay_planes: bool, | 37 | + pub enable_overlay_planes: Option<Flag>, |
| 13 | #[knuffel(child)] | 38 | #[knuffel(child)] |
| 14 | - pub disable_cursor_plane: bool, | 39 | + pub disable_cursor_plane: Option<Flag>, |
| 15 | #[knuffel(child)] | 40 | #[knuffel(child)] |
| 16 | - pub disable_direct_scanout: bool, | 41 | + pub disable_direct_scanout: Option<Flag>, |
| 17 | #[knuffel(child)] | 42 | #[knuffel(child)] |
| 18 | - pub keep_max_bpc_unchanged: bool, | 43 | + pub keep_max_bpc_unchanged: Option<Flag>, |
| 19 | #[knuffel(child)] | 44 | #[knuffel(child)] |
| 20 | - pub restrict_primary_scanout_to_matching_format: bool, | 45 | + pub restrict_primary_scanout_to_matching_format: Option<Flag>, |
| 21 | #[knuffel(child, unwrap(argument))] | 46 | #[knuffel(child, unwrap(argument))] |
| 22 | pub render_drm_device: Option<PathBuf>, | 47 | pub render_drm_device: Option<PathBuf>, |
| 23 | #[knuffel(child)] | 48 | #[knuffel(child)] |
| 24 | - pub force_pipewire_invalid_modifier: bool, | 49 | + pub force_pipewire_invalid_modifier: Option<Flag>, |
| 25 | #[knuffel(child)] | 50 | #[knuffel(child)] |
| 26 | - pub emulate_zero_presentation_time: bool, | 51 | + pub emulate_zero_presentation_time: Option<Flag>, |
| 27 | #[knuffel(child)] | 52 | #[knuffel(child)] |
| 28 | - pub disable_resize_throttling: bool, | 53 | + pub disable_resize_throttling: Option<Flag>, |
| 29 | #[knuffel(child)] | 54 | #[knuffel(child)] |
| 30 | - pub disable_transactions: bool, | 55 | + pub disable_transactions: Option<Flag>, |
| 31 | #[knuffel(child)] | 56 | #[knuffel(child)] |
| 32 | - pub keep_laptop_panel_on_when_lid_is_closed: bool, | 57 | + pub keep_laptop_panel_on_when_lid_is_closed: Option<Flag>, |
| 33 | #[knuffel(child)] | 58 | #[knuffel(child)] |
| 34 | - pub disable_monitor_names: bool, | 59 | + pub disable_monitor_names: Option<Flag>, |
| 35 | #[knuffel(child)] | 60 | #[knuffel(child)] |
| 36 | - pub strict_new_window_focus_policy: bool, | 61 | + pub strict_new_window_focus_policy: Option<Flag>, |
| 37 | #[knuffel(child)] | 62 | #[knuffel(child)] |
| 38 | - pub honor_xdg_activation_with_invalid_serial: bool, | 63 | + pub honor_xdg_activation_with_invalid_serial: Option<Flag>, |
| 39 | #[knuffel(child)] | 64 | #[knuffel(child)] |
| 40 | - pub deactivate_unfocused_windows: bool, | 65 | + pub deactivate_unfocused_windows: Option<Flag>, |
| 41 | #[knuffel(child)] | 66 | #[knuffel(child)] |
| 42 | - pub skip_cursor_only_updates_during_vrr: bool, | 67 | + pub skip_cursor_only_updates_during_vrr: Option<Flag>, |
| 68 | +} | ||
| 69 | + | ||
| 70 | +impl MergeWith<DebugPart> for Debug { | ||
| 71 | + fn merge_with(&mut self, part: &DebugPart) { | ||
| 72 | + merge!( | ||
| 73 | + (self, part), | ||
| 74 | + dbus_interfaces_in_non_session_instances, | ||
| 75 | + wait_for_frame_completion_before_queueing, | ||
| 76 | + enable_overlay_planes, | ||
| 77 | + disable_cursor_plane, | ||
| 78 | + disable_direct_scanout, | ||
| 79 | + keep_max_bpc_unchanged, | ||
| 80 | + restrict_primary_scanout_to_matching_format, | ||
| 81 | + force_pipewire_invalid_modifier, | ||
| 82 | + emulate_zero_presentation_time, | ||
| 83 | + disable_resize_throttling, | ||
| 84 | + disable_transactions, | ||
| 85 | + keep_laptop_panel_on_when_lid_is_closed, | ||
| 86 | + disable_monitor_names, | ||
| 87 | + strict_new_window_focus_policy, | ||
| 88 | + honor_xdg_activation_with_invalid_serial, | ||
| 89 | + deactivate_unfocused_windows, | ||
| 90 | + skip_cursor_only_updates_during_vrr, | ||
| 91 | + ); | ||
| 92 | + | ||
| 93 | + merge_clone_opt!((self, part), preview_render, render_drm_device); | ||
| 94 | + } | ||
| 43 | } | 95 | } |
| 44 | 96 | ||
| 45 | #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq, Eq)] | 97 | #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq, Eq)] |
niri-config/src/lib.rsmodified+1 -1
| @@ -196,7 +196,7 @@ where | |||
| 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_merge!(switch_events), | 198 | "switch-events" => m_merge!(switch_events), |
| 199 | - "debug" => m_replace!(debug), | 199 | + "debug" => m_merge!(debug), |
| 200 | 200 | ||
| 201 | // Multipart sections. | 201 | // Multipart sections. |
| 202 | "output" => { | 202 | "output" => { |