Merge pull request #2879 from Emantor/fix/swaybar_position
swaybar: disallow left and right position and print error on default
This commit is contained in:
commit
4bde0eb911
|
@ -12,7 +12,7 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) {
|
||||||
if (!config->current_bar) {
|
if (!config->current_bar) {
|
||||||
return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
|
return cmd_results_new(CMD_FAILURE, "position", "No bar defined.");
|
||||||
}
|
}
|
||||||
char *valid[] = { "top", "bottom", "left", "right" };
|
char *valid[] = { "top", "bottom" };
|
||||||
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) {
|
||||||
if (strcasecmp(valid[i], argv[0]) == 0) {
|
if (strcasecmp(valid[i], argv[0]) == 0) {
|
||||||
wlr_log(WLR_DEBUG, "Setting bar position '%s' for bar: %s",
|
wlr_log(WLR_DEBUG, "Setting bar position '%s' for bar: %s",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#define _XOPEN_SOURCE 500
|
#define _XOPEN_SOURCE 500
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <wlr/util/log.h>
|
||||||
#include "swaybar/config.h"
|
#include "swaybar/config.h"
|
||||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||||
#include "stringop.h"
|
#include "stringop.h"
|
||||||
|
@ -9,17 +10,12 @@
|
||||||
uint32_t parse_position(const char *position) {
|
uint32_t parse_position(const char *position) {
|
||||||
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||||
uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
|
|
||||||
if (strcmp("top", position) == 0) {
|
if (strcmp("top", position) == 0) {
|
||||||
return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz;
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz;
|
||||||
} else if (strcmp("bottom", position) == 0) {
|
} else if (strcmp("bottom", position) == 0) {
|
||||||
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
|
||||||
} else if (strcmp("left", position) == 0) {
|
|
||||||
return ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | vert;
|
|
||||||
} else if (strcmp("right", position) == 0) {
|
|
||||||
return ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | vert;
|
|
||||||
} else {
|
} else {
|
||||||
|
wlr_log(WLR_ERROR, "Invalid position: %s, defaulting to bottom", position);
|
||||||
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue