From ab5a462e0ca35d2abf4910f112b0b840e6fe716d Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Mon, 24 Jun 2024 21:16:58 -0700 Subject: [PATCH] Use likely-newer KeyPress serial for wl clipboard (#13483) The KeyEnter serial will be too old if another client replaces the selection before the user unfocuses and refocuses the window (i.e., triggers another KeyEnter event). The KeyPress event is more likely to be new enough. Release Notes: - Fixed setting clipboard sometimes not working on wayland ([#13445](https://github.com/zed-industries/zed/issues/13445)). --- crates/gpui/src/platform/linux/wayland/client.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 004b8dbb90a913dc160213dee1d49d2cd2b210cf..6b7cfd62d8341dfd7a6066bfb16f07b2ebdeeaa9 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -671,12 +671,12 @@ impl LinuxClient for WaylandClient { return; }; if state.mouse_focused_window.is_some() || state.keyboard_focused_window.is_some() { - let serial = state.serial_tracker.get(SerialKind::KeyEnter); + state.clipboard.set_primary(item.text); + let serial = state.serial_tracker.get(SerialKind::KeyPress); let data_source = primary_selection_manager.create_source(&state.globals.qh, ()); data_source.offer(state.clipboard.self_mime()); data_source.offer(TEXT_MIME_TYPE.to_string()); primary_selection.set_selection(Some(&data_source), serial); - state.clipboard.set_primary(item.text); } } @@ -689,12 +689,12 @@ impl LinuxClient for WaylandClient { return; }; if state.mouse_focused_window.is_some() || state.keyboard_focused_window.is_some() { - let serial = state.serial_tracker.get(SerialKind::KeyEnter); + state.clipboard.set(item.text); + let serial = state.serial_tracker.get(SerialKind::KeyPress); let data_source = data_device_manager.create_data_source(&state.globals.qh, ()); data_source.offer(state.clipboard.self_mime()); data_source.offer(TEXT_MIME_TYPE.to_string()); data_device.set_selection(Some(&data_source), serial); - state.clipboard.set(item.text); } }