Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#3211) change layer for mode invisible to nullopt #3281

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/bar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <gtkmm/window.h>
#include <json/json.h>

#include <optional>
#include <memory>
#include <vector>

Expand Down Expand Up @@ -41,7 +42,7 @@ struct bar_margins {
};

struct bar_mode {
bar_layer layer;
std::optional<bar_layer> layer;
bool exclusive;
bool passthrough;
bool visible;
Expand Down
14 changes: 7 additions & 7 deletions src/bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Bar::bar_mode_map Bar::PRESET_MODES = { //
.visible = true}},
{"invisible",
{//
.layer = bar_layer::BOTTOM,
.layer = std::nullopt,
.exclusive = false,
.passthrough = true,
.visible = false}},
Expand All @@ -59,7 +59,7 @@ const std::string Bar::MODE_INVISIBLE = "invisible";
const std::string_view DEFAULT_BAR_ID = "bar-0";

/* Deserializer for enum bar_layer */
void from_json(const Json::Value& j, bar_layer& l) {
void from_json(const Json::Value& j, std::optional<bar_layer>& l) {
if (j == "bottom") {
l = bar_layer::BOTTOM;
} else if (j == "top") {
Expand Down Expand Up @@ -316,13 +316,13 @@ void waybar::Bar::setMode(const std::string& mode) {
void waybar::Bar::setMode(const struct bar_mode& mode) {
auto* gtk_window = window.gobj();

auto layer = GTK_LAYER_SHELL_LAYER_BOTTOM;
if (mode.layer == bar_layer::TOP) {
layer = GTK_LAYER_SHELL_LAYER_TOP;
if (mode.layer == bar_layer::BOTTOM) {
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_BOTTOM);
} else if (mode.layer == bar_layer::TOP) {
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_TOP);
} else if (mode.layer == bar_layer::OVERLAY) {
layer = GTK_LAYER_SHELL_LAYER_OVERLAY;
gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_OVERLAY);
}
gtk_layer_set_layer(gtk_window, layer);

if (mode.exclusive) {
gtk_layer_auto_exclusive_zone_enable(gtk_window);
Expand Down
Loading