Skip to content

Commit

Permalink
Modifier key now sends the bar to TOP or BOTTOM layer, hidden class g…
Browse files Browse the repository at this point in the history
…ets updated
  • Loading branch information
emirror-de committed Sep 14, 2021
1 parent 6c3b7e4 commit c11aecd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class Bar {
~Bar() = default;

void setVisible(bool visible);
void setHiddenClass(bool value);
void moveToTopLayer();
void moveToBottomLayer();
void toggle();
void setExclusive(bool value);
void handleSignal(int);
Expand Down
16 changes: 16 additions & 0 deletions src/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,22 @@ void waybar::Bar::setVisible(bool value) {
surface_impl_->commit();
}

void waybar::Bar::setHiddenClass(bool value) {
if (value) {
window.get_style_context()->add_class("hidden");
} else {
window.get_style_context()->remove_class("hidden");
}
}

void waybar::Bar::moveToTopLayer() {
surface_impl_->setLayer(bar_layer::TOP);
surface_impl_->commit();
}

void waybar::Bar::moveToBottomLayer() {
surface_impl_->setLayer(bar_layer::BOTTOM);
surface_impl_->commit();
}

void waybar::Bar::setExclusive(bool value) {
Expand Down
12 changes: 9 additions & 3 deletions src/modules/sway/hide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ void Hide::onEvent(const struct Ipc::ipc_response& res) {
bar->setVisible(true);
bar->setExclusive(true);
}
}
}
} else if (payload.isMember("visible_by_modifier")) {
// bar_state_update: get visible_by_modifier
visible_by_modifier_ = payload["visible_by_modifier"].asBool();
spdlog::debug("sway/hide: visible by modifier: {}", visible_by_modifier_);
for (auto& bar : waybar::Client::inst()->bars) {
bar->setVisible(visible_by_modifier_);
if (visible_by_modifier_) {
bar->setHiddenClass(false);
bar->moveToTopLayer();
} else {
bar->setHiddenClass(true);
bar->moveToBottomLayer();
bar->setExclusive(false);
}
}
}
}
Expand Down

0 comments on commit c11aecd

Please sign in to comment.