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;
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:
{