Fix OSD window dragging not working
The USB read was blocking indefinitely (timeout=0), preventing the main loop from calling osd_update to process X11 mouse events. Changes: - Changed libusb_interrupt_transfer timeout from 0 to 50ms - Added XFlush after XMapWindow in osd_set_mode - Timeout now continues loop instead of printing error message The OSD window can now be dragged while waiting for KD100 button presses. https://claude.ai/code/session_01H5sr8TkRyt6U1vdkVZRRvy
+7 −3 · 2 files changed
-
src/device.c+6 −3 -
src/osd.c+1 −0
@@ -385,10 +385,13 @@ void device_run(libusb_context* ctx, config_t* config, int debug, int accept, in } } - err = libusb_interrupt_transfer(handle, 0x81, data, sizeof(data), NULL, 0); + // Use 50ms timeout to allow OSD event processing (dragging, etc.) + err = libusb_interrupt_transfer(handle, 0x81, data, sizeof(data), NULL, 50); - if (err == LIBUSB_ERROR_TIMEOUT) - printf("\nTIMEDOUT\n"); + if (err == LIBUSB_ERROR_TIMEOUT) { + // Normal timeout - just continue to process OSD events + continue; + } if (err == LIBUSB_ERROR_PIPE) printf("\nPIPE ERROR\n"); if (err == LIBUSB_ERROR_NO_DEVICE) @@ -301,6 +301,7 @@ void osd_set_mode(osd_state_t* osd, osd_mode_t mode) { XResizeWindow(dpy, win, osd->width, osd->height); XMapWindow(dpy, win); XRaiseWindow(dpy, win); + XFlush(dpy); osd_redraw(osd); }