forge
Explore
Log in

Don't you dare go Hollow

Add clipboard disable-primary setting

Browse files at this commit

54a1cd5069cd2f4eb302862fae115b742fbf32a4peelzParent: 748d90b
niri-config/src/lib.rsmodified+15 -0
@@ -53,6 +53,8 @@ pub struct Config {
5353 ]
5454 pub screenshot_path: Option<String>,
5555 #[knuffel(child, default)]
56+ pub clipboard: Clipboard,
57+ #[knuffel(child, default)]
5658 pub hotkey_overlay: HotkeyOverlay,
5759 #[knuffel(child, default)]
5860 pub animations: Animations,
@@ -785,6 +787,12 @@ pub struct HotkeyOverlay {
785787 pub skip_at_startup: bool,
786788 }
787789
790+#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)]
791+pub struct Clipboard {
792+ #[knuffel(child)]
793+ pub disable_primary: bool,
794+}
795+
788796 #[derive(knuffel::Decode, Debug, Clone, PartialEq)]
789797 pub struct Animations {
790798 #[knuffel(child)]
@@ -3432,6 +3440,10 @@ mod tests {
34323440
34333441 screenshot-path "~/Screenshots/screenshot.png"
34343442
3443+ clipboard {
3444+ disable-primary
3445+ }
3446+
34353447 hotkey-overlay {
34363448 skip-at-startup
34373449 }
@@ -3686,6 +3698,9 @@ mod tests {
36863698 hide_after_inactive_ms: Some(3000),
36873699 },
36883700 screenshot_path: Some(String::from("~/Screenshots/screenshot.png")),
3701+ clipboard: Clipboard {
3702+ disable_primary: true,
3703+ },
36893704 hotkey_overlay: HotkeyOverlay {
36903705 skip_at_startup: true,
36913706 },
src/dbus/mutter_service_channel.rsmodified+1 -0
@@ -28,6 +28,7 @@ impl ServiceChannel {
2828 compositor_state: Default::default(),
2929 // Would be nice to thread config here but for now it's fine.
3030 can_view_decoration_globals: false,
31+ primary_selection_disabled: false,
3132 restricted: false,
3233 // FIXME: maybe you can get the PID from D-Bus somehow?
3334 credentials_unknown: true,
src/handlers/mod.rsmodified+1 -0
@@ -475,6 +475,7 @@ impl SecurityContextHandler for State {
475475 let data = Arc::new(ClientState {
476476 compositor_state: Default::default(),
477477 can_view_decoration_globals: config.prefer_no_csd,
478+ primary_selection_disabled: config.clipboard.disable_primary,
478479 restricted: true,
479480 credentials_unknown: false,
480481 });
src/niri.rsmodified+9 -1
@@ -1810,7 +1810,13 @@ impl Niri {
18101810 let idle_notifier_state = IdleNotifierState::new(&display_handle, event_loop.clone());
18111811 let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(&display_handle);
18121812 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+ });
18141820 let data_control_state = DataControlState::new::<State, _>(
18151821 &display_handle,
18161822 Some(&primary_selection_state),
@@ -1930,6 +1936,7 @@ impl Niri {
19301936 let data = Arc::new(ClientState {
19311937 compositor_state: Default::default(),
19321938 can_view_decoration_globals: config.prefer_no_csd,
1939+ primary_selection_disabled: config.clipboard.disable_primary,
19331940 restricted: false,
19341941 credentials_unknown: false,
19351942 });
@@ -5167,6 +5174,7 @@ impl Niri {
51675174 pub struct ClientState {
51685175 pub compositor_state: CompositorClientState,
51695176 pub can_view_decoration_globals: bool,
5177+ pub primary_selection_disabled: bool,
51705178 /// Whether this client is denied from the restricted protocols such as security-context.
51715179 pub restricted: bool,
51725180 /// We cannot retrieve this client's socket credentials.