@@ -19,7 +19,7 @@ static void toggle_visibility(void *data, zdwl_ipc_output_v2 *zdwl_output_v2) {
19
19
}
20
20
21
21
static void active (void *data, zdwl_ipc_output_v2 *zdwl_output_v2, uint32_t active) {
22
- // Intentionally empty
22
+ static_cast <Window *>(data)-> handle_active (active);
23
23
}
24
24
25
25
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
74
74
.global_remove = handle_global_remove};
75
75
76
76
Window::Window (const std::string &id, const Bar &bar, const Json::Value &config)
77
- : AAppIconLabel(config, " window" , id, " {}" , 0 , true ), bar_(bar) {
77
+ : AAppIconLabel(config, " window" , id, " {}" , 0 , true ),
78
+ bar_ (bar),
79
+ active_(false ),
80
+ hide_inactive_(false ),
81
+ hide_empty_(false ) {
82
+ if (config_[" hide-inactive" ].isBool ()) {
83
+ hide_inactive_ = config[" hide-inactive" ].asBool ();
84
+ }
85
+ if (config_[" hide-empty" ].isBool ()) {
86
+ hide_empty_ = config[" hide-empty" ].asBool ();
87
+ }
78
88
struct wl_display *display = Client::inst ()->wl_display ;
79
89
struct wl_registry *registry = wl_display_get_registry (display);
80
90
@@ -102,6 +112,8 @@ void Window::handle_title(const char *title) { title_ = Glib::Markup::escape_tex
102
112
103
113
void Window::handle_appid (const char *appid) { appid_ = Glib::Markup::escape_text (appid); }
104
114
115
+ void Window::handle_active (const uint32_t active) { active_ = active != 0 ; }
116
+
105
117
void Window::handle_layout_symbol (const char *layout_symbol) {
106
118
layout_symbol_ = Glib::Markup::escape_text (layout_symbol);
107
119
}
@@ -118,6 +130,19 @@ void Window::handle_frame() {
118
130
if (tooltipEnabled ()) {
119
131
label_.set_tooltip_text (title_);
120
132
}
133
+ if (hide_empty_ && title_ == " " ) {
134
+ box_.set_visible (false );
135
+ } else {
136
+ if (active_) {
137
+ box_.get_style_context ()->add_class (" active" );
138
+ box_.set_visible (true );
139
+ } else {
140
+ box_.get_style_context ()->remove_class (" active" );
141
+ if (hide_inactive_) {
142
+ box_.set_visible (false );
143
+ }
144
+ }
145
+ }
121
146
}
122
147
123
148
} // namespace waybar::modules::dwl
0 commit comments