diff --git a/include/x11/background_manager.hpp b/include/x11/background_manager.hpp index e3ce3ced..dd9b0747 100644 --- a/include/x11/background_manager.hpp +++ b/include/x11/background_manager.hpp @@ -16,7 +16,7 @@ class logger; namespace cairo { class surface; class xcb_surface; -} // namespace cairo +} // namespace cairo class bg_slice { public: @@ -31,7 +31,7 @@ class bg_slice { * * This function is fast, since the current desktop background is cached. */ - cairo::surface* get_surface() const { + cairo::xcb_surface* get_surface() const { return m_surface.get(); } diff --git a/src/components/controller.cpp b/src/components/controller.cpp index ec856766..100c90c2 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -238,45 +238,45 @@ void controller::screenshot_handler() { void controller::read_events(bool confwatch) { m_log.info("Entering event loop (thread-id=%lu)", this_thread::get_id()); - try { - auto& poll_handle = m_loop.handle(m_connection.get_file_descriptor()); - poll_handle.start( - UV_READABLE, [this](const auto&) { conn_cb(); }, - [this](const auto& e) { - m_log.err("libuv error while polling X connection: "s + uv_strerror(e.status)); - stop(false); + if (!m_writeback) { + m_bar->start(); + } + + auto& poll_handle = m_loop.handle(m_connection.get_file_descriptor()); + poll_handle.start( + UV_READABLE, [this](const auto&) { conn_cb(); }, + [this](const auto& e) { + m_log.err("libuv error while polling X connection: "s + uv_strerror(e.status)); + stop(false); + }); + + for (auto s : {SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGALRM}) { + auto& signal_handle = m_loop.handle(); + signal_handle.start(s, [this](const auto& e) { signal_handler(e.signum); }); + } + + if (confwatch) { + auto& fs_event_handle = m_loop.handle(); + fs_event_handle.start( + m_conf.filepath(), 0, [this](const auto& e) { confwatch_handler(e.path); }, + [this, &fs_event_handle](const auto& e) { + m_log.err("libuv error while watching config file for changes: %s", uv_strerror(e.status)); + fs_event_handle.close(); }); + } - for (auto s : {SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGALRM}) { - auto& signal_handle = m_loop.handle(); - signal_handle.start(s, [this](const auto& e) { signal_handler(e.signum); }); - } + if (!m_snapshot_dst.empty()) { + // Trigger a single screenshot after 3 seconds + auto& timer_handle = m_loop.handle(); + timer_handle.start(3000, 0, [this]() { screenshot_handler(); }); + } - if (confwatch) { - auto& fs_event_handle = m_loop.handle(); - fs_event_handle.start( - m_conf.filepath(), 0, [this](const auto& e) { confwatch_handler(e.path); }, - [this, &fs_event_handle](const auto& e) { - m_log.err("libuv error while watching config file for changes: %s", uv_strerror(e.status)); - fs_event_handle.close(); - }); - } - - if (!m_snapshot_dst.empty()) { - // Trigger a single screenshot after 3 seconds - auto& timer_handle = m_loop.handle(); - timer_handle.start(3000, 0, [this]() { screenshot_handler(); }); - } - - if (!m_writeback) { - m_bar->start(); - } - - /* - * Immediately trigger and update so that the bar displays something. - */ - trigger_update(true); + /* + * Immediately trigger and update so that the bar displays something. + */ + trigger_update(true); + try { m_loop.run(); } catch (const exception& err) { m_log.err("Fatal Error in eventloop: %s", err.what()); diff --git a/src/x11/tray_manager.cpp b/src/x11/tray_manager.cpp index 31080cc0..5a6e1ccb 100644 --- a/src/x11/tray_manager.cpp +++ b/src/x11/tray_manager.cpp @@ -387,7 +387,7 @@ void tray_manager::reconfigure_bg() { return m_log.err("tray: no context for drawing the background"); } - cairo::surface* surface = m_bg_slice->get_surface(); + cairo::xcb_surface* surface = m_bg_slice->get_surface(); if (!surface) { return m_log.err("tray: no root surface"); }