1
0
mirror of https://github.com/Cloudef/bemenu synced 2024-11-23 09:21:59 +01:00

wayland: Allow showing the menu on the focused monitor

This adds an alias 'focused' for selecting the current monitor, which
becomes the default on x11 and wayland. The previous wayland default of
displaying on all outputs moves under '-2' or 'all'.

ref: https://github.com/Cloudef/bemenu/issues/102#issuecomment-604562234

Signed-off-by: Robert Günzler <r@gnzler.io>
This commit is contained in:
Robert Günzler 2021-05-20 22:53:01 +02:00 committed by Jari Vetoniemi
parent f23597ded0
commit 4612f9d327
3 changed files with 12 additions and 6 deletions

@ -219,8 +219,10 @@ set_monitor(struct client *client, char *arg)
char *endptr = NULL;
long num = strtol(arg, &endptr, 10);
if (arg == endptr) { // No digits found
if (!strcmp(arg, "all")) {
if (!strcmp(arg, "focused")) {
client->monitor = -1;
} else if (!strcmp(arg, "all")) {
client->monitor = -2;
} else {
client->monitor_name = arg;
}

@ -285,7 +285,7 @@ recreate_windows(const struct bm_menu *menu, struct wayland *wayland)
wl_list_for_each(output, &wayland->outputs, link) {
if (!menu->monitor_name) {
if (menu->monitor != -1) {
if (menu->monitor > -1) {
if (menu->monitor < monitors && monitor != menu->monitor) {
++monitor;
continue;
@ -311,14 +311,14 @@ recreate_windows(const struct bm_menu *menu, struct wayland *wayland)
window->scale = output->scale;
}
if (!bm_wl_window_create(window, wayland->display, wayland->shm, output->output, wayland->layer_shell, surface))
if (!bm_wl_window_create(window, wayland->display, wayland->shm, (menu->monitor == -1) ? NULL : output->output, wayland->layer_shell, surface))
free(window);
window->notify.render = bm_cairo_paint;
window->max_height = output->height;
window->render_pending = true;
wl_list_insert(&wayland->windows, &window->link);
if (menu->monitor != -1) break;
if (menu->monitor != -2) break;
}
set_overlap(menu, menu->overlap);

@ -124,14 +124,18 @@ Specify the monitor
where the list should appear.
Monitor indices start at zero.
The interpretation of the given argument depends on the utilized backend.
With X11, a value of
With X11 and Wayland, a value of
.Ql -1
or
.Cm focused
indicates that the current monitor should be used (the default).
With Wayland, the
.Ar index
should be a string specifying a specific monitor name. The value
.Ql -2
or
.Cm all
indicates that the list should appear on all monitors (the default).
indicates that the list should appear on all monitors.
.It Fl n , -no-overlap Pq Wayland
Set the
.Nm