diff --git a/CHANGELOG.md b/CHANGELOG.md index 85a7469..01bd423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,9 +31,12 @@ * map: conditions failing to match when they contain multiple, quoted tag values ([#302][302]). * Crash when hidden by an opaque window. +* Bar not resizing itself when the screen resolution is changed + ([#330][330]). [311]: https://codeberg.org/dnkl/yambar/issues/311 [302]: https://codeberg.org/dnkl/yambar/issues/302 +[330]: https://codeberg.org/dnkl/yambar/issues/330 ### Security diff --git a/bar/wayland.c b/bar/wayland.c index 2b1e0a5..22ca3e2 100644 --- a/bar/wayland.c +++ b/bar/wayland.c @@ -475,13 +475,24 @@ output_mode(void *data, struct wl_output *wl_output, uint32_t flags, { } +static bool update_size(struct wayland_backend *backend); +static void refresh(const struct bar *_bar); + static void output_done(void *data, struct wl_output *wl_output) { -} + struct monitor *mon = data; -static bool update_size(struct wayland_backend *backend); -static void refresh(const struct bar *_bar); + if (mon->backend->monitor == mon) { + int old_scale = mon->backend->scale; + int old_width = mon->backend->width; + + update_size(mon->backend); + + if (mon->backend->scale != old_scale || mon->backend->width != old_width) + refresh(mon->backend->bar); + } +} static void output_scale(void *data, struct wl_output *wl_output, int32_t factor) @@ -491,14 +502,6 @@ output_scale(void *data, struct wl_output *wl_output, int32_t factor) return; mon->scale = factor; - - if (mon->backend->monitor == mon) { - int old_scale = mon->backend->scale; - update_size(mon->backend); - - if (mon->backend->scale != old_scale) - refresh(mon->backend->bar); - } } #if defined(WL_OUTPUT_NAME_SINCE_VERSION) @@ -1058,9 +1061,6 @@ update_size(struct wayland_backend *backend) assert(backend->surface != NULL); - if (backend->scale == scale) - return true; - backend->scale = scale; int height = bar->height_with_border;