Merge pull request #3926 from casKd-dev/dwl/hide-title

dwl/window: allow hiding of title when either inactive or empty
This commit is contained in:
Alexis Rouillard
2026-07-03 23:20:36 +02:00
committed by GitHub
3 changed files with 45 additions and 2 deletions
+27 -2
View File
@@ -19,7 +19,7 @@ static void toggle_visibility(void* data, zdwl_ipc_output_v2* zdwl_output_v2) {
}
static void active(void* data, zdwl_ipc_output_v2* zdwl_output_v2, uint32_t active) {
// Intentionally empty
static_cast<Window*>(data)->handle_active(active);
}
static void set_tag(void* data, zdwl_ipc_output_v2* zdwl_output_v2, uint32_t tag, uint32_t state,
@@ -74,7 +74,17 @@ static const wl_registry_listener registry_listener_impl = {.global = handle_glo
.global_remove = handle_global_remove};
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
: AAppIconLabel(config, "window", id, "{}", 0, true), bar_(bar) {
: AAppIconLabel(config, "window", id, "{}", 0, true),
bar_(bar),
active_(false),
hide_inactive_(false),
hide_empty_(false) {
if (config_["hide-inactive"].isBool()) {
hide_inactive_ = config["hide-inactive"].asBool();
}
if (config_["hide-empty"].isBool()) {
hide_empty_ = config["hide-empty"].asBool();
}
struct wl_display* display = Client::inst()->wl_display;
struct wl_registry* registry = wl_display_get_registry(display);
@@ -102,6 +112,8 @@ void Window::handle_title(const char* title) { title_ = Glib::Markup::escape_tex
void Window::handle_appid(const char* appid) { appid_ = Glib::Markup::escape_text(appid); }
void Window::handle_active(const uint32_t active) { active_ = active != 0; }
void Window::handle_layout_symbol(const char* layout_symbol) {
layout_symbol_ = Glib::Markup::escape_text(layout_symbol);
}
@@ -118,6 +130,19 @@ void Window::handle_frame() {
if (tooltipEnabled()) {
label_.set_tooltip_markup(title_);
}
if (hide_empty_ && title_.empty()) {
box_.set_visible(false);
} else {
if (active_) {
box_.get_style_context()->add_class("active");
box_.set_visible(true);
} else {
box_.get_style_context()->remove_class("active");
if (hide_inactive_) {
box_.set_visible(false);
}
}
}
}
} // namespace waybar::modules::dwl