Merge remote-tracking branch 'origin/master' into finitemonkey/master
This commit is contained in:
@@ -402,8 +402,13 @@ auto waybar::modules::Clock::get_calendar(const year_month_day& today, const yea
|
||||
data = g_utf8_find_next_char(data, end);
|
||||
}
|
||||
}
|
||||
// Note: the stream's default fill character is already a space (L' ' on
|
||||
// libstdc++'s wide FormatStream, ' ' on libc++'s narrow one), so no
|
||||
// std::setfill is needed. Passing std::setfill(' ')/std::setfill(L' ')
|
||||
// here is not portable because the fill char type must match the
|
||||
// FormatStream's char type, which differs between standard libraries.
|
||||
os << Glib::ustring::format(
|
||||
(cldWPos_ != WS::LEFT || line == 0) ? std::left : std::right, std::setfill(L' '),
|
||||
(cldWPos_ != WS::LEFT || line == 0) ? std::left : std::right,
|
||||
std::setw(cldMonColLen_ + ((line < 2) ? cldWnLen_ - wideCharCount : 0)),
|
||||
calendarLine);
|
||||
|
||||
|
||||
@@ -223,7 +223,11 @@ void Workspace::setActiveWindow(WindowAddress const& addr) {
|
||||
}
|
||||
|
||||
auto activeWindowPos = m_workspaceManager.activeWindowPosition();
|
||||
if (activeIdx.has_value() && activeWindowPos != Workspaces::ActiveWindowPosition::NONE) {
|
||||
const bool has_active_window =
|
||||
activeIdx.has_value() &&
|
||||
activeWindowPos != Workspaces::ActiveWindowPosition::NONE;
|
||||
|
||||
if (has_active_window) {
|
||||
auto window = std::move(m_windowMap[*activeIdx]);
|
||||
m_windowMap.erase(m_windowMap.begin() + *activeIdx);
|
||||
if (activeWindowPos == Workspaces::ActiveWindowPosition::FIRST) {
|
||||
@@ -238,7 +242,10 @@ void Workspace::insertWindow(WindowCreationPayload create_window_payload) {
|
||||
if (!create_window_payload.isEmpty(m_workspaceManager)) {
|
||||
auto repr = create_window_payload.repr(m_workspaceManager);
|
||||
|
||||
if (!repr.empty() || m_workspaceManager.enableTaskbar()) {
|
||||
const bool should_display =
|
||||
!repr.empty() || m_workspaceManager.enableTaskbar();
|
||||
|
||||
if (should_display) {
|
||||
auto addr = create_window_payload.getAddress();
|
||||
auto it = std::ranges::find_if(
|
||||
m_windowMap, [&addr](const auto& window) { return window.address == addr; });
|
||||
@@ -250,7 +257,7 @@ void Workspace::insertWindow(WindowCreationPayload create_window_payload) {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bool Workspace::onWindowOpened(WindowCreationPayload const& create_window_payload) {
|
||||
if (create_window_payload.getWorkspaceName() == name()) {
|
||||
@@ -390,7 +397,9 @@ void Workspace::update(const std::string& workspace_icon) {
|
||||
|
||||
bool Workspace::isEmpty() const {
|
||||
auto ignore_list = m_workspaceManager.getIgnoredWindows();
|
||||
if (ignore_list.empty()) {
|
||||
const bool no_ignore_rules = ignore_list.empty();
|
||||
|
||||
if (no_ignore_rules) {
|
||||
return m_windows == 0;
|
||||
}
|
||||
// If there are windows but they are all ignored, consider the workspace empty
|
||||
@@ -472,7 +481,9 @@ void Workspace::updateTaskbar(const std::string& workspace_icon) {
|
||||
}
|
||||
|
||||
auto formatAfter = m_workspaceManager.formatAfter();
|
||||
if (!formatAfter.empty()) {
|
||||
const bool has_format_after = !formatAfter.empty();
|
||||
|
||||
if (has_format_after) {
|
||||
m_labelAfter.set_markup(fmt::format(fmt::runtime(formatAfter), fmt::arg("id", id()),
|
||||
fmt::arg("name", name()),
|
||||
fmt::arg("icon", workspace_icon)));
|
||||
|
||||
@@ -85,7 +85,7 @@ void waybar::modules::MPD::setLabel() {
|
||||
? config_["format-disconnected"].asString()
|
||||
: "disconnected";
|
||||
if (format.empty()) {
|
||||
label_.set_markup(format);
|
||||
setLabelMarkup(format);
|
||||
label_.show();
|
||||
} else {
|
||||
label_.hide();
|
||||
@@ -97,7 +97,7 @@ void waybar::modules::MPD::setLabel() {
|
||||
? config_["tooltip-format-disconnected"].asString()
|
||||
: "MPD (disconnected)";
|
||||
// Nothing to format
|
||||
label_.set_tooltip_markup(tooltip_format);
|
||||
setTooltipMarkup(tooltip_format);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -124,8 +124,9 @@ void waybar::modules::MPD::setLabel() {
|
||||
label_.get_style_context()->add_class("playing");
|
||||
label_.get_style_context()->remove_class("paused");
|
||||
} else if (paused()) {
|
||||
format = config_["format-paused"].isString() ? config_["format-paused"].asString()
|
||||
: config_["format"].asString();
|
||||
if (config_["format-paused"].isString()) {
|
||||
format = config_["format-paused"].asString();
|
||||
}
|
||||
label_.get_style_context()->add_class("paused");
|
||||
label_.get_style_context()->remove_class("playing");
|
||||
}
|
||||
@@ -168,7 +169,7 @@ void waybar::modules::MPD::setLabel() {
|
||||
label_.hide();
|
||||
} else {
|
||||
label_.show();
|
||||
label_.set_markup(text);
|
||||
setLabelMarkup(text);
|
||||
}
|
||||
} catch (fmt::format_error const& e) {
|
||||
spdlog::warn("mpd: format error: {}", e.what());
|
||||
@@ -188,7 +189,7 @@ void waybar::modules::MPD::setLabel() {
|
||||
fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon),
|
||||
fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon),
|
||||
fmt::arg("singleIcon", singleIcon), fmt::arg("filename", filename), fmt::arg("uri", uri));
|
||||
label_.set_tooltip_markup(tooltip_text);
|
||||
setTooltipMarkup(tooltip_text);
|
||||
} catch (fmt::format_error const& e) {
|
||||
spdlog::warn("mpd: format error (tooltip): {}", e.what());
|
||||
}
|
||||
|
||||
@@ -94,12 +94,12 @@ auto Window::update() -> void {
|
||||
old_app_id_ = app_id_;
|
||||
}
|
||||
|
||||
label_.set_markup(waybar::util::rewriteString(
|
||||
setLabelMarkup(waybar::util::rewriteString(
|
||||
fmt::format(fmt::runtime(format_), fmt::arg("title", window_), fmt::arg("app_id", app_id_),
|
||||
fmt::arg("shell", shell_), fmt::arg("marks", marks_)),
|
||||
config_["rewrite"]));
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_markup(window_);
|
||||
setTooltipMarkup(window_);
|
||||
}
|
||||
|
||||
updateAppIcon();
|
||||
|
||||
@@ -94,9 +94,35 @@ Task::Task(const waybar::Bar& bar, const Json::Value& config, Taskbar* tbar,
|
||||
|
||||
button.set_relief(Gtk::RELIEF_NONE);
|
||||
|
||||
content_.add(text_before_);
|
||||
content_.add(icon_);
|
||||
content_.add(text_after_);
|
||||
/* When "expand" is enabled the buttons stretch to fill the taskbar and the
|
||||
* titles ellipsize to fit within the available space. This only makes sense
|
||||
* on a horizontal bar; on a vertical bar the box grows along the vertical
|
||||
* axis, so ellipsizing/forcing width_chars(1) would truncate every title to
|
||||
* "…". Keep the historical behavior (buttons sized to their content) as the
|
||||
* default and when the bar is vertical. */
|
||||
bool expand = config_["expand"].isBool() && config_["expand"].asBool();
|
||||
bool horizontal = bar.orientation == Gtk::ORIENTATION_HORIZONTAL;
|
||||
|
||||
if (expand && horizontal) {
|
||||
button.set_hexpand(true);
|
||||
content_.set_hexpand(true);
|
||||
text_before_.set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
text_before_.set_single_line_mode(true);
|
||||
text_before_.set_width_chars(1);
|
||||
text_before_.set_xalign(0.0);
|
||||
text_after_.set_ellipsize(Pango::ELLIPSIZE_END);
|
||||
text_after_.set_single_line_mode(true);
|
||||
text_after_.set_width_chars(1);
|
||||
text_after_.set_xalign(0.0);
|
||||
|
||||
content_.pack_start(text_before_, true, true, 0);
|
||||
content_.pack_start(icon_, false, false, 0);
|
||||
content_.pack_start(text_after_, true, true, 0);
|
||||
} else {
|
||||
content_.add(text_before_);
|
||||
content_.add(icon_);
|
||||
content_.add(text_after_);
|
||||
}
|
||||
|
||||
content_.show();
|
||||
button.add(content_);
|
||||
@@ -718,7 +744,15 @@ void Taskbar::handle_finished() {
|
||||
}
|
||||
|
||||
void Taskbar::add_button(Gtk::Button& bt) {
|
||||
box_.pack_start(bt, false, false);
|
||||
/* Only let the buttons expand to fill the taskbar when "expand" is enabled
|
||||
* and the bar is horizontal (see the Task constructor for details). */
|
||||
bool expand = config_["expand"].isBool() && config_["expand"].asBool();
|
||||
bool horizontal = bar_.orientation == Gtk::ORIENTATION_HORIZONTAL;
|
||||
if (expand && horizontal) {
|
||||
box_.pack_start(bt, true, true);
|
||||
} else {
|
||||
box_.pack_start(bt, false, false);
|
||||
}
|
||||
box_.get_style_context()->remove_class("empty");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user