Skip to content

Commit

Permalink
wayland: always be sure to initially try to render
Browse files Browse the repository at this point in the history
A subtle regression from c26d833. On sway if mpv was set to be a
floating window in the config, set_buffer_scale would actually get
applied twice according to the wayland log. That meant a 1920x1080
window would appear as a 960x540 window if the scale of the wl_output
was set to 2. This only affected egl on sway (didn't occur on weston and
was too lazy to try anything else; probably they were fine). Since
wl->render is initially false, that meant that the very first run
through the render loop returns false. This probably caused something
weird to happen with the set_buffer_scale calls (the egl window gets
created and everything but mpv doesn't write to it just yet) which makes
the set_buffer_scale call happen an extra time. Since it was always
intended for mpv to initally render, this is worth fixing. Just chnage
wl->render to wl->hidden (again) and flip the bools around. That way,
the initial false value results in render == true and mpv tries to draw
on the first pass. This fixes the weird scaling behavior because
reasons.
  • Loading branch information
Dudemanguy committed Jun 27, 2021
1 parent 573f696 commit 76bddac
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion video/out/opengl/context_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static bool wayland_egl_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_
{
struct ra_ctx *ctx = sw->ctx;
struct vo_wayland_state *wl = ctx->vo->wl;
bool render = wl->render || wl->opts->disable_vsync;
bool render = !wl->hidden || wl->opts->disable_vsync;
wl->frame_wait = true;

return render ? ra_gl_ctx_start_frame(sw, out_fbo) : false;
Expand Down
2 changes: 1 addition & 1 deletion video/out/vo_wlshm.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static void draw_image(struct vo *vo, struct mp_image *src)
struct priv *p = vo->priv;
struct vo_wayland_state *wl = vo->wl;
struct buffer *buf;
bool render = wl->render || wl->opts->disable_vsync;
bool render = !wl->hidden || wl->opts->disable_vsync;
wl->frame_wait = true;

if (!render)
Expand Down
2 changes: 1 addition & 1 deletion video/out/vulkan/context_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct priv {
static bool wayland_vk_start_frame(struct ra_ctx *ctx)
{
struct vo_wayland_state *wl = ctx->vo->wl;
bool render = wl->render || wl->opts->disable_vsync;
bool render = !wl->hidden || wl->opts->disable_vsync;
wl->frame_wait = true;

return render;
Expand Down
7 changes: 3 additions & 4 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,18 +1964,17 @@ void vo_wayland_wait_frame(struct vo_wayland_state *wl)
if (wl->frame_wait) {
// Only consider consecutive missed callbacks.
if (wl->timeout_count > 1) {
wl->render = false;
wl->hidden = true;
return;
} else {
wl->timeout_count += 1;
wl->render = true;
wl->hidden = false;
return;
}
}

wl->timeout_count = 0;
wl->render = true;
return;
wl->hidden = false;
}

void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)
Expand Down
2 changes: 1 addition & 1 deletion video/out/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct vo_wayland_state {
bool has_keyboard_input;
bool focused;
bool frame_wait;
bool render;
bool hidden;
bool state_change;
bool toplevel_configured;
int display_fd;
Expand Down

0 comments on commit 76bddac

Please sign in to comment.