Skip to content

Commit

Permalink
wayland: support showing bemenu on all monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Mar 25, 2020
1 parent cd53b7b commit 6343a65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ do_getopt(struct client *client, int *argc, char **argv[])
client->grab = true;
break;
case 'm':
client->monitor = strtol(optarg, NULL, 10);
client->monitor = (!strcmp(optarg, "all") ? -1 : strtol(optarg, NULL, 10));
break;
case 'n':
client->no_overlap = true;
Expand Down
14 changes: 8 additions & 6 deletions lib/renderers/wayland/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,18 @@ recreate_windows(const struct bm_menu *menu, struct wayland *wayland)
{
destroy_windows(wayland);

size_t monitors = 0;
uint32_t monitors = 0;
struct output *output;
wl_list_for_each(output, &wayland->outputs, link)
monitors++;

size_t monitor = 0;
uint32_t monitor = 0;
wl_list_for_each(output, &wayland->outputs, link) {
if (menu->monitor < monitors && monitor != menu->monitor) {
++monitor;
continue;
if (menu->monitor != (uint32_t)-1) {
if (menu->monitor < monitors && monitor != menu->monitor) {
++monitor;
continue;
}
}

struct wl_surface *surface;
Expand All @@ -270,7 +272,7 @@ recreate_windows(const struct bm_menu *menu, struct wayland *wayland)
window->max_height = output->height;
window->render_pending = true;
wl_list_insert(&wayland->windows, &window->link);
break;
if (menu->monitor != (uint32_t)-1) break;
}

set_overlap(menu, menu->overlap);
Expand Down
2 changes: 1 addition & 1 deletion lib/renderers/x11/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ set_monitor(const struct bm_menu *menu, uint32_t monitor)
{
struct x11 *x11 = menu->renderer->internal;
assert(x11);
bm_x11_window_set_monitor(&x11->window, monitor);
bm_x11_window_set_monitor(&x11->window, (monitor != (uint32_t)-1 ? monitor : 0));
}

static void
Expand Down
1 change: 1 addition & 0 deletions man/bemenu.1
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ These options are only available on backends specified in the parentheses
.TP
.BI \-m " INDEX" ", \-\-monitor=" INDEX
(Wayland, X11) Specify \fIINDEX\fR of the monitor where the menu should appear.
(Wayland) If index is \fI-1\fR or \fIall\fR then the menu will appear on all monitors.

.TP
.BI \-H " HEIGHT" ", \-\-line\-height=" HEIGHT
Expand Down

0 comments on commit 6343a65

Please sign in to comment.