Add clipboard disable-primary setting
Browse files at this commit54a1cd5069cd2f4eb302862fae115b742fbf32a4Parent: 748d90b4 changed files +26 -1
- niri-config/src/lib.rs +15 -0
- src/dbus/mutter_service_channel.rs +1 -0
- src/handlers/mod.rs +1 -0
- src/niri.rs +9 -1
niri-config/src/lib.rsmodified+15 -0
| @@ -53,6 +53,8 @@ pub struct Config { | ||
| 53 | 53 | ] |
| 54 | 54 | pub screenshot_path: Option<String>, |
| 55 | 55 | #[knuffel(child, default)] |
| 56 | + pub clipboard: Clipboard, | |
| 57 | + #[knuffel(child, default)] | |
| 56 | 58 | pub hotkey_overlay: HotkeyOverlay, |
| 57 | 59 | #[knuffel(child, default)] |
| 58 | 60 | pub animations: Animations, |
| @@ -785,6 +787,12 @@ pub struct HotkeyOverlay { | ||
| 785 | 787 | pub skip_at_startup: bool, |
| 786 | 788 | } |
| 787 | 789 | |
| 790 | +#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)] | |
| 791 | +pub struct Clipboard { | |
| 792 | + #[knuffel(child)] | |
| 793 | + pub disable_primary: bool, | |
| 794 | +} | |
| 795 | + | |
| 788 | 796 | #[derive(knuffel::Decode, Debug, Clone, PartialEq)] |
| 789 | 797 | pub struct Animations { |
| 790 | 798 | #[knuffel(child)] |
| @@ -3432,6 +3440,10 @@ mod tests { | ||
| 3432 | 3440 | |
| 3433 | 3441 | screenshot-path "~/Screenshots/screenshot.png" |
| 3434 | 3442 | |
| 3443 | + clipboard { | |
| 3444 | + disable-primary | |
| 3445 | + } | |
| 3446 | + | |
| 3435 | 3447 | hotkey-overlay { |
| 3436 | 3448 | skip-at-startup |
| 3437 | 3449 | } |
| @@ -3686,6 +3698,9 @@ mod tests { | ||
| 3686 | 3698 | hide_after_inactive_ms: Some(3000), |
| 3687 | 3699 | }, |
| 3688 | 3700 | screenshot_path: Some(String::from("~/Screenshots/screenshot.png")), |
| 3701 | + clipboard: Clipboard { | |
| 3702 | + disable_primary: true, | |
| 3703 | + }, | |
| 3689 | 3704 | hotkey_overlay: HotkeyOverlay { |
| 3690 | 3705 | skip_at_startup: true, |
| 3691 | 3706 | }, |
src/dbus/mutter_service_channel.rsmodified+1 -0
| @@ -28,6 +28,7 @@ impl ServiceChannel { | ||
| 28 | 28 | compositor_state: Default::default(), |
| 29 | 29 | // Would be nice to thread config here but for now it's fine. |
| 30 | 30 | can_view_decoration_globals: false, |
| 31 | + primary_selection_disabled: false, | |
| 31 | 32 | restricted: false, |
| 32 | 33 | // FIXME: maybe you can get the PID from D-Bus somehow? |
| 33 | 34 | credentials_unknown: true, |
src/handlers/mod.rsmodified+1 -0
| @@ -475,6 +475,7 @@ impl SecurityContextHandler for State { | ||
| 475 | 475 | let data = Arc::new(ClientState { |
| 476 | 476 | compositor_state: Default::default(), |
| 477 | 477 | can_view_decoration_globals: config.prefer_no_csd, |
| 478 | + primary_selection_disabled: config.clipboard.disable_primary, | |
| 478 | 479 | restricted: true, |
| 479 | 480 | credentials_unknown: false, |
| 480 | 481 | }); |
src/niri.rsmodified+9 -1
| @@ -1810,7 +1810,13 @@ impl Niri { | ||
| 1810 | 1810 | let idle_notifier_state = IdleNotifierState::new(&display_handle, event_loop.clone()); |
| 1811 | 1811 | let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(&display_handle); |
| 1812 | 1812 | let data_device_state = DataDeviceState::new::<State>(&display_handle); |
| 1813 | - let primary_selection_state = PrimarySelectionState::new::<State>(&display_handle); | |
| 1813 | + let primary_selection_state = | |
| 1814 | + PrimarySelectionState::new_with_filter::<State, _>(&display_handle, |client| { | |
| 1815 | + !client | |
| 1816 | + .get_data::<ClientState>() | |
| 1817 | + .unwrap() | |
| 1818 | + .primary_selection_disabled | |
| 1819 | + }); | |
| 1814 | 1820 | let data_control_state = DataControlState::new::<State, _>( |
| 1815 | 1821 | &display_handle, |
| 1816 | 1822 | Some(&primary_selection_state), |
| @@ -1930,6 +1936,7 @@ impl Niri { | ||
| 1930 | 1936 | let data = Arc::new(ClientState { |
| 1931 | 1937 | compositor_state: Default::default(), |
| 1932 | 1938 | can_view_decoration_globals: config.prefer_no_csd, |
| 1939 | + primary_selection_disabled: config.clipboard.disable_primary, | |
| 1933 | 1940 | restricted: false, |
| 1934 | 1941 | credentials_unknown: false, |
| 1935 | 1942 | }); |
| @@ -5167,6 +5174,7 @@ impl Niri { | ||
| 5167 | 5174 | pub struct ClientState { |
| 5168 | 5175 | pub compositor_state: CompositorClientState, |
| 5169 | 5176 | pub can_view_decoration_globals: bool, |
| 5177 | + pub primary_selection_disabled: bool, | |
| 5170 | 5178 | /// Whether this client is denied from the restricted protocols such as security-context. |
| 5171 | 5179 | pub restricted: bool, |
| 5172 | 5180 | /// We cannot retrieve this client's socket credentials. |