From 151c281bcf84f3763537af869adf828652412397 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 5 Oct 2025 17:06:27 +1100 Subject: [PATCH] attempt to fix clipboard --- platform.d | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform.d b/platform.d index 90604dc..b1db124 100644 --- a/platform.d +++ b/platform.d @@ -528,7 +528,7 @@ struct PlatformWindow Inputs[2] inputs; TicketMut input_mutex; - IntervalTimer cb_timer; + Mut cb_msg_mut; TicketMut cb_mut; Selection[CBM.max] selections; version(linux) u32 cb_transfer_size; @@ -568,6 +568,7 @@ CreateWindow(string name, u16 width, u16 height) input_mutex: CreateTicketMut(), msg_queue: CreateMessageQueue(), cb_mut: CreateTicketMut(), + cb_msg_mut: CreateMut(), cb_timer: CreateTimer(X11_TIMEOUT_DEFAULT), inputs: [ { arena: CreateArena(MB(1)) }, @@ -896,8 +897,8 @@ ClipboardText(PlatformWindow* w, ClipboardMode mode) xcb_convert_selection(w.conn, w.window, sel.xmode, sel.target, sel.xmode, XCB_CURRENT_TIME); xcb_flush(w.conn); - ResetTimer(&w.cb_timer); - while(!CheckTimer(&w.cb_timer) && sel.data.length == 0) {} + while(!w.cb_msg_mut.locked) {} + while(w.cb_msg_mut.locked) {} GetClipboardSelection(w, sel); } @@ -1272,7 +1273,9 @@ HandleEvents(void* window_ptr) } break; case XCB_SELECTION_NOTIFY: { + TryLock(&w.cb_msg_mut); RetrieveSelection(w, cast(xcb_selection_notify_event_t*)e); + Unlock(&w.cb_msg_mut); } break; case XCB_SELECTION_REQUEST: {