mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 17:31:28 +00:00
swaynag: adds option to set wayland shell layer
Uses --layer/-y set to overlay|top|bottom|background
This commit is contained in:
parent
75a4122f7a
commit
d13090be54
|
@ -7,6 +7,7 @@ struct swaynag_type {
|
||||||
char *font;
|
char *font;
|
||||||
char *output;
|
char *output;
|
||||||
uint32_t anchors;
|
uint32_t anchors;
|
||||||
|
int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
uint32_t button_text;
|
uint32_t button_text;
|
||||||
|
|
|
@ -59,6 +59,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
|
||||||
{"config", required_argument, NULL, 'c'},
|
{"config", required_argument, NULL, 'c'},
|
||||||
{"debug", no_argument, NULL, 'd'},
|
{"debug", no_argument, NULL, 'd'},
|
||||||
{"edge", required_argument, NULL, 'e'},
|
{"edge", required_argument, NULL, 'e'},
|
||||||
|
{"layer", required_argument, NULL, 'y'},
|
||||||
{"font", required_argument, NULL, 'f'},
|
{"font", required_argument, NULL, 'f'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"detailed-message", no_argument, NULL, 'l'},
|
{"detailed-message", no_argument, NULL, 'l'},
|
||||||
|
@ -104,6 +105,8 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
|
||||||
" -c, --config <path> Path to config file.\n"
|
" -c, --config <path> Path to config file.\n"
|
||||||
" -d, --debug Enable debugging.\n"
|
" -d, --debug Enable debugging.\n"
|
||||||
" -e, --edge top|bottom Set the edge to use.\n"
|
" -e, --edge top|bottom Set the edge to use.\n"
|
||||||
|
" -y, --layer overlay|top|bottom|background\n"
|
||||||
|
" Set the layer to use.\n"
|
||||||
" -f, --font <font> Set the font to use.\n"
|
" -f, --font <font> Set the font to use.\n"
|
||||||
" -h, --help Show help message and quit.\n"
|
" -h, --help Show help message and quit.\n"
|
||||||
" -l, --detailed-message Read a detailed message from stdin.\n"
|
" -l, --detailed-message Read a detailed message from stdin.\n"
|
||||||
|
@ -133,7 +136,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
int c = getopt_long(argc, argv, "b:B:z:Z:c:de:f:hlL:m:o:s:t:v", opts, NULL);
|
int c = getopt_long(argc, argv, "b:B:z:Z:c:de:y:f:hlL:m:o:s:t:v", opts, NULL);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -184,6 +187,24 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'y': // Layer
|
||||||
|
if (type) {
|
||||||
|
if (strcmp(optarg, "background") == 0) {
|
||||||
|
type->layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||||
|
} else if (strcmp(optarg, "bottom") == 0) {
|
||||||
|
type->layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
|
||||||
|
} else if (strcmp(optarg, "top") == 0) {
|
||||||
|
type->layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;
|
||||||
|
} else if (strcmp(optarg, "overlay") == 0) {
|
||||||
|
type->layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Invalid layer: %s\n"
|
||||||
|
"Usage: --layer overlay|top|bottom|background\n",
|
||||||
|
optarg);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'f': // Font
|
case 'f': // Font
|
||||||
if (type) {
|
if (type) {
|
||||||
free(type->font);
|
free(type->font);
|
||||||
|
|
|
@ -48,6 +48,9 @@ _swaynag_ [options...]
|
||||||
*-e, --edge* top|bottom
|
*-e, --edge* top|bottom
|
||||||
Set the edge to use.
|
Set the edge to use.
|
||||||
|
|
||||||
|
*-y, --layer* overlay|top|bottom|background
|
||||||
|
Set the layer to use.
|
||||||
|
|
||||||
*-f, --font* <font>
|
*-f, --font* <font>
|
||||||
Set the font to use.
|
Set the font to use.
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,9 @@ Additionally, the following options can be assigned a default per-type:
|
||||||
*edge=top|bottom*
|
*edge=top|bottom*
|
||||||
Set the edge to use.
|
Set the edge to use.
|
||||||
|
|
||||||
|
*layer=overlay|top|bottom|background*
|
||||||
|
Set the layer to use.
|
||||||
|
|
||||||
*font=<font>*
|
*font=<font>*
|
||||||
Set the font to use.
|
Set the font to use.
|
||||||
|
|
||||||
|
|
|
@ -476,7 +476,8 @@ void swaynag_setup(struct swaynag *swaynag) {
|
||||||
swaynag->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
swaynag->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||||
swaynag->layer_shell, swaynag->surface,
|
swaynag->layer_shell, swaynag->surface,
|
||||||
swaynag->output ? swaynag->output->wl_output : NULL,
|
swaynag->output ? swaynag->output->wl_output : NULL,
|
||||||
ZWLR_LAYER_SHELL_V1_LAYER_TOP, "swaynag");
|
swaynag->type->layer,
|
||||||
|
"swaynag");
|
||||||
assert(swaynag->layer_surface);
|
assert(swaynag->layer_surface);
|
||||||
zwlr_layer_surface_v1_add_listener(swaynag->layer_surface,
|
zwlr_layer_surface_v1_add_listener(swaynag->layer_surface,
|
||||||
&layer_surface_listener, swaynag);
|
&layer_surface_listener, swaynag);
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct swaynag_type *swaynag_type_new(const char *name) {
|
||||||
type->button_gap_close = -1;
|
type->button_gap_close = -1;
|
||||||
type->button_margin_right = -1;
|
type->button_margin_right = -1;
|
||||||
type->button_padding = -1;
|
type->button_padding = -1;
|
||||||
|
type->layer = -1;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ void swaynag_types_add_default(list_t *types) {
|
||||||
type_defaults->anchors = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
|
type_defaults->anchors = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP
|
||||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
| ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT
|
||||||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||||
|
type_defaults->layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;
|
||||||
type_defaults->button_background = 0x333333FF;
|
type_defaults->button_background = 0x333333FF;
|
||||||
type_defaults->details_background = 0x333333FF;
|
type_defaults->details_background = 0x333333FF;
|
||||||
type_defaults->background = 0x323232FF;
|
type_defaults->background = 0x323232FF;
|
||||||
|
@ -100,6 +102,10 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) {
|
||||||
dest->anchors = src->anchors;
|
dest->anchors = src->anchors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src->layer >= 0) {
|
||||||
|
dest->layer = src->layer;
|
||||||
|
}
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
if (src->button_background > 0) {
|
if (src->button_background > 0) {
|
||||||
dest->button_background = src->button_background;
|
dest->button_background = src->button_background;
|
||||||
|
|
Loading…
Reference in a new issue