diff --git a/include/components/bar.hpp b/include/components/bar.hpp index 0bd49cc2..3b70f1ca 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -59,6 +59,8 @@ class bar : public xpp::event::sink> configure_bar(); diff --git a/include/components/types.hpp b/include/components/types.hpp index 8b87bbc0..e9e94008 100644 --- a/include/components/types.hpp +++ b/include/components/types.hpp @@ -134,4 +134,18 @@ struct action_block { } }; +struct event_timer { + xcb_timestamp_t event{0}; + uint32_t delay_ms{0U}; + + bool throttle(xcb_timestamp_t evt) { + if (evt > event + delay_ms) { + event = evt; + return false; + } else { + return true; + } + }; +}; + POLYBAR_NS_END diff --git a/include/modules/xbacklight.hpp b/include/modules/xbacklight.hpp index 42b929cf..07769a36 100644 --- a/include/modules/xbacklight.hpp +++ b/include/modules/xbacklight.hpp @@ -49,7 +49,7 @@ namespace modules { connection& m_connection; monitor_t m_output; xcb_window_t m_proxy; - xcb_timestamp_t m_timestamp; + event_timer m_randrnotify{}; ramp_t m_ramp; label_t m_label; diff --git a/include/modules/xwindow.hpp b/include/modules/xwindow.hpp index 804b4c91..7c3777f5 100644 --- a/include/modules/xwindow.hpp +++ b/include/modules/xwindow.hpp @@ -80,9 +80,9 @@ namespace modules { bool build(builder* builder, const string& tag) const; private: - static constexpr auto TAG_LABEL = "