mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -04:00
Drop wmenu -x option
This commit is contained in:
parent
e4c4627eeb
commit
6a39269d2e
5 changed files with 4 additions and 61 deletions
54
menu.c
54
menu.c
|
|
@ -94,7 +94,7 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
|||
"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "bhiPvxf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "bhiPvf:l:o:p:N:n:M:m:S:s:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
menu->bottom = true;
|
||||
|
|
@ -108,9 +108,6 @@ void menu_getopts(struct menu *menu, int argc, char *argv[]) {
|
|||
case 'v':
|
||||
puts("wmenu " VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'x':
|
||||
menu->exec = true;
|
||||
break;
|
||||
case 'f':
|
||||
menu->font = optarg;
|
||||
break;
|
||||
|
|
@ -413,53 +410,6 @@ static void movewordedge(struct menu *menu, int dir) {
|
|||
}
|
||||
}
|
||||
|
||||
// Information needed to execute an item.
|
||||
struct executable {
|
||||
struct menu *menu;
|
||||
char *name;
|
||||
};
|
||||
|
||||
// Executes an item with an activation token.
|
||||
static void execute(struct executable *exe, const char *token) {
|
||||
menu_destroy(exe->menu);
|
||||
|
||||
setenv("XDG_ACTIVATION_TOKEN", token, true);
|
||||
execlp(exe->name, exe->name, NULL);
|
||||
|
||||
// Handle execution failure
|
||||
fprintf(stderr, "Failed to execute selection: %s\n", strerror(errno));
|
||||
free(exe->name);
|
||||
free(exe);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void activation_token_done(void *data, struct xdg_activation_token_v1 *activation_token,
|
||||
const char *token) {
|
||||
struct executable *exe = data;
|
||||
xdg_activation_token_v1_destroy(activation_token);
|
||||
execute(exe, token);
|
||||
}
|
||||
|
||||
static const struct xdg_activation_token_v1_listener activation_token_listener = {
|
||||
.done = activation_token_done,
|
||||
};
|
||||
|
||||
// Executes the selected item.
|
||||
static void menu_exec(struct menu *menu) {
|
||||
if (!menu->sel) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct executable *exe = calloc(1, sizeof(struct executable));
|
||||
exe->menu = menu;
|
||||
exe->name = strdup(menu->sel->text);
|
||||
|
||||
struct xdg_activation_token_v1 *activation_token = xdg_activation_v1_get_activation_token(menu->activation);
|
||||
xdg_activation_token_v1_set_surface(activation_token, menu->surface);
|
||||
xdg_activation_token_v1_add_listener(activation_token, &activation_token_listener, exe);
|
||||
xdg_activation_token_v1_commit(activation_token);
|
||||
}
|
||||
|
||||
// Handle a keypress.
|
||||
void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
|
||||
xkb_keysym_t sym) {
|
||||
|
|
@ -639,8 +589,6 @@ void menu_keypress(struct menu *menu, enum wl_keyboard_key_state key_state,
|
|||
puts(menu->input);
|
||||
fflush(stdout);
|
||||
menu->exit = true;
|
||||
} else if (menu->exec) {
|
||||
menu_exec(menu);
|
||||
} else {
|
||||
char *text = menu->sel ? menu->sel->text : menu->input;
|
||||
puts(text);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue