feat(swaybar-ipc): handle visibility_by_modifier update
parent
bc13453155
commit
ebdeb86703
|
@ -33,12 +33,14 @@ class BarIpcClient {
|
|||
void onIpcEvent(const struct Ipc::ipc_response&);
|
||||
void onConfigUpdate(const swaybar_config& config);
|
||||
void onVisibilityUpdate(bool visible_by_modifier);
|
||||
void update();
|
||||
|
||||
Bar& bar_;
|
||||
util::JsonParser parser_;
|
||||
Ipc ipc_;
|
||||
|
||||
swaybar_config bar_config_;
|
||||
bool visible_by_modifier_ = false;
|
||||
|
||||
SafeSignal<bool> signal_visible_;
|
||||
SafeSignal<swaybar_config> signal_config_;
|
||||
|
|
|
@ -82,12 +82,23 @@ void BarIpcClient::onIpcEvent(const struct Ipc::ipc_response& res) {
|
|||
void BarIpcClient::onConfigUpdate(const swaybar_config& config) {
|
||||
spdlog::info("config update: {} {} {}", config.id, config.mode, config.position);
|
||||
bar_config_ = config;
|
||||
bar_.setMode(bar_config_.mode);
|
||||
update();
|
||||
}
|
||||
|
||||
void BarIpcClient::onVisibilityUpdate(bool visible_by_modifier) {
|
||||
spdlog::trace("visiblity update: {}", visible_by_modifier);
|
||||
// TODO: pass visibility to bars
|
||||
visible_by_modifier_ = visible_by_modifier;
|
||||
update();
|
||||
}
|
||||
|
||||
void BarIpcClient::update() {
|
||||
bool visible = visible_by_modifier_;
|
||||
if (bar_config_.mode == "invisible") {
|
||||
visible = false;
|
||||
} else if (bar_config_.mode != "hide" || bar_config_.hidden_state != "hide") {
|
||||
visible = true;
|
||||
}
|
||||
bar_.setMode(visible ? bar_config_.mode : Bar::MODE_INVISIBLE);
|
||||
}
|
||||
|
||||
} // namespace waybar::modules::sway
|
||||
|
|
Loading…
Reference in New Issue