From 9f4638f42c7946364722ea975b766ec2d1b30198 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 26 Nov 2016 06:13:20 +0100 Subject: [PATCH] refactor: Cleanup --- include/components/bar.hpp | 2 + include/components/types.hpp | 14 +++++ include/modules/xbacklight.hpp | 2 +- include/modules/xwindow.hpp | 4 +- include/utils/bspwm.hpp | 3 +- include/utils/i3.hpp | 3 +- include/x11/connection.hpp | 10 +-- include/x11/draw.hpp | 5 +- include/x11/graphics.hpp | 3 +- include/x11/types.hpp | 14 ++++- include/x11/window.hpp | 2 + include/x11/winspec.hpp | 4 +- include/x11/wm.hpp | 18 +++--- include/x11/xutils.hpp | 5 ++ src/components/bar.cpp | 16 +++-- src/main.cpp | 2 + src/modules/xbacklight.cpp | 16 ++--- src/modules/xwindow.cpp | 10 +-- src/utils/bspwm.cpp | 1 + src/utils/i3.cpp | 1 + src/x11/connection.cpp | 8 ++- src/x11/draw.cpp | 1 + src/x11/fonts.cpp | 1 + src/x11/graphics.cpp | 1 + src/x11/randr.cpp | 1 + src/x11/tray.cpp | 112 ++++++++++++++------------------- src/x11/winspec.cpp | 4 ++ src/x11/wm.cpp | 35 ++++++----- src/x11/xembed.cpp | 1 + src/x11/xutils.cpp | 27 +++++--- 30 files changed, 185 insertions(+), 141 deletions(-) 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 = "