Merge pull request #3281 from VlctM/master

fix(#3211) change layer for mode invisible to nullopt
master
Alexis Rouillard 2024-05-28 09:18:36 +02:00 committed by GitHub
commit b7ce0b05b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View File

@ -8,6 +8,7 @@
#include <gtkmm/window.h> #include <gtkmm/window.h>
#include <json/json.h> #include <json/json.h>
#include <optional>
#include <memory> #include <memory>
#include <vector> #include <vector>
@ -41,7 +42,7 @@ struct bar_margins {
}; };
struct bar_mode { struct bar_mode {
bar_layer layer; std::optional<bar_layer> layer;
bool exclusive; bool exclusive;
bool passthrough; bool passthrough;
bool visible; bool visible;

View File

@ -43,7 +43,7 @@ const Bar::bar_mode_map Bar::PRESET_MODES = { //
.visible = true}}, .visible = true}},
{"invisible", {"invisible",
{// {//
.layer = bar_layer::BOTTOM, .layer = std::nullopt,
.exclusive = false, .exclusive = false,
.passthrough = true, .passthrough = true,
.visible = false}}, .visible = false}},
@ -59,7 +59,7 @@ const std::string Bar::MODE_INVISIBLE = "invisible";
const std::string_view DEFAULT_BAR_ID = "bar-0"; const std::string_view DEFAULT_BAR_ID = "bar-0";
/* Deserializer for enum bar_layer */ /* 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") { if (j == "bottom") {
l = bar_layer::BOTTOM; l = bar_layer::BOTTOM;
} else if (j == "top") { } else if (j == "top") {
@ -316,13 +316,13 @@ void waybar::Bar::setMode(const std::string& mode) {
void waybar::Bar::setMode(const struct bar_mode& mode) { void waybar::Bar::setMode(const struct bar_mode& mode) {
auto* gtk_window = window.gobj(); auto* gtk_window = window.gobj();
auto layer = GTK_LAYER_SHELL_LAYER_BOTTOM; if (mode.layer == bar_layer::BOTTOM) {
if (mode.layer == bar_layer::TOP) { gtk_layer_set_layer(gtk_window, GTK_LAYER_SHELL_LAYER_BOTTOM);
layer = GTK_LAYER_SHELL_LAYER_TOP; } 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) { } 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) { if (mode.exclusive) {
gtk_layer_auto_exclusive_zone_enable(gtk_window); gtk_layer_auto_exclusive_zone_enable(gtk_window);