summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2019-12-11 20:40:33 +0200
committerJan Ekström <jeebjp@gmail.com>2019-12-18 00:02:49 +0200
commit82003047687d39523f3801b8187e084ecb539751 (patch)
treefbccd02db93d799fb701b92bb724c61d0f586280
parent0bf0efd6d37d02b2ec7f5fecd5b662d60fc64acf (diff)
downloadmpv-82003047687d39523f3801b8187e084ecb539751.tar.bz2
mpv-82003047687d39523f3801b8187e084ecb539751.tar.xz
video/w32_common: switch full screening to options cache
* Instead of following VOCTRL_FULLSCREEN, check for option changes. * Instead of signaling VO_EVENT_FULLSCREEN_STATE, update the cached option structure and have it propagated to the origin. Additionally, gets rid of all the straight usage of the VO options structure. Done in a similar style to the Wayland common file, where in case of reading the value, the "payload" from cache is utilized.
-rw-r--r--video/out/w32_common.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c
index 4436bf030e..7f93cb67b1 100644
--- a/video/out/w32_common.c
+++ b/video/out/w32_common.c
@@ -26,6 +26,7 @@
#include <shobjidl.h>
#include <avrt.h>
+#include "options/m_config.h"
#include "options/options.h"
#include "input/keycodes.h"
#include "input/input.h"
@@ -74,6 +75,7 @@ struct vo_w32_state {
struct mp_log *log;
struct vo *vo;
struct mp_vo_opts *opts;
+ struct m_config_cache *opts_cache;
struct input_ctx *input_ctx;
pthread_t thread;
@@ -839,7 +841,9 @@ static bool update_fullscreen_state(struct vo_w32_state *w32)
}
bool toggle_fs = w32->current_fs != new_fs;
- w32->current_fs = new_fs;
+ w32->opts->fullscreen = w32->current_fs = new_fs;
+ m_config_cache_write_opt(w32->opts_cache,
+ &w32->opts->fullscreen);
if (toggle_fs) {
if (w32->current_fs) {
@@ -1047,7 +1051,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
if (IsMaximized(w32->window) && w32->current_fs) {
w32->toggle_fs = true;
reinit_window_state(w32);
- signal_events(w32, VO_EVENT_FULLSCREEN_STATE);
+
return 0;
}
break;
@@ -1482,10 +1486,11 @@ int vo_w32_init(struct vo *vo)
*w32 = (struct vo_w32_state){
.log = mp_log_new(w32, vo->log, "win32"),
.vo = vo,
- .opts = vo->opts,
+ .opts_cache = m_config_cache_alloc(w32, vo->global, &vo_sub_opts),
.input_ctx = vo->input_ctx,
.dispatch = mp_dispatch_create(w32),
};
+ w32->opts = w32->opts_cache->opts;
vo->w32 = w32;
if (pthread_create(&w32->thread, NULL, gui_thread, w32))
@@ -1560,10 +1565,21 @@ static char **get_disp_names(struct vo_w32_state *w32)
static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
{
switch (request) {
- case VOCTRL_FULLSCREEN:
- if (w32->opts->fullscreen != w32->current_fs)
- reinit_window_state(w32);
+ case VOCTRL_VO_OPTS_CHANGED: {
+ void *changed_option;
+
+ while (m_config_cache_get_next_changed(w32->opts_cache,
+ &changed_option))
+ {
+ struct mp_vo_opts *vo_opts = w32->opts_cache->opts;
+
+ if (changed_option == &vo_opts->fullscreen) {
+ reinit_window_state(w32);
+ }
+ }
+
return VO_TRUE;
+ }
case VOCTRL_ONTOP:
update_window_state(w32);
return VO_TRUE;
@@ -1571,9 +1587,6 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
update_window_style(w32);
update_window_state(w32);
return VO_TRUE;
- case VOCTRL_GET_FULLSCREEN:
- *(bool *)arg = w32->current_fs;
- return VO_TRUE;
case VOCTRL_GET_UNFS_WINDOW_SIZE: {
int *s = arg;