Add layer option

Only applies to Wayland and the default is still bottom.
This commit is contained in:
Nulo 2021-08-25 13:20:33 -03:00 committed by Daniel Eklöf
parent 7e7c011126
commit eb94c8cceb
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 35 additions and 1 deletions

View file

@ -17,6 +17,8 @@
individually. `border.width` is now a short-hand for setting all individually. `border.width` is now a short-hand for setting all
four borders to the same value four borders to the same value
(https://codeberg.org/dnkl/yambar/issues/77). (https://codeberg.org/dnkl/yambar/issues/77).
* bar: `layer: top|bottom`, allowing the layer which the bar is
rendered on to be changed. Wayland only - ignored on X11.
* river: `per-output: false|true`. * river: `per-output: false|true`.
* `-d,--log-level=info|warning|error|none` command line option * `-d,--log-level=info|warning|error|none` command line option
(https://codeberg.org/dnkl/yambar/issues/84). (https://codeberg.org/dnkl/yambar/issues/84).

View file

@ -433,6 +433,7 @@ bar_new(const struct bar_config *config)
struct private *priv = calloc(1, sizeof(*priv)); struct private *priv = calloc(1, sizeof(*priv));
priv->monitor = config->monitor != NULL ? strdup(config->monitor) : NULL; priv->monitor = config->monitor != NULL ? strdup(config->monitor) : NULL;
priv->layer = config->layer;
priv->location = config->location; priv->location = config->location;
priv->height = config->height; priv->height = config->height;
priv->background = config->background; priv->background = config->background;

View file

@ -17,12 +17,14 @@ struct bar {
}; };
enum bar_location { BAR_TOP, BAR_BOTTOM }; enum bar_location { BAR_TOP, BAR_BOTTOM };
enum bar_layer { BAR_LAYER_TOP, BAR_LAYER_BOTTOM };
enum bar_backend { BAR_BACKEND_AUTO, BAR_BACKEND_XCB, BAR_BACKEND_WAYLAND }; enum bar_backend { BAR_BACKEND_AUTO, BAR_BACKEND_XCB, BAR_BACKEND_WAYLAND };
struct bar_config { struct bar_config {
enum bar_backend backend; enum bar_backend backend;
const char *monitor; const char *monitor;
enum bar_layer layer;
enum bar_location location; enum bar_location location;
int height; int height;
int left_spacing, right_spacing; int left_spacing, right_spacing;

View file

@ -6,6 +6,7 @@
struct private { struct private {
/* From bar_config */ /* From bar_config */
char *monitor; char *monitor;
enum bar_layer layer;
enum bar_location location; enum bar_location location;
int height; int height;
int left_spacing, right_spacing; int left_spacing, right_spacing;

View file

@ -988,10 +988,14 @@ setup(struct bar *_bar)
wl_surface_add_listener(backend->surface, &surface_listener, backend); wl_surface_add_listener(backend->surface, &surface_listener, backend);
enum zwlr_layer_shell_v1_layer layer = bar->layer == BAR_LAYER_BOTTOM
? ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM
: ZWLR_LAYER_SHELL_V1_LAYER_TOP;
backend->layer_surface = zwlr_layer_shell_v1_get_layer_surface( backend->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
backend->layer_shell, backend->surface, backend->layer_shell, backend->surface,
backend->monitor != NULL ? backend->monitor->output : NULL, backend->monitor != NULL ? backend->monitor->output : NULL,
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel"); layer, "panel");
if (backend->layer_surface == NULL) { if (backend->layer_surface == NULL) {
LOG_ERR("failed to create layer shell surface"); LOG_ERR("failed to create layer shell surface");

View file

@ -404,6 +404,12 @@ verify_bar_location(keychain_t *chain, const struct yml_node *node)
return conf_verify_enum(chain, node, (const char *[]){"top", "bottom"}, 2); return conf_verify_enum(chain, node, (const char *[]){"top", "bottom"}, 2);
} }
static bool
verify_bar_layer(keychain_t *chain, const struct yml_node *node)
{
return conf_verify_enum(chain, node, (const char *[]){"top", "bottom"}, 2);
}
bool bool
conf_verify_bar(const struct yml_node *bar) conf_verify_bar(const struct yml_node *bar)
{ {
@ -421,6 +427,7 @@ conf_verify_bar(const struct yml_node *bar)
{"background", true, &conf_verify_color}, {"background", true, &conf_verify_color},
{"monitor", false, &conf_verify_string}, {"monitor", false, &conf_verify_string},
{"layer", false, &verify_bar_layer},
{"spacing", false, &conf_verify_int}, {"spacing", false, &conf_verify_int},
{"left-spacing", false, &conf_verify_int}, {"left-spacing", false, &conf_verify_int},

View file

@ -204,6 +204,7 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend)
struct bar_config conf = { struct bar_config conf = {
.backend = backend, .backend = backend,
.layer = BAR_LAYER_BOTTOM,
}; };
/* /*
@ -228,6 +229,18 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend)
if (monitor != NULL) if (monitor != NULL)
conf.monitor = yml_value_as_string(monitor); conf.monitor = yml_value_as_string(monitor);
const struct yml_node *layer = yml_get_value(bar, "layer");
if (layer != NULL) {
const char *tmp = yml_value_as_string(layer);
if (strcmp(tmp, "top") == 0)
conf.layer = BAR_LAYER_TOP;
else if (strcmp(tmp, "bottom") == 0)
conf.layer = BAR_LAYER_BOTTOM;
else
assert(false);
}
const struct yml_node *spacing = yml_get_value(bar, "spacing"); const struct yml_node *spacing = yml_get_value(bar, "spacing");
if (spacing != NULL) if (spacing != NULL)
conf.left_spacing = conf.right_spacing = yml_value_as_int(spacing); conf.left_spacing = conf.right_spacing = yml_value_as_int(spacing);

View file

@ -45,6 +45,10 @@ types that are frequently used:
: no : no
: Monitor to place the bar on. If not specified, the primary monitor will be : Monitor to place the bar on. If not specified, the primary monitor will be
used used
| layer
: string
: no
: Layer to put bar on. One of _top_ or _bottom_. Wayland only
| left-spacing | left-spacing
: int : int
: no : no