Poll for X events in while loop
Otherwise we would only read a single event, even if multiple were available causing delays.
This commit is contained in:
parent
895c1a6b51
commit
52a3961602
@ -165,29 +165,31 @@ void controller::stop(bool reload) {
|
|||||||
|
|
||||||
void controller::conn_cb(uv_poll_event) {
|
void controller::conn_cb(uv_poll_event) {
|
||||||
int xcb_error = m_connection.connection_has_error();
|
int xcb_error = m_connection.connection_has_error();
|
||||||
if ((xcb_error = m_connection.connection_has_error()) > 0) {
|
if ((xcb_error = m_connection.connection_has_error()) != 0) {
|
||||||
m_log.err("X connection error, terminating... (what: %s)", m_connection.error_str(xcb_error));
|
m_log.err("X connection error, terminating... (what: %s)", m_connection.error_str(xcb_error));
|
||||||
stop(false);
|
stop(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<xcb_generic_event_t> evt{};
|
shared_ptr<xcb_generic_event_t> evt{};
|
||||||
if ((evt = shared_ptr<xcb_generic_event_t>(xcb_poll_for_event(m_connection), free)) != nullptr) {
|
while ((evt = shared_ptr<xcb_generic_event_t>(xcb_poll_for_event(m_connection), free)) != nullptr) {
|
||||||
try {
|
try {
|
||||||
m_connection.dispatch_event(evt);
|
m_connection.dispatch_event(evt);
|
||||||
} catch (xpp::connection_error& err) {
|
} catch (xpp::connection_error& err) {
|
||||||
m_log.err("X connection error, terminating... (what: %s)", m_connection.error_str(err.code()));
|
m_log.err("X connection error, terminating... (what: %s)", m_connection.error_str(err.code()));
|
||||||
|
stop(false);
|
||||||
} catch (const exception& err) {
|
} catch (const exception& err) {
|
||||||
m_log.err("Error in X event loop: %s", err.what());
|
m_log.err("Error in X event loop: %s", err.what());
|
||||||
|
stop(false);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if ((xcb_error = m_connection.connection_has_error()) > 0) {
|
|
||||||
|
if ((xcb_error = m_connection.connection_has_error()) != 0) {
|
||||||
m_log.err("X connection error, terminating... (what: %s)", m_connection.error_str(xcb_error));
|
m_log.err("X connection error, terminating... (what: %s)", m_connection.error_str(xcb_error));
|
||||||
stop(false);
|
stop(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void controller::signal_handler(int signum) {
|
void controller::signal_handler(int signum) {
|
||||||
m_log.notice("Received signal(%d): %s", signum, strsignal(signum));
|
m_log.notice("Received signal(%d): %s", signum, strsignal(signum));
|
||||||
|
Loading…
Reference in New Issue
Block a user