mirror of
https://github.com/polybar/polybar.git
synced 2025-04-14 17:33:17 -04:00
Merge branch 'hotfix/3.7.1'
This commit is contained in:
commit
367847ec3b
15 changed files with 75 additions and 57 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [3.7.1] - 2023-11-27
|
||||
### Build
|
||||
- Fixed missing header when using `libc++` in clang 15 and below
|
||||
|
||||
### Changed
|
||||
- `internal/tray`: The module must use the `<tray>` tag (this is the default) ([`#3037`](https://github.com/polybar/polybar/pull/3037))
|
||||
|
||||
## Fixed
|
||||
- Modules did not validate that all tags (e.g. `<label>`) used in a format were valid for that format ([`#3043`](https://github.com/polybar/polybar/issues/3043), [`#3045`](https://github.com/polybar/polybar/pull/3045))
|
||||
- `internal/tray`: Fixed `module-margin` and `separator` being applied to completely empty tray module ([`#3036`](https://github.com/polybar/polybar/issues/3036), [`#3037`](https://github.com/polybar/polybar/pull/3037))
|
||||
|
||||
## [3.7.0] - 2023-11-05
|
||||
### Breaking
|
||||
- `custom/script`:
|
||||
|
@ -247,7 +258,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.7.0...HEAD
|
||||
[Unreleased]: https://github.com/polybar/polybar/compare/3.7.1...HEAD
|
||||
[3.7.1]: https://github.com/polybar/polybar/releases/tag/3.7.1
|
||||
[3.7.0]: https://github.com/polybar/polybar/releases/tag/3.7.0
|
||||
[3.6.3]: https://github.com/polybar/polybar/releases/tag/3.6.3
|
||||
[3.6.2]: https://github.com/polybar/polybar/releases/tag/3.6.2
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "settings.hpp"
|
||||
|
|
|
@ -104,9 +104,6 @@ namespace signals {
|
|||
struct tray_pos_change : public detail::value_signal<tray_pos_change, int> {
|
||||
using base_type::base_type;
|
||||
};
|
||||
struct tray_visibility : public detail::value_signal<tray_visibility, bool> {
|
||||
using base_type::base_type;
|
||||
};
|
||||
} // namespace ui_tray
|
||||
} // namespace signals
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace signals {
|
|||
} // namespace ui
|
||||
namespace ui_tray {
|
||||
struct tray_pos_change;
|
||||
struct tray_visibility;
|
||||
} // namespace ui_tray
|
||||
} // namespace signals
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ namespace modules {
|
|||
string get_format() const;
|
||||
string get_output();
|
||||
|
||||
void set_visible(bool value);
|
||||
virtual void set_visible(bool value);
|
||||
|
||||
void action_module_toggle();
|
||||
void action_module_show();
|
||||
|
|
|
@ -8,11 +8,21 @@
|
|||
|
||||
POLYBAR_NS
|
||||
namespace modules {
|
||||
/**
|
||||
* Wraps the tray_manager in a module.
|
||||
*
|
||||
* The module produces the `%{Pt}` formatting tag, which is used by the renderer
|
||||
* to place the tray.
|
||||
* The visibility of the tray icons is directly tied to the visibility of the
|
||||
* module.
|
||||
*/
|
||||
class tray_module : public static_module<tray_module> {
|
||||
public:
|
||||
explicit tray_module(const bar_settings& bar_settings, string name_, const config&);
|
||||
string get_format() const;
|
||||
|
||||
void set_visible(bool value) override;
|
||||
|
||||
void start() override;
|
||||
|
||||
bool build(builder* builder, const string& tag) const;
|
||||
|
|
|
@ -116,14 +116,13 @@ class tray_client {
|
|||
unsigned int m_height;
|
||||
};
|
||||
|
||||
class tray_manager
|
||||
: public xpp::event::sink<evt::expose, evt::visibility_notify, evt::client_message, evt::configure_request,
|
||||
evt::resize_request, evt::selection_clear, evt::property_notify, evt::reparent_notify, evt::destroy_notify,
|
||||
evt::map_notify, evt::unmap_notify>,
|
||||
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::visibility_change, signals::ui::dim_window,
|
||||
signals::ui::update_background, signals::ui_tray::tray_pos_change, signals::ui_tray::tray_visibility>,
|
||||
public non_copyable_mixin,
|
||||
public non_movable_mixin {
|
||||
class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify, evt::client_message,
|
||||
evt::configure_request, evt::resize_request, evt::selection_clear, evt::property_notify,
|
||||
evt::reparent_notify, evt::destroy_notify, evt::map_notify, evt::unmap_notify>,
|
||||
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::visibility_change, signals::ui::dim_window,
|
||||
signals::ui::update_background, signals::ui_tray::tray_pos_change>,
|
||||
public non_copyable_mixin,
|
||||
public non_movable_mixin {
|
||||
public:
|
||||
using make_type = unique_ptr<tray_manager>;
|
||||
static make_type make(const bar_settings& settings);
|
||||
|
@ -194,7 +193,6 @@ class tray_manager
|
|||
bool on(const signals::ui::dim_window& evt) override;
|
||||
bool on(const signals::ui::update_background& evt) override;
|
||||
bool on(const signals::ui_tray::tray_pos_change& evt) override;
|
||||
bool on(const signals::ui_tray::tray_visibility& evt) override;
|
||||
|
||||
private:
|
||||
connection& m_connection;
|
||||
|
|
|
@ -76,13 +76,13 @@ struct tray_settings {
|
|||
|
||||
using on_update = std::function<void(void)>;
|
||||
|
||||
class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::configure_request, evt::resize_request,
|
||||
evt::selection_clear, evt::property_notify, evt::reparent_notify, evt::destroy_notify,
|
||||
evt::map_notify, evt::unmap_notify>,
|
||||
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::update_background,
|
||||
signals::ui_tray::tray_pos_change, signals::ui_tray::tray_visibility>,
|
||||
non_copyable_mixin,
|
||||
non_movable_mixin {
|
||||
class manager
|
||||
: public xpp::event::sink<evt::expose, evt::client_message, evt::configure_request, evt::resize_request,
|
||||
evt::selection_clear, evt::property_notify, evt::reparent_notify, evt::destroy_notify, evt::map_notify,
|
||||
evt::unmap_notify>,
|
||||
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::update_background, signals::ui_tray::tray_pos_change>,
|
||||
non_copyable_mixin,
|
||||
non_movable_mixin {
|
||||
public:
|
||||
explicit manager(connection& conn, signal_emitter& emitter, const logger& logger, const bar_settings& bar_opts,
|
||||
on_update on_update);
|
||||
|
@ -103,6 +103,8 @@ class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::c
|
|||
|
||||
bool is_visible() const;
|
||||
|
||||
bool change_visibility(bool visible);
|
||||
|
||||
protected:
|
||||
void recalculate_width();
|
||||
void reconfigure_clients();
|
||||
|
@ -130,7 +132,6 @@ class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::c
|
|||
void remove_client(const client& client);
|
||||
void remove_client(xcb_window_t win);
|
||||
void clean_clients();
|
||||
bool change_visibility(bool visible);
|
||||
|
||||
void handle(const evt::expose& evt) override;
|
||||
void handle(const evt::client_message& evt) override;
|
||||
|
@ -145,7 +146,6 @@ class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::c
|
|||
|
||||
bool on(const signals::ui::update_background& evt) override;
|
||||
bool on(const signals::ui_tray::tray_pos_change& evt) override;
|
||||
bool on(const signals::ui_tray::tray_visibility& evt) override;
|
||||
|
||||
private:
|
||||
connection& m_connection;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 36b2a1b05083837abe259b1990d738feaf4fa866
|
||||
Subproject commit 0daa58349ab3373161a4a73c1ccd2822328d2c73
|
|
@ -839,13 +839,10 @@ bool renderer::on(const signals::ui::request_snapshot& evt) {
|
|||
}
|
||||
|
||||
void renderer::apply_tray_position(const tags::context& context) {
|
||||
if (context.get_relative_tray_position() != std::pair<alignment, int>()) {
|
||||
int absolute_x = static_cast<int>(
|
||||
block_x(context.get_relative_tray_position().first) + context.get_relative_tray_position().second);
|
||||
auto [alignment, pos] = context.get_relative_tray_position();
|
||||
if (alignment != alignment::NONE) {
|
||||
int absolute_x = static_cast<int>(block_x(alignment) + pos);
|
||||
m_sig.emit(signals::ui_tray::tray_pos_change{absolute_x});
|
||||
m_sig.emit(signals::ui_tray::tray_visibility{true});
|
||||
} else {
|
||||
m_sig.emit(signals::ui_tray::tray_visibility{false});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace modules {
|
|||
};
|
||||
|
||||
auto format = make_unique<module_format>();
|
||||
format->value = move(value);
|
||||
format->value = std::move(value);
|
||||
format->fg = m_conf.get(m_modname, name + "-foreground", formatdef("foreground", format->fg));
|
||||
format->bg = m_conf.get(m_modname, name + "-background", formatdef("background", format->bg));
|
||||
format->ul = m_conf.get(m_modname, name + "-underline", formatdef("underline", format->ul));
|
||||
|
@ -122,18 +122,14 @@ namespace modules {
|
|||
tag_collection.insert(tag_collection.end(), tags.begin(), tags.end());
|
||||
tag_collection.insert(tag_collection.end(), whitelist.begin(), whitelist.end());
|
||||
|
||||
size_t start, end;
|
||||
while ((start = value.find('<')) != string::npos && (end = value.find('>', start)) != string::npos) {
|
||||
if (start > 0) {
|
||||
value.erase(0, start);
|
||||
end -= start;
|
||||
start = 0;
|
||||
}
|
||||
string tag{value.substr(start, end + 1)};
|
||||
size_t start = 0;
|
||||
size_t end = 0;
|
||||
while ((start = format->value.find('<', start)) != string::npos && (end = format->value.find('>', start)) != string::npos) {
|
||||
string tag{format->value.substr(start, end - start + 1)};
|
||||
if (find(tag_collection.begin(), tag_collection.end(), tag) == tag_collection.end()) {
|
||||
throw undefined_format_tag(tag + " is not a valid format tag for \"" + name + "\"");
|
||||
}
|
||||
value.erase(0, tag.size());
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
m_formats.insert(make_pair(move(name), move(format)));
|
||||
|
|
|
@ -8,27 +8,46 @@ namespace modules {
|
|||
template class module<tray_module>;
|
||||
|
||||
tray_module::tray_module(const bar_settings& bar_settings, string name_, const config& config)
|
||||
: static_module<tray_module>(bar_settings, move(name_), config)
|
||||
: static_module<tray_module>(bar_settings, std::move(name_), config)
|
||||
, m_tray(connection::make(), signal_emitter::make(), m_log, bar_settings, [&] { this->broadcast(); }) {
|
||||
m_formatter->add(DEFAULT_FORMAT, TAG_TRAY, {TAG_TRAY});
|
||||
|
||||
/* There are a bunch of edge cases with regards to tray visiblity when the
|
||||
* <tray> tag is not there (in that case the tray icons should under no
|
||||
* circumnstances appear). To avoid this, we simply disallow the situation.
|
||||
* The module is basically useless without that tag anyway.
|
||||
*/
|
||||
if (!m_formatter->has(TAG_TRAY, DEFAULT_FORMAT)) {
|
||||
throw module_error("The " + std::string(TAG_TRAY) + " tag is required in " + name() + "." + DEFAULT_FORMAT);
|
||||
}
|
||||
|
||||
// Otherwise the tray does not see the initial module visibility
|
||||
m_tray.change_visibility(visible());
|
||||
}
|
||||
|
||||
string tray_module::get_format() const {
|
||||
return DEFAULT_FORMAT;
|
||||
}
|
||||
|
||||
void tray_module::set_visible(bool value) {
|
||||
m_tray.change_visibility(value);
|
||||
static_module<tray_module>::set_visible(value);
|
||||
}
|
||||
|
||||
void tray_module::start() {
|
||||
m_tray.setup(m_conf, name());
|
||||
this->static_module<tray_module>::start();
|
||||
}
|
||||
|
||||
bool tray_module::build(builder* builder, const string& tag) const {
|
||||
if (tag == TAG_TRAY) {
|
||||
// Don't produce any output if the tray is empty so that the module can be hidden
|
||||
if (tag == TAG_TRAY && m_tray.get_width() > 0) {
|
||||
builder->control(tags::controltag::t);
|
||||
extent_val offset_extent = {extent_type::PIXEL, static_cast<float>(m_tray.get_width())};
|
||||
builder->offset(offset_extent);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1172,14 +1172,6 @@ bool tray_manager::on(const signals::ui_tray::tray_pos_change& evt) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool tray_manager::on(const signals::ui_tray::tray_visibility& evt) {
|
||||
if (evt.cast() == m_hidden && m_opts.tray_position == tray_postition::MODULE) {
|
||||
return change_visibility(evt.cast());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
tray_client::tray_client(connection& conn, xcb_window_t win, unsigned int w, unsigned int h)
|
||||
: m_connection(conn), m_window(win), m_width(w), m_height(h) {}
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ void manager::clean_clients() {
|
|||
}
|
||||
|
||||
bool manager::change_visibility(bool visible) {
|
||||
if (!is_active() || m_hidden == !visible) {
|
||||
if (m_hidden == !visible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -764,10 +764,6 @@ bool manager::on(const signals::ui_tray::tray_pos_change& evt) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool manager::on(const signals::ui_tray::tray_visibility& evt) {
|
||||
return change_visibility(evt.cast());
|
||||
}
|
||||
|
||||
} // namespace tray
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Polybar version information
|
||||
# Update this on every release
|
||||
# This is used to create the version string if a git repo is not available
|
||||
3.7.0
|
||||
3.7.1
|
||||
|
|
Loading…
Add table
Reference in a new issue