From f29f96be96f25055210ed53c4c9ac89791151db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 22 Sep 2019 12:08:08 +0200 Subject: [PATCH] bar/wayland: use preferred monitor if user didn't specify one --- bar/wayland.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bar/wayland.c b/bar/wayland.c index 23edb81..a858260 100644 --- a/bar/wayland.c +++ b/bar/wayland.c @@ -51,6 +51,7 @@ struct monitor { int width_px; int height_px; + bool preferred; int scale; }; @@ -269,6 +270,8 @@ static void output_mode(void *data, struct wl_output *wl_output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) { + struct monitor *mon = data; + mon->preferred = flags & WL_OUTPUT_MODE_PREFERRED; } static void @@ -588,11 +591,15 @@ setup(struct bar *_bar) mon->name, mon->width_px, mon->height_px, mon->x, mon->y, mon->width_mm, mon->height_mm); - /* TODO: detect primary output when user hasn't specified a monitor */ - if (bar->monitor == NULL) + if (bar->monitor == NULL && mon->preferred) { + /* User didn't specify a monitor, and this is the default one */ backend->monitor = mon; - else if (strcmp(bar->monitor, mon->name) == 0) + } + + else if (bar->monitor != NULL && strcmp(bar->monitor, mon->name) == 0) { + /* User specified a monitor, and this is one */ backend->monitor = mon; + } } if (backend->monitor == NULL) {