From 4e4252f9169edc00c747ffc66fe0b627bbca7ba7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 29 Nov 2019 12:50:50 +0100 Subject: x11: use new option stuff to implement fullscreen - remove VOCTRL_FULLSCREEN and VOCTRL_GET_FULLSCREEN - have your own m_config_cache for the fullscreen option (vo->opts_cache cannot be used because you lose per-option change notifications, and it'd be a mess anyway) - use VOCTRL_VO_OPTS_CHANGED to update it (it's used for convenience) - when updating it, check for the fullscreen option (wasn't sure how to do it best; currently, it compares the raw option pointers, but this could be changed) - do not send VO_EVENT_FULLSCREEN_STATE on FS change - instead write the option on FS change (assign in opt. struct + m_config_cache_write_opt) --- video/out/vo.c | 7 +++++-- video/out/vo.h | 12 ++++++++---- video/out/x11_common.c | 18 ++++++++++-------- video/out/x11_common.h | 1 + 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/video/out/vo.c b/video/out/vo.c index e28026cab5..0effc41285 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -228,9 +228,12 @@ static void update_opts(void *p) if (m_config_cache_update(vo->opts_cache)) { read_opts(vo); - // "Legacy" update of video position related options. - if (vo->driver->control) + if (vo->driver->control) { + vo->driver->control(vo, VOCTRL_VO_OPTS_CHANGED, NULL); + // "Legacy" update of video position related options. + // Unlike VOCTRL_VO_OPTS_CHANGED, often not propagated to backends. vo->driver->control(vo, VOCTRL_SET_PANSCAN, NULL); + } } if (vo->gl_opts_cache && m_config_cache_update(vo->gl_opts_cache)) { diff --git a/video/out/vo.h b/video/out/vo.h index a02412a8ea..68d8273937 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -43,7 +43,8 @@ enum { VO_EVENT_AMBIENT_LIGHTING_CHANGED = 1 << 4, // Special mechanism for making resizing with Cocoa react faster VO_EVENT_LIVE_RESIZING = 1 << 5, - // Window fullscreen state changed via external influence. + // Legacy. Use m_config_cache_write_opt() instead to update the fullscreen + // option. VO_EVENT_FULLSCREEN_STATE = 1 << 6, // Special thing for encode mode (vo_driver.initially_blocked). // Part of VO_EVENTS_USER to make vo_is_ready_for_frame() work properly. @@ -67,6 +68,10 @@ enum mp_voctrl { VOCTRL_SET_PANSCAN, VOCTRL_SET_EQUALIZER, + // Trigger by any change to mp_vo_opts. This is for convenience. In theory, + // you could install your own listener. + VOCTRL_VO_OPTS_CHANGED, + /* private to vo_gpu */ VOCTRL_LOAD_HWDEC_API, @@ -80,12 +85,13 @@ enum mp_voctrl { VOCTRL_UNINIT, VOCTRL_RECONFIG, + // Legacy stuff. VOCTRL_FULLSCREEN, VOCTRL_ONTOP, VOCTRL_BORDER, VOCTRL_ALL_WORKSPACES, - VOCTRL_GET_FULLSCREEN, + VOCTRL_GET_WIN_STATE, // int* (VO_WIN_STATE_* flags) VOCTRL_UPDATE_WINDOW_TITLE, // char* VOCTRL_UPDATE_PLAYBACK_STATE, // struct voctrl_playback_state* @@ -102,8 +108,6 @@ enum mp_voctrl { VOCTRL_GET_UNFS_WINDOW_SIZE, // int[2] (w/h) VOCTRL_SET_UNFS_WINDOW_SIZE, // int[2] (w/h) - VOCTRL_GET_WIN_STATE, // int* (VO_WIN_STATE_* flags) - // char *** (NULL terminated array compatible with CONF_TYPE_STRING_LIST) // names for displays the window is on VOCTRL_GET_DISPLAY_NAMES, diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 24c05bb63d..9f44af23cd 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -562,8 +562,9 @@ int vo_x11_init(struct vo *vo) .xrandr_event = -1, .wakeup_pipe = {-1, -1}, .dpi_scale = 1, - .opts = vo->opts, + .opts_cache = m_config_cache_alloc(x11, vo->global, &vo_sub_opts), }; + x11->opts = x11->opts_cache->opts; vo->x11 = x11; sem_init(&x11->screensaver_sem, 0, 0); @@ -1040,7 +1041,7 @@ static void vo_x11_check_net_wm_state_fullscreen_change(struct vo *vo) { x11->opts->fullscreen = is_fullscreen; x11->fs = is_fullscreen; - x11->pending_vo_events |= VO_EVENT_FULLSCREEN_STATE; + m_config_cache_write_opt(x11->opts_cache, &x11->opts->fullscreen); if (!is_fullscreen && (x11->pos_changed_during_fs || x11->size_changed_during_fs)) @@ -1214,7 +1215,6 @@ void vo_x11_check_events(struct vo *vo) x11->pseudo_mapped = true; } } else if (Event.xproperty.atom == XA(x11, _NET_WM_STATE)) { - x11->pending_vo_events |= VO_EVENT_WIN_STATE; vo_x11_check_net_wm_state_fullscreen_change(vo); } else if (Event.xproperty.atom == x11->icc_profile_property) { x11->pending_vo_events |= VO_EVENT_ICC_PROFILE_CHANGED; @@ -1820,12 +1820,14 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) *events |= x11->pending_vo_events; x11->pending_vo_events = 0; return VO_TRUE; - case VOCTRL_FULLSCREEN: - vo_x11_fullscreen(vo); - return VO_TRUE; - case VOCTRL_GET_FULLSCREEN: - *(int *)arg = x11->fs; + case VOCTRL_VO_OPTS_CHANGED: { + void *opt; + while (m_config_cache_get_next_changed(x11->opts_cache, &opt)) { + if (opt == &opts->fullscreen) + vo_x11_fullscreen(vo); + } return VO_TRUE; + } case VOCTRL_ONTOP: vo_x11_setlayer(vo, opts->ontop); return VO_TRUE; diff --git a/video/out/x11_common.h b/video/out/x11_common.h index 0ae2195f05..fffc5be294 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -50,6 +50,7 @@ struct xrandr_display { struct vo_x11_state { struct mp_log *log; struct input_ctx *input_ctx; + struct m_config_cache *opts_cache; struct mp_vo_opts *opts; Display *display; int event_fd; -- cgit v1.2.3