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
This commit is contained in:
Tobias Oetiker authored and Benoit de Chezelles committed 2026-09-15 13:29:32 +02:00
1 parent 699fd77b44
commit d8563fa028
1 file changed
+8 -2
+8 -2
View File
@@ -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!(