attempt to fix clipboard

This commit is contained in:
Matthew 2025-10-05 17:06:27 +11:00
parent 09cd7a1fd7
commit 151c281bcf

View File

@ -528,7 +528,7 @@ struct PlatformWindow
Inputs[2] inputs; Inputs[2] inputs;
TicketMut input_mutex; TicketMut input_mutex;
IntervalTimer cb_timer; Mut cb_msg_mut;
TicketMut cb_mut; TicketMut cb_mut;
Selection[CBM.max] selections; Selection[CBM.max] selections;
version(linux) u32 cb_transfer_size; version(linux) u32 cb_transfer_size;
@ -568,6 +568,7 @@ CreateWindow(string name, u16 width, u16 height)
input_mutex: CreateTicketMut(), input_mutex: CreateTicketMut(),
msg_queue: CreateMessageQueue(), msg_queue: CreateMessageQueue(),
cb_mut: CreateTicketMut(), cb_mut: CreateTicketMut(),
cb_msg_mut: CreateMut(),
cb_timer: CreateTimer(X11_TIMEOUT_DEFAULT), cb_timer: CreateTimer(X11_TIMEOUT_DEFAULT),
inputs: [ inputs: [
{ arena: CreateArena(MB(1)) }, { 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_convert_selection(w.conn, w.window, sel.xmode, sel.target, sel.xmode, XCB_CURRENT_TIME);
xcb_flush(w.conn); xcb_flush(w.conn);
ResetTimer(&w.cb_timer); while(!w.cb_msg_mut.locked) {}
while(!CheckTimer(&w.cb_timer) && sel.data.length == 0) {} while(w.cb_msg_mut.locked) {}
GetClipboardSelection(w, sel); GetClipboardSelection(w, sel);
} }
@ -1272,7 +1273,9 @@ HandleEvents(void* window_ptr)
} break; } break;
case XCB_SELECTION_NOTIFY: case XCB_SELECTION_NOTIFY:
{ {
TryLock(&w.cb_msg_mut);
RetrieveSelection(w, cast(xcb_selection_notify_event_t*)e); RetrieveSelection(w, cast(xcb_selection_notify_event_t*)e);
Unlock(&w.cb_msg_mut);
} break; } break;
case XCB_SELECTION_REQUEST: case XCB_SELECTION_REQUEST:
{ {