From d8563fa02802204a5da3f45d5dfbc100ed4337f4 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Mon, 10 Aug 2026 14:52:48 +0200 Subject: [PATCH] x11: assert selection ownership with CURRENT_TIME update_selection_owner asserted ownership using self.copy_and_paste.time That field only advances on key and button events delivered to that particular window, so a window the user has not touched recently carries a timestamp that predates the selection's lastTimeChanged. The X server ignores SetSelectionOwner in that case, so the assertion was previously dropped. Use X's CURRENT_TIME constant instead which is always accepted. This mirrors what focus() already does for the same underlying reason. refs: #5917 --- window/src/os/x11/window.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index cb26392ed..179207949 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -926,7 +926,12 @@ impl XWindowInner { conn.send_request_no_reply(&xcb::x::SetSelectionOwner { owner: xcb::x::Window::none(), selection, - time: self.copy_and_paste.time, + // We use CURRENT_TIME rather than self.copy_and_paste.time here, because that field + // only advances on key/button events on *this* window, so for a window that hasn't + // been interacted with recently it lags behind the selection's lastTimeChanged. + // The X server ignores SetSelectionOwner with time before lastTimeChanged, so + // clipboard updates without explicit interaction (OSC 52) would never be accepted. + time: xcb::x::CURRENT_TIME, })?; } else if we_own_it { log::trace!( @@ -937,7 +942,8 @@ impl XWindowInner { conn.send_request_no_reply(&xcb::x::SetSelectionOwner { owner: self.window_id, selection, - time: self.copy_and_paste.time, + // See note about CURRENT_TIME in the other branch above. + time: xcb::x::CURRENT_TIME, })?; } else { log::trace!(