mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -04:00
add option to set exclusive zone
This commit is contained in:
parent
fc69aa6e2b
commit
937c0c4e77
4 changed files with 17 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ wmenu - dynamic menu for Wayland
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
*wmenu* [-biPv] \
|
||||
*wmenu* [-bxiPv] \
|
||||
[-f _font_] \
|
||||
[-l _lines_] \
|
||||
[-o _output_] \
|
||||
|
|
@ -32,6 +32,9 @@ $PATH and runs the result.
|
|||
*-b*
|
||||
wmenu appears at the bottom of the screen.
|
||||
|
||||
*-x*
|
||||
wmenu avoids overlapping panels and occluding other exclusive surfaces.
|
||||
|
||||
*-i*
|
||||
wmenu matches menu items case insensitively.
|
||||
|
||||
|
|
|
|||
7
menu.c
7
menu.c
|
|
@ -85,15 +85,18 @@ static bool parse_color(const char *color, uint32_t *result) {
|
|||
// Parse menu options from command line arguments.
|
||||
void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
||||
const char *usage =
|
||||
"Usage: wmenu [-biPv] [-f font] [-l lines] [-o output] [-p prompt]\n"
|
||||
"Usage: wmenu [-bxiPv] [-f font] [-l lines] [-o output] [-p prompt]\n"
|
||||
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "bhiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "bxhiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
menu->bottom = true;
|
||||
break;
|
||||
case 'x':
|
||||
menu->exclusive = true;
|
||||
break;
|
||||
case 'i':
|
||||
menu->strncmp = strncasecmp;
|
||||
break;
|
||||
|
|
|
|||
2
menu.h
2
menu.h
|
|
@ -31,6 +31,8 @@ struct page {
|
|||
struct menu {
|
||||
// Whether the menu appears at the bottom of the screen
|
||||
bool bottom;
|
||||
// Set exclusive zone
|
||||
bool exclusive;
|
||||
// The function used to match menu items
|
||||
int (*strncmp)(const char *, const char *, size_t);
|
||||
// Whether the input is a password
|
||||
|
|
|
|||
|
|
@ -454,9 +454,14 @@ int menu_run(struct menu *menu) {
|
|||
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
|
||||
}
|
||||
|
||||
if (menu->exclusive) {
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, 0);
|
||||
} else {
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, -1);
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, menu->height);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, -1);
|
||||
zwlr_layer_surface_v1_set_keyboard_interactivity(layer_surface, true);
|
||||
zwlr_layer_surface_v1_add_listener(layer_surface, &layer_surface_listener, context);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue