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