diff --git a/include/config.hpp.cmake b/include/config.hpp.cmake index cab5223d..cfbf2f56 100644 --- a/include/config.hpp.cmake +++ b/include/config.hpp.cmake @@ -29,6 +29,11 @@ #cmakedefine VERBOSE_TRACELOG #cmakedefine DEBUG_HINTS +static const int SINK_PRIORITY_BAR{1}; +static const int SINK_PRIORITY_SCREEN{2}; +static const int SINK_PRIORITY_TRAY{3}; +static const int SINK_PRIORITY_MODULE{4}; + #ifdef DEBUG_HINTS static const int DEBUG_HINTS_OFFSET_X{@DEBUG_HINTS_OFFSET_X@}; static const int DEBUG_HINTS_OFFSET_Y{@DEBUG_HINTS_OFFSET_Y@}; diff --git a/include/modules/xworkspaces.hpp b/include/modules/xworkspaces.hpp index 7fb8d03b..1c3a4ea7 100644 --- a/include/modules/xworkspaces.hpp +++ b/include/modules/xworkspaces.hpp @@ -45,7 +45,6 @@ namespace modules { xworkspaces_module(const bar_settings& bar, const logger& logger, const config& config, string name); void setup(); - void start(); void teardown(); void handle(const evt::property_notify& evt); void update(); diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 75b9083d..171e767b 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -53,7 +53,7 @@ bar::bar(connection& conn, const config& config, const logger& logger, unique_pt bar::~bar() { std::lock_guard guard(m_mutex); g_signals::tray::report_slotcount = nullptr; - m_connection.detach_sink(this, 1); + m_connection.detach_sink(this, SINK_PRIORITY_BAR); m_tray.reset(); } @@ -148,7 +148,7 @@ void bar::bootstrap(bool nodraw) { } m_log.trace("bar: Attaching sink to registry"); - m_connection.attach_sink(this, 1); + m_connection.attach_sink(this, SINK_PRIORITY_BAR); configure_geom(); diff --git a/src/components/screen.cpp b/src/components/screen.cpp index a92f0a96..33852fd2 100644 --- a/src/components/screen.cpp +++ b/src/components/screen.cpp @@ -60,14 +60,14 @@ screen::screen(connection& conn, const logger& logger, const config& conf) m_connection.clear_event_mask(m_root); // Finally attach the sink the process randr events - m_connection.attach_sink(this, 1); + m_connection.attach_sink(this, SINK_PRIORITY_SCREEN); } /** * Deconstruct screen instance */ screen::~screen() { - m_connection.detach_sink(this, 1); + m_connection.detach_sink(this, SINK_PRIORITY_SCREEN); if (m_proxy != XCB_NONE) { m_connection.destroy_window(m_proxy); diff --git a/src/modules/xbacklight.cpp b/src/modules/xbacklight.cpp index 62a2837a..1dcd085b 100644 --- a/src/modules/xbacklight.cpp +++ b/src/modules/xbacklight.cpp @@ -65,7 +65,7 @@ namespace modules { // Connect with the event registry and make sure we get // notified when a RandR output property gets modified - m_connection.attach_sink(this, 1); + m_connection.attach_sink(this, SINK_PRIORITY_MODULE); m_connection.select_input_checked(m_proxy, XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY); // Add formats and elements @@ -89,7 +89,7 @@ namespace modules { * Disconnect from the event registry */ void xbacklight_module::teardown() { - m_connection.detach_sink(this, 1); + m_connection.detach_sink(this, SINK_PRIORITY_MODULE); } /** diff --git a/src/modules/xkeyboard.cpp b/src/modules/xkeyboard.cpp index 5ba927ba..fcf98063 100644 --- a/src/modules/xkeyboard.cpp +++ b/src/modules/xkeyboard.cpp @@ -38,7 +38,7 @@ namespace modules { } // Connect to the event registry - m_connection.attach_sink(this, 3); + m_connection.attach_sink(this, SINK_PRIORITY_MODULE); // Setup extension m_connection.xkb().select_events_checked(XCB_XKB_ID_USE_CORE_KBD, @@ -55,7 +55,7 @@ namespace modules { * Disconnect from the event registry */ void xkeyboard_module::teardown() { - m_connection.detach_sink(this, 3); + m_connection.detach_sink(this, SINK_PRIORITY_MODULE); } /** diff --git a/src/modules/xwindow.cpp b/src/modules/xwindow.cpp index 7b4ac6ba..5f64199a 100644 --- a/src/modules/xwindow.cpp +++ b/src/modules/xwindow.cpp @@ -98,7 +98,7 @@ namespace modules { m_connection.ensure_event_mask(m_connection.root(), XCB_EVENT_MASK_PROPERTY_CHANGE); // Connect with the event registry - m_connection.attach_sink(this, 1); + m_connection.attach_sink(this, SINK_PRIORITY_MODULE); // Trigger the initial draw event update(); @@ -108,7 +108,7 @@ namespace modules { * Disconnect from the event registry */ void xwindow_module::teardown() { - m_connection.detach_sink(this, 1); + m_connection.detach_sink(this, SINK_PRIORITY_MODULE); } /** diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index 37ec343f..9962083e 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -83,19 +83,17 @@ namespace modules { // Make sure we get notified when root properties change window{m_connection, m_connection.root()}.ensure_event_mask(XCB_EVENT_MASK_PROPERTY_CHANGE); + // Connect with the event registry + m_connection.attach_sink(this, SINK_PRIORITY_MODULE); + update(); } - void xworkspaces_module::start() { - // Connect with the event registry - m_connection.attach_sink(this, 3); - static_module::start(); - } /** * Disconnect from the event registry */ void xworkspaces_module::teardown() { - m_connection.detach_sink(this, 3); + m_connection.detach_sink(this, SINK_PRIORITY_MODULE); } /** diff --git a/src/x11/tray.cpp b/src/x11/tray.cpp index 5c749246..d7c10249 100644 --- a/src/x11/tray.cpp +++ b/src/x11/tray.cpp @@ -139,11 +139,11 @@ void tray_client::configure_notify(int16_t x, int16_t y) const { // {{{ // implementation : tray_manager {{{ tray_manager::tray_manager(connection& conn, const logger& logger) : m_connection(conn), m_log(logger) { - m_connection.attach_sink(this, 2); + m_connection.attach_sink(this, SINK_PRIORITY_TRAY); } tray_manager::~tray_manager() { - m_connection.detach_sink(this, 2); + m_connection.detach_sink(this, SINK_PRIORITY_TRAY); if (m_delaythread.joinable()) { m_delaythread.join();