Skip to content

Commit

Permalink
wayland: fix wl_surface_set_buffer_scale usage
Browse files Browse the repository at this point in the history
The wl_surface lives for the entire lifetime of the vo. It's only
neccesary to set the scale initially and when the output scaling changes
(the surface moves to a different output with a different scale or the
output itself changes it scale). All of the calls that were being made
in the egl/vulkan resize functions are not needed. vo_wlshm wasn't
correctly rescaling itself before this commit since it had no logic to
handle scale changes. This should all be shared, common code in the
surface/output listeners.
  • Loading branch information
Dudemanguy committed Jun 27, 2021
1 parent 76bddac commit a02901c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions video/out/opengl/context_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ static void resize(struct ra_ctx *ctx)
const int32_t height = wl->scaling * mp_rect_h(wl->geometry);

vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
wl_surface_set_buffer_scale(wl->surface, wl->scaling);

if (p->egl_window)
wl_egl_window_resize(p->egl_window, width, height, 0, 0);

Expand Down
1 change: 0 additions & 1 deletion video/out/vulkan/context_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ static bool resize(struct ra_ctx *ctx)
const int32_t height = wl->scaling * mp_rect_h(wl->geometry);

vo_wayland_set_opaque_region(wl, ctx->opts.want_alpha);
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
return ra_vk_ctx_resize(ctx, width, height);
}

Expand Down
2 changes: 2 additions & 0 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ static void output_handle_done(void* data, struct wl_output *wl_output)
* geometry and scaling should be recalculated. */
if (wl->current_output && wl->current_output->output == wl_output) {
wl->scaling = wl->current_output->scale;
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
spawn_cursor(wl);
set_geometry(wl);
wl->window_size = wl->vdparams;
Expand Down Expand Up @@ -711,6 +712,7 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
if (wl->scaling != wl->current_output->scale && wl->vo_opts->hidpi_window_scale) {
double factor = (double)wl->scaling / wl->current_output->scale;
wl->scaling = wl->current_output->scale;
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
spawn_cursor(wl);
rescale_geometry_dimensions(wl, factor);
wl->pending_vo_events |= VO_EVENT_DPI;
Expand Down

0 comments on commit a02901c

Please sign in to comment.