diff --git a/CHANGELOG.md b/CHANGELOG.md index 27987e81..b02d975f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `internal/pulseaudio`: `reverse-scroll` option ([`#2664`](https://github.com/polybar/polybar/pull/2664)) - `custom/script`: Repeat interval for script failure (`interval-fail`) and `exec-if` (`interval-if`) ([`#943`](https://github.com/polybar/polybar/issues/943), [`#2606`](https://github.com/polybar/polybar/issues/2606), [`#2630`](https://github.com/polybar/polybar/pull/2630)) +## [3.6.2] - 2022-04-03 +### Fixed +- `format-offset` being ignored ([`#2643`](https://github.com/polybar/polybar/pull/2643)) +- Negative struts (`margin-bottom`, `margin-top`) being ignored ([`#2642`](https://github.com/polybar/polybar/issues/2642), [`#2644`](https://github.com/polybar/polybar/pull/2644)) +- Positioning in awesomeWM ([`#2651`](https://github.com/polybar/polybar/pull/2651)) +- `internal/xworkspaces`: The module sometimes crashed polybar when windows were closed. ([`#2655`](https://github.com/polybar/polybar/pull/2655)) +- Mouseover error when only one cursor is defined ([`#2656`](https://github.com/polybar/polybar/pull/2656)) +- `custom/script`: Timing inconsistencies ([`#2650`](https://github.com/polybar/polybar/issues/2650), first described at [`#2630`](https://github.com/polybar/polybar/pull/2630)) + ## [3.6.1] - 2022-03-05 ### Build - Fixed compiler warning in Clang 13 ([`#2613`](https://github.com/polybar/polybar/pull/2613)) @@ -170,7 +179,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Empty color values are no longer treated as invalid and no longer produce an error. -[Unreleased]: https://github.com/polybar/polybar/compare/3.6.1...HEAD +[Unreleased]: https://github.com/polybar/polybar/compare/3.6.2...HEAD +[3.6.2]: https://github.com/polybar/polybar/releases/tag/3.6.2 [3.6.1]: https://github.com/polybar/polybar/releases/tag/3.6.1 [3.6.0]: https://github.com/polybar/polybar/releases/tag/3.6.0 [3.5.7]: https://github.com/polybar/polybar/releases/tag/3.5.7 diff --git a/include/adapters/pulseaudio.hpp b/include/adapters/pulseaudio.hpp index 09398ac1..a5d23426 100644 --- a/include/adapters/pulseaudio.hpp +++ b/include/adapters/pulseaudio.hpp @@ -1,12 +1,12 @@ #pragma once #include + #include #include "common.hpp" -#include "settings.hpp" #include "errors.hpp" - +#include "settings.hpp" #include "utils/math.hpp" // fwd struct pa_context; @@ -25,57 +25,57 @@ class pulseaudio { enum class evtype { NEW = 0, CHANGE, REMOVE, SERVER }; using queue = std::queue; - public: - explicit pulseaudio(const logger& logger, string&& sink_name, bool m_max_volume); - ~pulseaudio(); + public: + explicit pulseaudio(const logger& logger, string&& sink_name, bool m_max_volume); + ~pulseaudio(); - pulseaudio(const pulseaudio& o) = delete; - pulseaudio& operator=(const pulseaudio& o) = delete; + pulseaudio(const pulseaudio& o) = delete; + pulseaudio& operator=(const pulseaudio& o) = delete; - const string& get_name(); + const string& get_name(); - bool wait(); - int process_events(); + bool wait(); + int process_events(); - int get_volume(); - double get_decibels(); - void set_volume(float percentage); - void inc_volume(int delta_perc); - void set_mute(bool mode); - void toggle_mute(); - bool is_muted(); + int get_volume(); + double get_decibels(); + void set_volume(float percentage); + void inc_volume(int delta_perc); + void set_mute(bool mode); + void toggle_mute(); + bool is_muted(); - private: - void update_volume(pa_operation *o); - static void check_mute_callback(pa_context *context, const pa_sink_info *info, int eol, void *userdata); - static void get_sink_volume_callback(pa_context *context, const pa_sink_info *info, int is_last, void *userdata); - static void subscribe_callback(pa_context* context, pa_subscription_event_type_t t, uint32_t idx, void* userdata); - static void simple_callback(pa_context *context, int success, void *userdata); - static void sink_info_callback(pa_context *context, const pa_sink_info *info, int eol, void *userdata); - static void context_state_callback(pa_context *context, void *userdata); + private: + void update_volume(pa_operation* o); + static void check_mute_callback(pa_context* context, const pa_sink_info* info, int eol, void* userdata); + static void get_sink_volume_callback(pa_context* context, const pa_sink_info* info, int is_last, void* userdata); + static void subscribe_callback(pa_context* context, pa_subscription_event_type_t t, uint32_t idx, void* userdata); + static void simple_callback(pa_context* context, int success, void* userdata); + static void sink_info_callback(pa_context* context, const pa_sink_info* info, int eol, void* userdata); + static void context_state_callback(pa_context* context, void* userdata); - inline void wait_loop(pa_operation *op, pa_threaded_mainloop *loop); + inline void wait_loop(pa_operation* op, pa_threaded_mainloop* loop); - const logger& m_log; + const logger& m_log; - // used for temporary callback results - int success{0}; - pa_cvolume cv; - bool muted{false}; - // default sink name - static constexpr auto DEFAULT_SINK = "@DEFAULT_SINK@"; + // used for temporary callback results + int success{0}; + pa_cvolume cv{}; + bool muted{false}; + // default sink name + static constexpr auto DEFAULT_SINK = "@DEFAULT_SINK@"; - pa_context* m_context{nullptr}; - pa_threaded_mainloop* m_mainloop{nullptr}; + pa_context* m_context{nullptr}; + pa_threaded_mainloop* m_mainloop{nullptr}; - queue m_events; + queue m_events; - // specified sink name - string spec_s_name; - string s_name; - uint32_t m_index{0}; + // specified sink name + string spec_s_name; + string s_name; + uint32_t m_index{0}; - pa_volume_t m_max_volume{PA_VOLUME_UI_MAX}; + pa_volume_t m_max_volume{PA_VOLUME_UI_MAX}; }; POLYBAR_NS_END diff --git a/include/adapters/script_runner.hpp b/include/adapters/script_runner.hpp index 3df931ea..855c72d4 100644 --- a/include/adapters/script_runner.hpp +++ b/include/adapters/script_runner.hpp @@ -11,9 +11,18 @@ POLYBAR_NS class script_runner { public: + struct data { + int counter{0}; + int pid{-1}; + int exit_status{0}; + string output; + }; + + using on_update = std::function; using interval = std::chrono::duration; - script_runner(std::function on_update, const string& exec, const string& exec_if, bool tail, - interval interval_success, interval interval_fail, const vector>& env); + + script_runner(on_update on_update, const string& exec, const string& exec_if, bool tail, interval interval_success, + interval interval_fail, const vector>& env); bool check_condition() const; interval process(); @@ -22,16 +31,11 @@ class script_runner { void stop(); - int get_pid() const; - int get_counter() const; - int get_exit_status() const; - - string get_output(); - bool is_stopping() const; protected: bool set_output(string&&); + bool set_exit_status(int); interval run_tail(); interval run(); @@ -39,7 +43,7 @@ class script_runner { private: const logger& m_log; - const std::function m_on_update; + const on_update m_on_update; const string m_exec; const string m_exec_if; @@ -48,13 +52,8 @@ class script_runner { const interval m_interval_fail; const vector> m_env; - std::mutex m_output_lock; - string m_output; - - std::atomic_int m_counter{0}; + data m_data; std::atomic_bool m_stopping{false}; - std::atomic_int m_pid{-1}; - std::atomic_int m_exit_status{0}; }; POLYBAR_NS_END diff --git a/include/components/bar.hpp b/include/components/bar.hpp index 43a444dc..dc7a09e1 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -31,12 +31,7 @@ namespace tags { class bar : public xpp::event::sink, - public signal_receiver { + public signal_receiver { public: using make_type = unique_ptr; static make_type make(eventloop::loop&, bool only_initialize_values = false); @@ -46,7 +41,7 @@ class bar : public xpp::event::sink()}; eventloop::TimerHandle& m_middleclick_timer{m_loop.handle()}; eventloop::TimerHandle& m_rightclick_timer{m_loop.handle()}; diff --git a/include/components/builder.hpp b/include/components/builder.hpp index d9041695..b5f98e78 100644 --- a/include/components/builder.hpp +++ b/include/components/builder.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "common.hpp" #include "components/types.hpp" @@ -21,11 +22,9 @@ class builder { void reset(); string flush(); - void append(const string& text); void node(const string& str); void node(const string& str, int font_index); void node(const label_t& label); - void node_repeat(const string& str, size_t n); void node_repeat(const label_t& label, size_t n); void offset(extent_val pixels = ZERO_PX_EXTENT); void spacing(spacing_val size); @@ -33,17 +32,11 @@ class builder { void font_close(); void background(rgba color); void background_close(); - void color(rgba color); - void color_close(); - void line_color(const rgba& color); - void line_color_close(); - void overline_color(rgba color); - void overline_color_close(); - void underline_color(rgba color); - void underline_color_close(); - void overline(const rgba& color = rgba{}); + void foreground(rgba color); + void foreground_close(); + void overline(const rgba& color); void overline_close(); - void underline(const rgba& color = rgba{}); + void underline(const rgba& color); void underline_close(); void control(tags::controltag tag); void action(mousebtn index, string action); @@ -52,23 +45,25 @@ class builder { void action(mousebtn btn, const modules::module_interface& module, string action, string data, const label_t& label); void action_close(); - static string get_spacing_format_string(const spacing_val& space); + static string get_spacing_format_string(spacing_val space); protected: + void append(const string& text); + + void overline_color_close(); + void underline_color_close(); + void tag_open(tags::syntaxtag tag, const string& value); void tag_open(tags::attribute attr); void tag_close(tags::syntaxtag tag); void tag_close(tags::attribute attr); private: - const bar_settings m_bar; + const bar_settings& m_bar; string m_output; map m_tags{}; - map m_colors{}; - map m_attrs{}; - - int m_fontindex{0}; + std::unordered_set m_attrs{}; }; POLYBAR_NS_END diff --git a/include/components/types.hpp b/include/components/types.hpp index 43cea82b..1d453e1c 100644 --- a/include/components/types.hpp +++ b/include/components/types.hpp @@ -59,6 +59,11 @@ static inline mousebtn mousebtn_get_double(mousebtn btn) { } } +/** + * Order of values for _NET_WM_STRUT_PARTIAL + * + * https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm45381391268672 + */ enum class strut { LEFT = 0, RIGHT, @@ -132,13 +137,6 @@ struct percentage_with_offset { extent_val offset{ZERO_PX_EXTENT}; }; -struct edge_values { - unsigned int left{0U}; - unsigned int right{0U}; - unsigned int top{0U}; - unsigned int bottom{0U}; -}; - struct radius { double top_left{0.0}; double top_right{0.0}; @@ -173,7 +171,7 @@ struct bar_settings { monitor_t monitor{}; bool monitor_strict{false}; bool monitor_exact{true}; - edge origin{edge::TOP}; + bool bottom{false}; struct size size { 1U, 1U }; @@ -185,7 +183,10 @@ struct bar_settings { position offset{0, 0}; side_values padding{ZERO_SPACE, ZERO_SPACE}; side_values module_margin{ZERO_SPACE, ZERO_SPACE}; - edge_values strut{0U, 0U, 0U, 0U}; + struct { + int top; + int bottom; + } strut{0, 0}; rgba background{0xFF000000}; rgba foreground{0xFFFFFFFF}; @@ -210,8 +211,14 @@ struct bar_settings { int double_click_interval{400}; - string cursor{}; + /** + * Name of cursor to use for clickable areas + */ string cursor_click{}; + + /** + * Name of cursor to use for scrollable areas + */ string cursor_scroll{}; vector actions{}; diff --git a/include/events/signal.hpp b/include/events/signal.hpp index f992b1e2..f122467a 100644 --- a/include/events/signal.hpp +++ b/include/events/signal.hpp @@ -45,7 +45,7 @@ namespace signals { private: const void* m_ptr; }; - } // namespace detail + } // namespace detail namespace eventqueue { struct exit_reload : public detail::base_signal { @@ -60,7 +60,7 @@ namespace signals { struct check_state : public detail::base_signal { using base_type::base_type; }; - } // namespace eventqueue + } // namespace eventqueue namespace ipc { struct command : public detail::value_signal { @@ -72,7 +72,7 @@ namespace signals { struct action : public detail::value_signal { using base_type::base_type; }; - } // namespace ipc + } // namespace ipc namespace ui { struct changed : public detail::base_signal { @@ -81,9 +81,6 @@ namespace signals { struct button_press : public detail::value_signal { using base_type::base_type; }; - struct cursor_change : public detail::value_signal { - using base_type::base_type; - }; struct visibility_change : public detail::value_signal { using base_type::base_type; }; @@ -101,13 +98,13 @@ namespace signals { struct update_geometry : public detail::base_signal { using base_type::base_type; }; - } // namespace ui + } // namespace ui namespace ui_tray { struct mapped_clients : public detail::value_signal { using base_type::base_type; }; - } // namespace ui_tray -} // namespace signals + } // namespace ui_tray +} // namespace signals POLYBAR_NS_END diff --git a/include/events/signal_fwd.hpp b/include/events/signal_fwd.hpp index 376683a0..2c7abbb7 100644 --- a/include/events/signal_fwd.hpp +++ b/include/events/signal_fwd.hpp @@ -19,25 +19,24 @@ namespace signals { struct notify_change; struct notify_forcechange; struct check_state; - } // namespace eventqueue + } // namespace eventqueue namespace ipc { struct command; struct hook; struct action; - } // namespace ipc + } // namespace ipc namespace ui { struct changed; struct button_press; - struct cursor_change; struct visibility_change; struct dim_window; struct request_snapshot; struct update_background; struct update_geometry; - } // namespace ui + } // namespace ui namespace ui_tray { struct mapped_clients; } -} // namespace signals +} // namespace signals POLYBAR_NS_END diff --git a/include/modules/meta/base.hpp b/include/modules/meta/base.hpp index b7de9ef0..78b4fc17 100644 --- a/include/modules/meta/base.hpp +++ b/include/modules/meta/base.hpp @@ -142,7 +142,7 @@ namespace modules { template class module : public module_interface { public: - module(const bar_settings bar, string name); + module(const bar_settings& bar, string name); ~module() noexcept; static constexpr auto EVENT_MODULE_TOGGLE = "module_toggle"; @@ -197,7 +197,7 @@ namespace modules { protected: signal_emitter& m_sig; - const bar_settings m_bar; + const bar_settings& m_bar; const logger& m_log; const config& m_conf; diff --git a/include/modules/meta/base.inl b/include/modules/meta/base.inl index 1f4378bc..9b6899ad 100644 --- a/include/modules/meta/base.inl +++ b/include/modules/meta/base.inl @@ -15,7 +15,7 @@ namespace modules { // module public {{{ template - module::module(const bar_settings bar, string name) + module::module(const bar_settings& bar, string name) : m_sig(signal_emitter::make()) , m_bar(bar) , m_log(logger::make()) @@ -271,7 +271,7 @@ namespace modules { m_builder->spacing(format->spacing); } - m_builder->append(tag_content); + m_builder->node(tag_content); has_tags = true; } @@ -279,7 +279,7 @@ namespace modules { } if (cursor < value.size()) { - m_builder->append(value.substr(cursor)); + m_builder->node(value.substr(cursor)); } return format->decorate(&*m_builder, m_builder->flush()); diff --git a/include/modules/script.hpp b/include/modules/script.hpp index 7d764b96..969af692 100644 --- a/include/modules/script.hpp +++ b/include/modules/script.hpp @@ -26,6 +26,8 @@ namespace modules { bool check_condition(); private: + void handle_runner_update(const script_runner::data&); + static constexpr auto TAG_LABEL = "