diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 14:31:10 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-12 14:31:10 +0300 |
| commit | dfebac1019560e278c605247de3b98cff1d73226 (patch) | |
| tree | 21df3066f2e60496f259a5981ca5501b4e395b61 /src/wayland/buffer.c | |
| parent | 9ed89c17dee752154c36d71cae93d20cccfc71ef (diff) | |
perf: cache Cocoa software MTLBuffer and optimize Wayland output/focus loops
Diffstat (limited to 'src/wayland/buffer.c')
| -rw-r--r-- | src/wayland/buffer.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/wayland/buffer.c b/src/wayland/buffer.c index 0561da3..4cddfa5 100644 --- a/src/wayland/buffer.c +++ b/src/wayland/buffer.c @@ -200,24 +200,27 @@ static const struct wp_fractional_scale_v1_listener frac_scale_listener = { .preferred_scale = fractional_preferred_scale, }; -static void surface_follow_refresh(struct wayland_surface *w) +void surface_follow_outputs(struct wayland_surface *w) { uint32_t refresh = 0; - for (const struct wl_conn_output *o = w->conn->outputs; o; o = o->next) - if ((o->mask & w->outputs) && o->refresh_ns && - (!refresh || o->refresh_ns < refresh)) - refresh = o->refresh_ns; + int32_t max_scale = 0; + bool need_scale = !w->frac_scale && !surface_gets_preferred_scale(w->surface); + + for (const struct wl_conn_output *o = w->conn->outputs; o; o = o->next) { + if (o->mask & w->outputs) { + if (o->refresh_ns && (!refresh || o->refresh_ns < refresh)) + refresh = o->refresh_ns; + if (need_scale && o->scale > max_scale) + max_scale = o->scale; + } + } if (!refresh && w->conn->outputs) refresh = w->conn->outputs->refresh_ns; if (refresh) w->clock.refresh_ns = refresh; -} -void surface_follow_outputs(struct wayland_surface *w) -{ - surface_follow_refresh(w); - if (!w->frac_scale && !surface_gets_preferred_scale(w->surface)) - surface_request_scale(w, conn_output_scale_120(w->conn, w->outputs)); + if (need_scale) + surface_request_scale(w, (uint32_t)max_scale * YASL_SCALE_UNIT); } static void surface_enter(void *data, struct wl_surface *surface, struct wl_output *output) |
