diff --git a/src/event_manager.cc b/src/event_manager.cc index cb69fc5e..eed7614f 100644 --- a/src/event_manager.cc +++ b/src/event_manager.cc @@ -69,7 +69,7 @@ EventManager::~EventManager() kak_assert(m_timers.empty()); } -void EventManager::handle_next_events(EventMode mode, sigset_t* sigmask, bool block) +bool EventManager::handle_next_events(EventMode mode, sigset_t* sigmask, bool block) { int max_fd = 0; fd_set rfds, wfds, efds; @@ -140,6 +140,8 @@ void EventManager::handle_next_events(EventMode mode, sigset_t* sigmask, bool bl if (contains(m_timers, timer) and timer->next_date() <= now) timer->run(mode); } + + return res > 0; } void EventManager::force_signal(int fd) diff --git a/src/event_manager.hh b/src/event_manager.hh index 857cb863..91a8d41c 100644 --- a/src/event_manager.hh +++ b/src/event_manager.hh @@ -86,7 +86,7 @@ public: EventManager(); ~EventManager(); - void handle_next_events(EventMode mode, sigset_t* sigmask = nullptr, bool block = true); + bool handle_next_events(EventMode mode, sigset_t* sigmask = nullptr, bool block = true); // force the watchers associated with fd to be executed // on next handle_next_events call. diff --git a/src/main.cc b/src/main.cc index f05a950e..b70dbdb9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -680,9 +680,14 @@ int run_server(StringView session, StringView server_init, (flags & ServerFlags::Daemon))) { client_manager.redraw_clients(); - event_manager.handle_next_events(EventMode::Normal, nullptr, - not client_manager.has_pending_inputs()); - client_manager.process_pending_inputs(); + + // Loop a + bool allow_blocking = not client_manager.has_pending_inputs(); + while (event_manager.handle_next_events(EventMode::Normal, nullptr, allow_blocking)) + { + client_manager.process_pending_inputs(); + allow_blocking = false; + } client_manager.clear_client_trash(); client_manager.clear_window_trash(); buffer_manager.clear_buffer_trash();