mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-04-17 00:04:27 +08:00
[fix] fix blocking join() in Linux clipboard monitor thread during shutdown
This commit is contained in:
@@ -452,11 +452,17 @@ static void MonitorThreadFunc() {
|
|||||||
LOG_INFO("Clipboard event monitoring started (Linux XFixes)");
|
LOG_INFO("Clipboard event monitoring started (Linux XFixes)");
|
||||||
|
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
constexpr int kEventPollIntervalMs = 20;
|
||||||
while (g_monitoring.load()) {
|
while (g_monitoring.load()) {
|
||||||
XNextEvent(g_x11_display, &event);
|
// Avoid blocking on XNextEvent so StopMonitoring() can stop quickly.
|
||||||
if (event.type == event_base + XFixesSelectionNotify) {
|
while (g_monitoring.load() && XPending(g_x11_display) > 0) {
|
||||||
HandleClipboardChange();
|
XNextEvent(g_x11_display, &event);
|
||||||
|
if (event.type == event_base + XFixesSelectionNotify) {
|
||||||
|
HandleClipboardChange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
std::this_thread::sleep_for(
|
||||||
|
std::chrono::milliseconds(kEventPollIntervalMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
XFixesSelectSelectionInput(g_x11_display, event_window, g_clipboard_atom, 0);
|
XFixesSelectSelectionInput(g_x11_display, event_window, g_clipboard_atom, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user