Commit dd5b0783344d
tarball3 files changed+17-10
@@ -79,9 +79,9 @@ repeat_delay = 200
7979
repeat_rate = 258080
8181
[xwayland]82
-# Which X11 clients may read a Wayland-owned clipboard or primary selection.83
-# focused allows only the window holding keyboard focus, any allows every X1184
-# client, which clipboard managers and headless xclip need.82
+# Which X11 clients may read the Wayland clipboard or primary selection, and83
+# set it. focused allows only the window holding keyboard focus, any allows84
+# every X11 client, which clipboard managers and headless xclip need.8585
selection_access = "focused"8686
8787
# libinput settings, bare metal only. Anything left out keeps the device's@@ -72,7 +72,7 @@ impl Default for General {
7272
#[derive(Deserialize, Debug, Clone, PartialEq)]7373
#[serde(default, deny_unknown_fields)]7474
pub struct Xwayland {75
- /// Which X11 clients may read a Wayland-owned selection.75
+ /// Which X11 clients may read the Wayland selections and set them.7676
pub selection_access: SelectionAccess,7777
}7878
@@ -459,11 +459,7 @@ impl XwmHandler for State {
459459
}460460
461461
fn allow_selection_access(&mut self, xwm: XwmId, _selection: SelectionTarget) -> bool {462
- self.settings.config.xwayland.selection_access == SelectionAccess::Any463
- || matches!(464
- self.input.seat.get_keyboard().and_then(|k| k.current_focus()),465
- Some(Focus::X11(x)) if x.xwm_id() == Some(xwm)466
- )462
+ self.x11_selection_allowed(xwm)467463
}468464
469465
fn send_selection(@@ -503,7 +499,10 @@ impl XwmHandler for State {
503499
}504500
}505501
506
- fn new_selection(&mut self, _xwm: XwmId, selection: SelectionTarget, mime_types: Vec<String>) {502
+ fn new_selection(&mut self, xwm: XwmId, selection: SelectionTarget, mime_types: Vec<String>) {503
+ if !self.x11_selection_allowed(xwm) {504
+ return;505
+ }507506
let (dh, seat) = (&self.core.display, &self.input.seat);508507
match selection {509508
SelectionTarget::Clipboard => set_data_device_selection(dh, seat, mime_types, ()),@@ -565,6 +564,14 @@ pub fn fixed_size(window: &X11Surface) -> Option<Size<i32, Logical>> {
565564
}566565
567566
impl State {567
+ fn x11_selection_allowed(&self, xwm: XwmId) -> bool {568
+ self.settings.config.xwayland.selection_access == SelectionAccess::Any569
+ || matches!(570
+ self.input.seat.get_keyboard().and_then(|k| k.current_focus()),571
+ Some(Focus::X11(x)) if x.xwm_id() == Some(xwm)572
+ )573
+ }574
+568575
/// Clears `selection` when an X11 client owns it, since a client-owned569576
/// selection carries no user data. Xwayland dying takes the owner with it570577
/// without a cleared_selection call.