From 61f03d87cb3b749dab16e73243194cae4b5bfd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 9 Aug 2024 22:05:04 -0600 Subject: [PATCH] introduce client_set_scale() --- client.h | 6 ++++++ dwl.c | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client.h b/client.h index e0c45fd..04f0f1d 100644 --- a/client.h +++ b/client.h @@ -333,6 +333,12 @@ client_set_fullscreen(Client *c, int fullscreen) wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen); } +static inline void +client_set_scale(struct wlr_surface *s, float scale) { + wlr_fractional_scale_v1_notify_scale(s, scale); + wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale)); +} + static inline uint32_t client_set_size(Client *c, uint32_t width, uint32_t height) { diff --git a/dwl.c b/dwl.c index a43e445..b2cd822 100644 --- a/dwl.c +++ b/dwl.c @@ -759,8 +759,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data) struct wlr_layer_surface_v1_state old_state; if (l->layer_surface->initial_commit) { - wlr_fractional_scale_v1_notify_scale(layer_surface->surface, l->mon->wlr_output->scale); - wlr_surface_set_preferred_buffer_scale(layer_surface->surface, (int32_t)ceilf(l->mon->wlr_output->scale)); + client_set_scale(layer_surface->surface, l->mon->wlr_output->scale); /* Temporarily set the layer's current state to pending * so that we can easily arrange it */ @@ -799,8 +798,7 @@ commitnotify(struct wl_listener *listener, void *data) * a wrong monitor. */ applyrules(c); - wlr_surface_set_preferred_buffer_scale(client_surface(c), (int)ceilf(c->mon->wlr_output->scale)); - wlr_fractional_scale_v1_notify_scale(client_surface(c), c->mon->wlr_output->scale); + client_set_scale(client_surface(c), c->mon->wlr_output->scale); setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */ wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);