Add clipboard disable-primary setting

This commit is contained in:
peelz
2025-01-22 00:00:35 -05:00
committed by Ivan Molodetskikh
parent 748d90b443
commit 54a1cd5069
4 changed files with 26 additions and 1 deletions
+15
View File
@@ -53,6 +53,8 @@ pub struct Config {
]
pub screenshot_path: Option<String>,
#[knuffel(child, default)]
pub clipboard: Clipboard,
#[knuffel(child, default)]
pub hotkey_overlay: HotkeyOverlay,
#[knuffel(child, default)]
pub animations: Animations,
@@ -785,6 +787,12 @@ pub struct HotkeyOverlay {
pub skip_at_startup: bool,
}
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Clipboard {
#[knuffel(child)]
pub disable_primary: bool,
}
#[derive(knuffel::Decode, Debug, Clone, PartialEq)]
pub struct Animations {
#[knuffel(child)]
@@ -3432,6 +3440,10 @@ mod tests {
screenshot-path "~/Screenshots/screenshot.png"
clipboard {
disable-primary
}
hotkey-overlay {
skip-at-startup
}
@@ -3686,6 +3698,9 @@ mod tests {
hide_after_inactive_ms: Some(3000),
},
screenshot_path: Some(String::from("~/Screenshots/screenshot.png")),
clipboard: Clipboard {
disable_primary: true,
},
hotkey_overlay: HotkeyOverlay {
skip_at_startup: true,
},
+1
View File
@@ -28,6 +28,7 @@ impl ServiceChannel {
compositor_state: Default::default(),
// Would be nice to thread config here but for now it's fine.
can_view_decoration_globals: false,
primary_selection_disabled: false,
restricted: false,
// FIXME: maybe you can get the PID from D-Bus somehow?
credentials_unknown: true,
+1
View File
@@ -475,6 +475,7 @@ impl SecurityContextHandler for State {
let data = Arc::new(ClientState {
compositor_state: Default::default(),
can_view_decoration_globals: config.prefer_no_csd,
primary_selection_disabled: config.clipboard.disable_primary,
restricted: true,
credentials_unknown: false,
});
+9 -1
View File
@@ -1810,7 +1810,13 @@ impl Niri {
let idle_notifier_state = IdleNotifierState::new(&display_handle, event_loop.clone());
let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(&display_handle);
let data_device_state = DataDeviceState::new::<State>(&display_handle);
let primary_selection_state = PrimarySelectionState::new::<State>(&display_handle);
let primary_selection_state =
PrimarySelectionState::new_with_filter::<State, _>(&display_handle, |client| {
!client
.get_data::<ClientState>()
.unwrap()
.primary_selection_disabled
});
let data_control_state = DataControlState::new::<State, _>(
&display_handle,
Some(&primary_selection_state),
@@ -1930,6 +1936,7 @@ impl Niri {
let data = Arc::new(ClientState {
compositor_state: Default::default(),
can_view_decoration_globals: config.prefer_no_csd,
primary_selection_disabled: config.clipboard.disable_primary,
restricted: false,
credentials_unknown: false,
});
@@ -5167,6 +5174,7 @@ impl Niri {
pub struct ClientState {
pub compositor_state: CompositorClientState,
pub can_view_decoration_globals: bool,
pub primary_selection_disabled: bool,
/// Whether this client is denied from the restricted protocols such as security-context.
pub restricted: bool,
/// We cannot retrieve this client's socket credentials.