Skip to content

Commit

Permalink
options: move all wayland specific options to vo_opts
Browse files Browse the repository at this point in the history
Unlike most other platforming backends, wayland has its own specific
sub_options struct. 027ca4f originally
introduced this and some more options were added later, but in
retrospect it's an unneccesary complication. There are already x11,
and windows-specific options within vo_opts. In fact, there actually is
a wayland one in there already as well (wayland-content-type) so it's
split btween two places. The wayland code already has to handle vo_opts
and it is already handles callbacks if needed. There is no advantage to
having a separate wayland-specific sub_options struct which is stuck
with whatever you set at init time.

So solve everything by deleting the old sub_options struct, moving it to
vo_opts and make some minor option naming changes for clarity (i.e.
adding a 'wl_' in front of the name). This simplifies the wayland common
code and also makes it have more functionality since you get runtime
updates for free.
  • Loading branch information
Dudemanguy committed Jul 24, 2024
1 parent bde7cac commit 3c7b6db
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 116 deletions.
20 changes: 14 additions & 6 deletions options/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,16 @@ static const m_option_t mp_vo_opt_list[] = {
{"x11-wid-title", OPT_BOOL(x11_wid_title)},
#endif
#if HAVE_WAYLAND
{"wayland-content-type", OPT_CHOICE(content_type, {"auto", -1}, {"none", 0},
{"wayland-configure-bounds", OPT_CHOICE(wl_configure_bounds,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"wayland-content-type", OPT_CHOICE(wl_content_type, {"auto", -1}, {"none", 0},
{"photo", 1}, {"video", 2}, {"game", 3})},
{"wayland-disable-vsync", OPT_BOOL(wl_disable_vsync)},
{"wayland-edge-pixels-pointer", OPT_INT(wl_edge_pixels_pointer),
M_RANGE(0, INT_MAX)},
{"wayland-edge-pixels-touch", OPT_INT(wl_edge_pixels_touch),
M_RANGE(0, INT_MAX)},
{"wayland-present", OPT_BOOL(wl_present)},
#endif
#if HAVE_WIN32_DESKTOP
// For old MinGW-w64 compatibility
Expand Down Expand Up @@ -250,11 +258,15 @@ const struct m_sub_options vo_sub_opts = {
.border = true,
.title_bar = true,
.appid = "mpv",
.content_type = -1,
.WinID = -1,
.window_scale = 1.0,
.x11_bypass_compositor = 2,
.x11_present = 1,
.wl_configure_bounds = -1,
.wl_content_type = -1,
.wl_edge_pixels_pointer = 16,
.wl_edge_pixels_touch = 32,
.wl_present = true,
.mmcss_profile = "Playback",
.ontop_level = -1,
.timing_offset = 0.050,
Expand Down Expand Up @@ -928,10 +940,6 @@ static const m_option_t mp_opts[] = {
{"", OPT_SUBSTRUCT(drm_opts, drm_conf)},
#endif

#if HAVE_WAYLAND
{"", OPT_SUBSTRUCT(wayland_opts, wayland_conf)},
#endif

#if HAVE_GL_WIN32
{"", OPT_SUBSTRUCT(wingl_opts, wingl_conf)},
#endif
Expand Down
9 changes: 7 additions & 2 deletions options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ typedef struct mp_vo_opts {
char *fsscreen_name;
char *winname;
char *appid;
int content_type;
int x11_netwm;
int x11_bypass_compositor;
int x11_present;
bool x11_wid_title;
bool cursor_passthrough;
bool native_keyrepeat;

int wl_configure_bounds;
int wl_content_type;
bool wl_disable_vsync;
int wl_edge_pixels_pointer;
int wl_edge_pixels_touch;
bool wl_present;

float panscan;
float zoom;
float pan_x, pan_y;
Expand Down Expand Up @@ -381,7 +387,6 @@ typedef struct MPOpts {
struct d3d11va_opts *d3d11va_opts;
struct macos_opts *macos_opts;
struct drm_opts *drm_opts;
struct wayland_opts *wayland_opts;
struct wingl_opts *wingl_opts;
struct cuda_opts *cuda_opts;
struct dvd_opts *dvd_opts;
Expand Down
2 changes: 1 addition & 1 deletion video/out/opengl/context_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static void wayland_egl_swap_buffers(struct ra_ctx *ctx)

eglSwapBuffers(p->egl_display, p->egl_surface);

if (!wl->opts->disable_vsync)
if (!wl->opts->wl_disable_vsync)
vo_wayland_wait_frame(wl);

if (wl->use_present)
Expand Down
8 changes: 4 additions & 4 deletions video/out/vo_dmabuf_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ static void resize(struct vo *vo)

struct mp_rect src;
struct mp_rect dst;
struct mp_vo_opts *vo_opts = wl->vo_opts;
struct mp_vo_opts *opts = wl->opts;

const int width = mp_rect_w(wl->geometry);
const int height = mp_rect_h(wl->geometry);
Expand All @@ -529,8 +529,8 @@ static void resize(struct vo *vo)
lround(window_h / wl->scaling_factor));

//now we restore pan for video viewport calculation
vo->opts->pan_x = vo_opts->pan_x;
vo->opts->pan_y = vo_opts->pan_y;
vo->opts->pan_x = opts->pan_x;
vo->opts->pan_y = opts->pan_y;
vo_get_src_dst_rects(vo, &src, &dst, &p->screen_osd_res);
wp_viewport_set_destination(wl->video_viewport, lround(mp_rect_w(dst) / wl->scaling_factor),
lround(mp_rect_h(dst) / wl->scaling_factor));
Expand Down Expand Up @@ -643,7 +643,7 @@ static void flip_page(struct vo *vo)
wl_surface_commit(wl->osd_surface);
wl_surface_commit(wl->surface);

if (!wl->opts->disable_vsync)
if (!wl->opts->wl_disable_vsync)
vo_wayland_wait_frame(wl);

if (wl->use_present)
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 @@ -299,7 +299,7 @@ static void flip_page(struct vo *vo)
vo->dheight);
wl_surface_commit(wl->surface);

if (!wl->opts->disable_vsync)
if (!wl->opts->wl_disable_vsync)
vo_wayland_wait_frame(wl);

if (wl->use_present)
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 @@ -36,7 +36,7 @@ static void wayland_vk_swap_buffers(struct ra_ctx *ctx)
{
struct vo_wayland_state *wl = ctx->vo->wl;

if (!wl->opts->disable_vsync)
if (!wl->opts->wl_disable_vsync)
vo_wayland_wait_frame(wl);

if (wl->use_present)
Expand Down
Loading

0 comments on commit 3c7b6db

Please sign in to comment.