bar: wayland: update bar size + refresh in output_done()

This ensures the bar's size (width) is updated when the screen
resolution (and/or scale) is changed.

Note that we already handled scale changes. This logic has been moved
from output_scale() to output_done().

Closes #330
This commit is contained in:
Daniel Eklöf 2024-01-03 15:39:04 +01:00
parent 9365580539
commit cdee55afed
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 17 additions and 14 deletions

View file

@ -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

View file

@ -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;