bool DisplayMessageQueue_X11::process(int timeout_ms) { auto end_time = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout_ms); while (true) { process_message(); process_queued_events(); // What is this? If its related to Event then it should be removed process_window_sockets(); // Same for this thing if (end_time <= std::chrono::steady_clock::now()) break; int x11_handle = ConnectionNumber(display); struct timeval tv; if (timeout_ms > 0) { tv.tv_sec = timeout_ms / 1000; tv.tv_usec = (timeout_ms % 1000) * 1000; } else if (timeout_ms == 0) { tv.tv_sec = 0; tv.tv_usec = 0; } else { tv.tv_sec = 0x7FFFFFFF; tv.tv_usec = 0; } fd_set rfds; FD_ZERO(&rfds); FD_SET(x11_handle, &rfds); FD_SET(async_work_event.read_fd(), &rfds); FD_SET(exit_event.read_fd(), &rfds); int result = select(std::max(std::max(async_work_event.read_fd(), x11_handle), exit_event.read_fd()) + 1, &rfds, nullptr, nullptr, &tv); if (result > 0) { if (FD_ISSET(async_work_event.read_fd(), &rfds)) { async_work_event.reset(); process_async_work(); } if (FD_ISSET(exit_event.read_fd(), &rfds)) { exit_event.reset(); return false; } } else { break; } } return true; }
// Danger: This function could delete "this" void X11Window::process_window() { if (site) { if (repaint_request) { (site->sig_paint)(); repaint_request = false; } } process_window_sockets(); }