From 7686cd7f043ef5b42ade64db21ec01c8c8d6281e Mon Sep 17 00:00:00 2001 From: Alexander Preisinger Date: Mon, 4 Mar 2013 17:40:21 +0100 Subject: vo: remove and cleanup globals Removes almost every global variabel in vo.h and puts them in a special struct in MPOpts for video output related options. Also we completly remove the options/globals pts and refresh rate because they were unused. --- video/decode/vd.c | 20 +++--- video/out/aspect.c | 18 ++--- video/out/cocoa_common.m | 51 +++++++------- video/out/vo.c | 40 ++++------- video/out/vo.h | 27 ++------ video/out/vo_caca.c | 4 +- video/out/vo_corevideo.m | 4 +- video/out/vo_opengl.c | 2 +- video/out/vo_opengl_old.c | 8 +-- video/out/vo_sdl.c | 28 ++++---- video/out/vo_vdpau.c | 5 +- video/out/vo_x11.c | 10 +-- video/out/vo_xv.c | 8 +-- video/out/w32_common.c | 91 ++++++++++++------------ video/out/wayland_common.c | 26 ++++--- video/out/x11_common.c | 168 +++++++++++++++++++++++---------------------- 16 files changed, 243 insertions(+), 267 deletions(-) (limited to 'video') diff --git a/video/decode/vd.c b/video/decode/vd.c index b43570f0ad..0ca685e2bb 100644 --- a/video/decode/vd.c +++ b/video/decode/vd.c @@ -169,16 +169,16 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int out_fmt) set_video_colorspace(sh); - if (opts->vo_gamma_gamma != 1000) - set_video_colors(sh, "gamma", opts->vo_gamma_gamma); - if (opts->vo_gamma_brightness != 1000) - set_video_colors(sh, "brightness", opts->vo_gamma_brightness); - if (opts->vo_gamma_contrast != 1000) - set_video_colors(sh, "contrast", opts->vo_gamma_contrast); - if (opts->vo_gamma_saturation != 1000) - set_video_colors(sh, "saturation", opts->vo_gamma_saturation); - if (opts->vo_gamma_hue != 1000) - set_video_colors(sh, "hue", opts->vo_gamma_hue); + if (opts->gamma_gamma != 1000) + set_video_colors(sh, "gamma", opts->gamma_gamma); + if (opts->gamma_brightness != 1000) + set_video_colors(sh, "brightness", opts->gamma_brightness); + if (opts->gamma_contrast != 1000) + set_video_colors(sh, "contrast", opts->gamma_contrast); + if (opts->gamma_saturation != 1000) + set_video_colors(sh, "saturation", opts->gamma_saturation); + if (opts->gamma_hue != 1000) + set_video_colors(sh, "hue", opts->gamma_hue); return 1; } diff --git a/video/out/aspect.c b/video/out/aspect.c index 05e40a73e9..e7ca37a82d 100644 --- a/video/out/aspect.c +++ b/video/out/aspect.c @@ -45,10 +45,10 @@ void aspect_save_screenres(struct vo *vo, int scrw, int scrh) scrw = (scrh * 4 + 2) / 3; vo->aspdat.scrw = scrw; vo->aspdat.scrh = scrh; - if (opts->force_monitor_aspect) - vo->monitor_par = opts->force_monitor_aspect * scrh / scrw; + if (opts->vo.force_monitor_aspect) + vo->monitor_par = opts->vo.force_monitor_aspect * scrh / scrw; else - vo->monitor_par = 1.0 / opts->monitor_pixel_aspect; + vo->monitor_par = 1.0 / opts->vo.monitor_pixel_aspect; } /* aspect is called with the source resolution and the @@ -88,7 +88,7 @@ static void get_max_dims(struct vo *vo, int *w, int *h, int zoom) struct aspect_data *aspdat = &vo->aspdat; *w = zoom ? aspdat->scrw : aspdat->prew; *h = zoom ? aspdat->scrh : aspdat->preh; - if (zoom && WinID >= 0) + if (zoom && vo->opts->vo.WinID >= 0) zoom = A_WINZOOM; if (zoom == A_WINZOOM) { *w = vo->dwidth; @@ -101,7 +101,7 @@ void aspect(struct vo *vo, int *srcw, int *srch, int zoom) int fitw; int fith; get_max_dims(vo, &fitw, &fith, zoom); - if (!zoom && vo->opts->vo_geometry.wh_valid) { + if (!zoom && vo->opts->vo.geometry.wh_valid) { mp_msg(MSGT_VO, MSGL_DBG2, "aspect(0) no aspect forced!\n"); return; // the user doesn't want to fix aspect } @@ -123,16 +123,16 @@ static void panscan_calc_internal(struct vo *vo, int zoom) get_max_dims(vo, &max_w, &max_h, zoom); struct MPOpts *opts = vo->opts; - if (opts->vo_panscanrange > 0) { + if (opts->vo.panscanrange > 0) { aspect(vo, &fwidth, &fheight, zoom); vo_panscan_area = max_h - fheight; if (!vo_panscan_area) vo_panscan_area = max_w - fwidth; - vo_panscan_area *= opts->vo_panscanrange; + vo_panscan_area *= opts->vo.panscanrange; } else - vo_panscan_area = -opts->vo_panscanrange * max_h; + vo_panscan_area = -opts->vo.panscanrange * max_h; - vo->panscan_amount = vo_fs || zoom == A_WINZOOM ? vo_panscan : 0; + vo->panscan_amount = opts->vo.fs || zoom == A_WINZOOM ? opts->vo.panscan : 0; vo->panscan_x = vo_panscan_area * vo->panscan_amount * vo->aspdat.asp; vo->panscan_y = vo_panscan_area * vo->panscan_amount; } diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index add42de953..b376e392c0 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -122,7 +122,7 @@ struct vo_cocoa_state { int display_cursor; int cursor_timer; - int cursor_autohide_delay; + int vo.cursor_autohide_delay; bool did_resize; bool out_fs_resize; @@ -150,7 +150,7 @@ static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo) .windowed_frame = {{0,0},{0,0}}, .out_fs_resize = NO, .display_cursor = 1, - .cursor_autohide_delay = vo->opts->cursor_autohide_delay, + .vo.cursor_autohide_delay = vo->opts->vo.cursor_autohide_delay, .power_mgmt_assertion = kIOPMNullAssertionID, .accumulated_scroll = 0, }; @@ -281,10 +281,10 @@ static void update_screen_info(struct vo *vo) struct MPOpts *opts = vo->opts; NSScreen *ws, *fss; - get_screen_handle(opts->vo_screen_id, s->window, &ws); + get_screen_handle(opts->vo.screen_id, s->window, &ws); s->screen_frame = [ws frame]; - get_screen_handle(opts->vo_fsscreen_id, s->window, &fss); + get_screen_handle(opts->vo.fsscreen_id, s->window, &fss); s->fsscreen_frame = [fss frame]; } @@ -296,10 +296,10 @@ void vo_cocoa_update_xinerama_info(struct vo *vo) update_screen_info(vo); aspect_save_screenres(vo, s->screen_frame.size.width, s->screen_frame.size.height); - opts->vo_screenwidth = s->screen_frame.size.width; - opts->vo_screenheight = s->screen_frame.size.height; - xinerama_x = s->screen_frame.origin.x; - xinerama_y = s->screen_frame.origin.y; + opts->vo.screenwidth = s->screen_frame.size.width; + opts->vo.screenheight = s->screen_frame.size.height; + vo->xinerama_x = s->screen_frame.origin.x; + vo->xinerama_y = s->screen_frame.origin.y; } int vo_cocoa_change_attributes(struct vo *vo) @@ -339,8 +339,8 @@ static void vo_set_level(struct vo *vo, int ontop) void vo_cocoa_ontop(struct vo *vo) { struct MPOpts *opts = vo->opts; - opts->vo_ontop = !opts->vo_ontop; - vo_set_level(vo, opts->vo_ontop); + opts->vo.ontop = !opts->vo.ontop; + vo_set_level(vo, opts->vo.ontop); } static void update_state_sizes(struct vo_cocoa_state *s, @@ -355,7 +355,7 @@ static int create_window(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags, int gl3profile) { struct vo_cocoa_state *s = vo->cocoa; - const NSRect window_rect = NSMakeRect(xinerama_x, xinerama_y, + const NSRect window_rect = NSMakeRect(vo->xinerama_x, vo->xinerama_y, d_width, d_height); const NSRect glview_rect = NSMakeRect(0, 0, 100, 100); @@ -418,7 +418,7 @@ static void update_window(struct vo *vo) if (s->current_video_size.width != s->previous_video_size.width || s->current_video_size.height != s->previous_video_size.height) { - if (vo_fs) { + if (vo->opts->vo.fs) { // we will resize as soon as we get out of fullscreen s->out_fs_resize = YES; } else { @@ -463,7 +463,7 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t d_width, if (flags & VOFLAG_FULLSCREEN) vo_cocoa_fullscreen(vo); - vo_set_level(vo, opts->vo_ontop); + vo_set_level(vo, opts->vo.ontop); [s->window setContentSize:s->current_video_size]; [s->window setContentAspectRatio:s->current_video_size]; @@ -491,12 +491,12 @@ static void vo_cocoa_display_cursor(struct vo *vo, int requested_state) { struct vo_cocoa_state *s = vo->cocoa; if (requested_state) { - if (!vo_fs || s->cursor_autohide_delay > -2) { + if (!vo->opts->vo.fs || s->vo.cursor_autohide_delay > -2) { s->display_cursor = requested_state; CGDisplayShowCursor(kCGDirectMainDisplay); } } else { - if (s->cursor_autohide_delay != -1) { + if (s->vo.cursor_autohide_delay != -1) { s->display_cursor = requested_state; CGDisplayHideCursor(kCGDirectMainDisplay); } @@ -510,8 +510,8 @@ int vo_cocoa_check_events(struct vo *vo) int ms_time = (int) ([[NSProcessInfo processInfo] systemUptime] * 1000); // automatically hide mouse cursor - if (vo_fs && s->display_cursor && - (ms_time - s->cursor_timer >= s->cursor_autohide_delay)) { + if (vo->opts->vo.fs && s->display_cursor && + (ms_time - s->cursor_timer >= s->vo.cursor_autohide_delay)) { vo_cocoa_display_cursor(vo, 0); s->cursor_timer = ms_time; } @@ -648,7 +648,8 @@ void create_menu() - (void)fullscreen { struct vo_cocoa_state *s = _vo->cocoa; - if (!vo_fs) { + struct MPOpts *opts = _vo->opts; + if (!opts->vo.fs) { update_screen_info(_vo); if (current_screen_has_dock_or_menubar(_vo)) [NSApp setPresentationOptions:NSApplicationPresentationHideDock| @@ -657,7 +658,7 @@ void create_menu() [self setHasShadow:NO]; [self setStyleMask:s->fullscreen_mask]; [self setFrame:s->fsscreen_frame display:YES animate:NO]; - vo_fs = VO_TRUE; + opts->vo.fs = true; vo_cocoa_display_cursor(_vo, 0); [self setMovableByWindowBackground: NO]; } else { @@ -671,7 +672,7 @@ void create_menu() s->out_fs_resize = NO; } [self setContentAspectRatio:s->current_video_size]; - vo_fs = VO_FALSE; + opts->vo.fs = false; vo_cocoa_display_cursor(_vo, 1); [self setMovableByWindowBackground: YES]; } @@ -695,7 +696,7 @@ void create_menu() { // this is only valid as a starting value. it will be rewritten in the // -fullscreen method. - return !vo_fs; + return !_vo->opts->o_fs; } - (void)handleQuitEvent:(NSAppleEventDescriptor*)e @@ -730,7 +731,7 @@ void create_menu() - (void)mouseMoved: (NSEvent *) theEvent { - if (vo_fs) + if (_vo->opts->vo.fs) vo_cocoa_display_cursor(_vo, 1); } @@ -851,7 +852,7 @@ void create_menu() - (void)applicationWillBecomeActive:(NSNotification *)aNotification { - if (vo_fs && current_screen_has_dock_or_menubar(_vo)) { + if (_vo->opts->vo.fs && current_screen_has_dock_or_menubar(_vo)) { struct vo_cocoa_state *s = _vo->cocoa; [self setLevel:s->window_level]; [NSApp setPresentationOptions:NSApplicationPresentationHideDock| @@ -861,7 +862,7 @@ void create_menu() - (void)applicationWillResignActive:(NSNotification *)aNotification { - if (vo_fs) { + if (_vo->opts->vo.fs) { [self setLevel:NSNormalWindowLevel]; [NSApp setPresentationOptions:NSApplicationPresentationDefault]; } @@ -888,7 +889,7 @@ void create_menu() - (void)mulSize:(float)multiplier { - if (!vo_fs) { + if (!_vo->opts->vo.fs) { NSSize size = { .width = _vo->aspdat.prew * multiplier, .height = _vo->aspdat.preh * multiplier diff --git a/video/out/vo.c b/video/out/vo.c index 52ed04d3b5..5841d6fd52 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -42,25 +42,8 @@ #include "video/vfcap.h" #include "sub/sub.h" -int xinerama_x; -int xinerama_y; - -int vo_nomouse_input = 0; -int vo_vsync = 1; -int vo_fs = 0; -int vo_fsmode = 0; -float vo_panscan = 0.0f; -int vo_refresh_rate=0; -int vo_keepaspect=1; -int vo_border=1; -int64_t WinID = -1; - -int vo_pts=0; // for hw decoding float vo_fps=0; -int vo_colorkey = 0x0000ff00; // default colorkey is green - // (0xff000000 means that colorkey has been disabled) - // // Externally visible list of all vo drivers // @@ -407,22 +390,22 @@ static void determine_window_geometry(struct vo *vo, int d_w, int d_h) { struct MPOpts *opts = vo->opts; - int scr_w = opts->vo_screenwidth; - int scr_h = opts->vo_screenheight; + int scr_w = opts->vo.screenwidth; + int scr_h = opts->vo.screenheight; // This is only for applying monitor pixel aspect aspect(vo, &d_w, &d_h, A_NOZOOM); - apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo_autofit, true); - apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo_autofit_larger, false); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo.autofit, true); + apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->vo.autofit_larger, false); - vo->dx = (int)(opts->vo_screenwidth - d_w) / 2; - vo->dy = (int)(opts->vo_screenheight - d_h) / 2; + vo->dx = (int)(opts->vo.screenwidth - d_w) / 2; + vo->dy = (int)(opts->vo.screenheight - d_h) / 2; m_geometry_apply(&vo->dx, &vo->dy, &d_w, &d_h, scr_w, scr_h, - &opts->vo_geometry); + &opts->vo.geometry); - vo->dx += xinerama_x; - vo->dy += xinerama_y; + vo->dx += vo->xinerama_x; + vo->dy += vo->xinerama_y; vo->dwidth = d_w; vo->dheight = d_h; } @@ -536,7 +519,7 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, .display_par = vo->monitor_par, .video_par = vo->aspdat.par, }; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { int scaled_width = 0, scaled_height = 0; aspect(vo, &scaled_width, &scaled_height, A_WINZOOM); panscan_calc_windowed(vo); @@ -581,8 +564,9 @@ const char *vo_get_window_title(struct vo *vo) void vo_mouse_movement(struct vo *vo, int posx, int posy) { char cmd_str[40]; - if (!enable_mouse_movements) + if (!vo->opts->vo.enable_mouse_movements) return; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(bstr0(cmd_str), "")); } + diff --git a/video/out/vo.h b/video/out/vo.h index ca252337b1..ed3be652bd 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -28,6 +28,7 @@ #include "video/img_format.h" #include "core/mp_common.h" +#include "core/options.h" #define VO_EVENT_EXPOSE 1 #define VO_EVENT_RESIZE 2 @@ -260,6 +261,9 @@ struct vo { int dwidth; int dheight; + int xinerama_x; + int xinerama_y; + int panscan_x; int panscan_y; float panscan_amount; @@ -306,27 +310,8 @@ const char *vo_get_window_title(struct vo *vo); // NULL terminated array of all drivers extern const struct vo_driver *video_out_drivers[]; -extern int xinerama_x; -extern int xinerama_y; - -extern int vo_vsync; -extern int vo_fs; -extern int vo_fsmode; -extern float vo_panscan; -extern int vo_refresh_rate; -extern int vo_keepaspect; -extern int vo_border; - -extern int vo_nomouse_input; -extern int enable_mouse_movements; - -extern int vo_pts; extern float vo_fps; -extern int vo_colorkey; - -extern int64_t WinID; - struct mp_keymap { int from; int to; @@ -339,9 +324,9 @@ struct mp_osd_res; void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, struct mp_rect *out_dst, struct mp_osd_res *out_osd); -static inline int aspect_scaling(void) +static inline int aspect_scaling(struct vo *vo) { - return vo_keepaspect || vo_fs; + return vo->opts->vo.keepaspect || vo->opts->vo.fs; } #endif /* MPLAYER_VIDEO_OUT_H */ diff --git a/video/out/vo_caca.c b/video/out/vo_caca.c index 3a07f57152..885a6c6e9a 100644 --- a/video/out/vo_caca.c +++ b/video/out/vo_caca.c @@ -175,12 +175,12 @@ static void check_events(struct vo *vo) vo_mouse_movement(vo, cev.data.mouse.x, cev.data.mouse.y); break; case CACA_EVENT_MOUSE_PRESS: - if (!vo_nomouse_input) + if (!vo->opts->vo.nomouse_input) mplayer_put_key(vo->key_fifo, (MP_MOUSE_BTN0 + cev.data.mouse.button - 1) | MP_KEY_STATE_DOWN); break; case CACA_EVENT_MOUSE_RELEASE: - if (!vo_nomouse_input) + if (!vo->opts->vo.nomouse_input) mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN0 + cev.data.mouse.button - 1); break; diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.m index a1b5036dbf..08dd8e8a25 100644 --- a/video/out/vo_corevideo.m +++ b/video/out/vo_corevideo.m @@ -70,7 +70,7 @@ static void resize(struct vo *vo, int width, int height) gl->MatrixMode(GL_PROJECTION); gl->LoadIdentity(); p->ass_border_x = p->ass_border_y = 0; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { int new_w, new_h; GLdouble scale_x, scale_y; @@ -307,7 +307,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) .video_par = vo->aspdat.par, }; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { res.ml = res.mr = p->ass_border_x; res.mt = res.mb = p->ass_border_y; } diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 98406ecad4..6170852132 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -2085,7 +2085,7 @@ static int preinit(struct vo *vo, const char *arg) .colorspace = MP_CSP_DETAILS_DEFAULTS, .use_npot = 1, .use_pbo = hq, - .swap_interval = vo_vsync, + .swap_interval = vo->opts->vo.vsync, .dither_depth = hq ? 0 : -1, .fbo_format = hq ? GL_RGB16 : GL_RGB, .use_scale_sep = 1, diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index 30a0467d46..d41a547847 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -1361,7 +1361,7 @@ static void resize(struct vo *vo, int x, int y) gl->MatrixMode(GL_PROJECTION); gl->LoadIdentity(); p->ass_border_x = p->ass_border_y = 0; - if (aspect_scaling()) { + if (aspect_scaling(vo)) { int new_w, new_h; GLdouble scale_x, scale_y; aspect(vo, &new_w, &new_h, A_WINZOOM); @@ -1490,7 +1490,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) if (p->scaled_osd) { res.w = p->image_width; res.h = p->image_height; - } else if (aspect_scaling()) { + } else if (aspect_scaling(vo)) { res.ml = res.mr = p->ass_border_x; res.mt = res.mb = p->ass_border_y; } @@ -1821,7 +1821,7 @@ static void flip_page(struct vo *vo) if (p->use_glFinish) gl->Finish(); p->glctx->swapGlBuffers(p->glctx); - if (aspect_scaling()) + if (aspect_scaling(vo)) gl->Clear(GL_COLOR_BUFFER_BIT); } @@ -2113,7 +2113,7 @@ static int preinit(struct vo *vo, const char *arg) .use_rectangle = -1, .ati_hack = -1, .force_pbo = -1, - .swap_interval = vo_vsync, + .swap_interval = vo->opts->vo.vsync, .custom_prog = NULL, .custom_tex = NULL, .custom_tlin = 1, diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index 5f1e4317ed..b10a237b19 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -271,7 +271,7 @@ static bool try_create_renderer(struct vo *vo, int i, const char *driver, if (!is_good_renderer(&ri, driver, vc->allow_sw, NULL)) return false; - bool xy_valid = vo->opts->vo_geometry.xy_valid; + bool xy_valid = vo->opts->vo.geometry.xy_valid; // then actually try vc->window = SDL_CreateWindow("MPV", @@ -387,7 +387,7 @@ static void set_fullscreen(struct vo *vo, int fs) // toggling fullscreen might recreate the window, so better guard for this SDL_DisableScreenSaver(); - vo_fs = fs; + vo->opts->vo.fs = fs; force_resize(vo); } @@ -473,18 +473,18 @@ static void check_events(struct vo *vo) struct MPOpts *opts = vo->opts; SDL_Event ev; - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { if (!vc->mouse_hidden && - (GetTimerMS() - vc->mouse_timer >= opts->cursor_autohide_delay)) { + (GetTimerMS() - vc->mouse_timer >= opts->vo.cursor_autohide_delay)) { SDL_ShowCursor(0); vc->mouse_hidden = 1; } - } else if (opts->cursor_autohide_delay == -1) { + } else if (opts->vo.cursor_autohide_delay == -1) { if (vc->mouse_hidden) { SDL_ShowCursor(1); vc->mouse_hidden = 0; } - } else if (opts->cursor_autohide_delay == -2) { + } else if (opts->vo.cursor_autohide_delay == -2) { if (!vc->mouse_hidden) { SDL_ShowCursor(0); vc->mouse_hidden = 1; @@ -553,7 +553,7 @@ static void check_events(struct vo *vo) break; } case SDL_MOUSEMOTION: - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { SDL_ShowCursor(1); vc->mouse_hidden = 0; vc->mouse_timer = GetTimerMS(); @@ -561,7 +561,7 @@ static void check_events(struct vo *vo) vo_mouse_movement(vo, ev.motion.x, ev.motion.y); break; case SDL_MOUSEBUTTONDOWN: - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { SDL_ShowCursor(1); vc->mouse_hidden = 0; vc->mouse_timer = GetTimerMS(); @@ -570,7 +570,7 @@ static void check_events(struct vo *vo) (MP_MOUSE_BTN0 + ev.button.button - 1) | MP_KEY_STATE_DOWN); break; case SDL_MOUSEBUTTONUP: - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay >= 0) { SDL_ShowCursor(1); vc->mouse_hidden = 0; vc->mouse_timer = GetTimerMS(); @@ -771,7 +771,7 @@ static int preinit(struct vo *vo, const char *arg) SDL_HINT_DEFAULT); // predefine MPV options (SDL env vars shall be overridden) - if (vo_vsync) + if (vo->opts->vo.vsync) SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, "1", SDL_HINT_OVERRIDE); else @@ -922,9 +922,9 @@ static void update_screeninfo(struct vo *vo) return; } struct MPOpts *opts = vo->opts; - opts->vo_screenwidth = mode.w; - opts->vo_screenheight = mode.h; - aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight); + opts->vo.screenwidth = mode.w; + opts->vo.screenheight = mode.h; + aspect_save_screenres(vo, opts->vo.screenwidth, opts->vo.screenheight); } static struct mp_image *get_screenshot(struct vo *vo) @@ -981,7 +981,7 @@ static int control(struct vo *vo, uint32_t request, void *data) { switch (request) { case VOCTRL_FULLSCREEN: - set_fullscreen(vo, !vo_fs); + set_fullscreen(vo, !vo->opts->vo.fs); return 1; case VOCTRL_REDRAW_FRAME: draw_image(vo, NULL); diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 6b35176bfb..02163f70bf 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -377,7 +377,10 @@ static void resize(struct vo *vo) vc->src_rect_vid.y0 = vc->flip ? src_rect.y1 : src_rect.y0; vc->src_rect_vid.y1 = vc->flip ? src_rect.y0 : src_rect.y1; - int flip_offset_ms = vo_fs ? vc->flip_offset_fs : vc->flip_offset_window; + int flip_offset_ms = vo->opts->vo.fs ? + vc->flip_offset_fs : + vc->flip_offset_window; + vo->flip_queue_offset = flip_offset_ms / 1000.; if (vc->output_surface_width < vo->dwidth diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 34c23523ef..9e5f4dc64d 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -49,6 +49,7 @@ #define MODE_BGR 0x2 #include "core/mp_msg.h" +#include "core/options.h" #include "osdep/timer.h" extern int sws_flags; @@ -348,7 +349,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, } if (!XMatchVisualInfo(vo->x11->display, vo->x11->screen, p->depth, DirectColor, &p->vinfo) - || (WinID > 0 + || (vo->opts->vo.WinID > 0 && p->vinfo.visualid != XVisualIDFromVisual(p->attribs.visual))) { XMatchVisualInfo(vo->x11->display, vo->x11->screen, p->depth, TrueColor, @@ -365,7 +366,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, vo_x11_config_vo_window(vo, &p->vinfo, vo->dx, vo->dy, vo->dwidth, vo->dheight, flags, "x11"); - if (WinID > 0) { + if (vo->opts->vo.WinID > 0) { unsigned depth, dummy_uint; int dummy_int; Window dummy_win; @@ -444,7 +445,7 @@ static void Display_Image(struct priv *p, XImage *myximage, uint8_t *ImageData) p->old_vo_dheight != vo->dheight) && p->zoomFlag) return; - if (WinID == 0) { + if (vo->opts->vo.WinID == 0) { x = vo->dx; y = vo->dy; } @@ -538,6 +539,7 @@ static void flip_page(struct vo *vo) static void draw_image(struct vo *vo, mp_image_t *mpi) { struct priv *p = vo->priv; + struct MPOpts *opts = vo->opts; uint8_t *dst[MP_MAX_PLANES] = {NULL}; int dstStride[MP_MAX_PLANES] = {0}; @@ -553,7 +555,7 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) p->old_vo_dwidth = vo->dwidth; p->old_vo_dheight = vo->dheight; - if (vo_fs) + if (opts->vo.fs) aspect(vo, &newW, &newH, A_ZOOM); if (sws_flags == 0) newW &= (~31); // not needed but, if the user wants the FAST_BILINEAR SCALER, then its needed diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index bc0920c2eb..46079aaf5f 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -317,7 +317,7 @@ static void xv_print_ck_info(struct xvctx *xv) } } -/* NOTE: If vo_colorkey has bits set after the first 3 low order bytes +/* NOTE: If vo.colorkey has bits set after the first 3 low order bytes * we don't draw anything as this means it was forced to off. */ static int xv_init_colorkey(struct vo *vo) { @@ -328,7 +328,7 @@ static int xv_init_colorkey(struct vo *vo) /* check if colorkeying is needed */ xv_atom = xv_intern_atom_if_exists(vo, "XV_COLORKEY"); - if (xv_atom != None && !(vo_colorkey & 0xFF000000)) { + if (xv_atom != None && !(vo->opts->vo.colorkey & 0xFF000000)) { if (ctx->xv_ck_info.source == CK_SRC_CUR) { int colorkey_ret; @@ -342,14 +342,14 @@ static int xv_init_colorkey(struct vo *vo) return 0; // error getting colorkey } } else { - ctx->xv_colorkey = vo_colorkey; + ctx->xv_colorkey = vo->opts->vo.colorkey; /* check if we have to set the colorkey too */ if (ctx->xv_ck_info.source == CK_SRC_SET) { xv_atom = XInternAtom(display, "XV_COLORKEY", False); rez = XvSetPortAttribute(display, ctx->xv_port, xv_atom, - vo_colorkey); + vo->opts->vo.colorkey); if (rez != Success) { mp_msg(MSGT_VO, MSGL_FATAL, "[xv] Couldn't set colorkey!\n"); return 0; // error setting colorkey diff --git a/video/out/w32_common.c b/video/out/w32_common.c index ab467135cc..3c882de625 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -150,7 +150,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, break; } case WM_SIZING: - if (vo_keepaspect && !vo_fs && WinID < 0) { + if (vo_keepaspect && !vo->opts->vo.fs && vo->otps->vo.WinID < 0) { RECT *rc = (RECT*)lParam; // get client area of the windows if it had the rect rc // (subtracting the window borders) @@ -215,11 +215,11 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, break; } case WM_LBUTTONDOWN: - if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) { + if (!vo_nomouse_input && (vo->opts->vo.fs || (wParam & MK_CONTROL))) { mplayer_put_key(vo->key_fifo, MP_MOUSE_BTN0 | mod_state(vo)); break; } - if (!vo_fs) { + if (!vo->opts->vo.fs) { ReleaseCapture(); SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); return 0; @@ -281,7 +281,7 @@ int vo_w32_check_events(struct vo *vo) TranslateMessage(&msg); DispatchMessageW(&msg); } - if (WinID >= 0) { + if (vo->opts->vo.WinID >= 0) { BOOL res; RECT r; POINT p; @@ -295,10 +295,10 @@ int vo_w32_check_events(struct vo *vo) if (p.x != w32->window_x || p.y != w32->window_y) { w32->window_x = p.x; w32->window_y = p.y; } - res = GetClientRect(WIN_ID_TO_HWND(WinID), &r); + res = GetClientRect(WIN_ID_TO_HWND(vo->opts->vo.WinID), &r); if (res && (r.right != vo->dwidth || r.bottom != vo->dheight)) MoveWindow(w32->window, 0, 0, r.right, r.bottom, FALSE); - if (!IsWindow(WIN_ID_TO_HWND(WinID))) + if (!IsWindow(WIN_ID_TO_HWND(vo->otps->vo.WinID))) // Window has probably been closed, e.g. due to program crash mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN); } @@ -311,10 +311,10 @@ static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) struct vo *vo = (void*)p; struct vo_w32_state *w32 = vo->w32; // this defaults to the last screen if specified number does not exist - xinerama_x = r->left; - xinerama_y = r->top; - vo->opts->vo_screenwidth = r->right - r->left; - vo->opts->vo_screenheight = r->bottom - r->top; + vo->xinerama_x = r->left; + vo->xinerama_y = r->top; + vo->opts->vo.screenwidth = r->right - r->left; + vo->opts->vo.screenheight = r->bottom - r->top; if (w32->mon_cnt == w32->mon_id) return FALSE; w32->mon_cnt++; @@ -339,32 +339,32 @@ void w32_update_xinerama_info(struct vo *vo) { struct vo_w32_state *w32 = vo->w32; struct MPOpts *opts = vo->opts; - int screen = vo_fs ? opts->vo_fsscreen_id : opts->vo_screen_id; - xinerama_x = xinerama_y = 0; - if (vo_fs && screen == -2) { + int screen = opts->vo.fs ? opts->vo.fsscreen_id : opts->vo.screen_id; + vo->xinerama_x = vo->xinerama_y = 0; + if (opts->vo.fs && screen == -2) { int tmp; - xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN); - xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN); + vo->xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN); + vo->xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN); tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN); - if (tmp) vo->opts->vo_screenwidth = tmp; + if (tmp) vo->opts->vo.screenwidth = tmp; tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN); - if (tmp) vo->opts->vo_screenheight = tmp; + if (tmp) vo->opts->vo.screenheight = tmp; } else if (screen == -1) { MONITORINFO mi; HMONITOR m = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY); mi.cbSize = sizeof(mi); GetMonitorInfoW(m, &mi); - xinerama_x = mi.rcMonitor.left; - xinerama_y = mi.rcMonitor.top; - vo->opts->vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left; - vo->opts->vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top; + vo->xinerama_x = mi.rcMonitor.left; + vo->xinerama_y = mi.rcMonitor.top; + vo->opts->vo.screenwidth = mi.rcMonitor.right - mi.rcMonitor.left; + vo->opts->vo.screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top; } else if (screen >= 0) { w32->mon_cnt = 0; w32->mon_id = screen; EnumDisplayMonitors(NULL, NULL, mon_enum, (LONG_PTR)vo); } - aspect_save_screenres(vo, vo->opts->vo_screenwidth, - vo->opts->vo_screenheight); + aspect_save_screenres(vo, vo->opts->vo.screenwidth, + vo->opts->vo.screenheight); } static void updateScreenProperties(struct vo *vo) @@ -380,8 +380,8 @@ static void updateScreenProperties(struct vo *vo) return; } - vo->opts->vo_screenwidth = dm.dmPelsWidth; - vo->opts->vo_screenheight = dm.dmPelsHeight; + vo->opts->vo.screenwidth = dm.dmPelsWidth; + vo->opts->vo.screenheight = dm.dmPelsHeight; w32_update_xinerama_info(vo); } @@ -390,7 +390,7 @@ static DWORD update_style(struct vo *vo, DWORD style) const DWORD NO_FRAME = WS_POPUP; const DWORD FRAME = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; style &= ~(NO_FRAME | FRAME); - style |= (vo_border && !vo_fs) ? FRAME : NO_FRAME; + style |= (vo_border && !vo->opts->vo.fs) ? FRAME : NO_FRAME; return style; } @@ -401,30 +401,30 @@ static int reinit_window_state(struct vo *vo) HWND layer = HWND_NOTOPMOST; RECT r; - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) return 1; wchar_t *title = mp_from_utf8(NULL, vo_get_window_title(vo)); SetWindowTextW(w32->window, title); talloc_free(title); - bool toggle_fs = w32->current_fs != vo_fs; - w32->current_fs = vo_fs; + bool toggle_fs = w32->current_fs != vo->opts->vo.fs; + w32->current_fs = vo->opts->vo.fs; DWORD style = update_style(vo, GetWindowLong(w32->window, GWL_STYLE)); - if (vo_fs || vo->opts->vo_ontop) + if (vo->opts->vo.fs || vo->opts->vo.ontop) layer = HWND_TOPMOST; // xxx not sure if this can trigger any unwanted messages (WM_MOVE/WM_SIZE) - if (vo_fs) { + if (vo->opts->vo.fs) { while (ShowCursor(0) >= 0) /**/ ; } else { while (ShowCursor(1) < 0) /**/ ; } updateScreenProperties(vo); - if (vo_fs) { + if (vo->opts->vo.fs) { // Save window position and size when switching to fullscreen. if (toggle_fs) { w32->prev_width = vo->dwidth; @@ -434,10 +434,10 @@ static int reinit_window_state(struct vo *vo) mp_msg(MSGT_VO, MSGL_V, "[vo] save window bounds: %d:%d:%d:%d\n", w32->prev_x, w32->prev_y, w32->prev_width, w32->prev_height); } - vo->dwidth = vo->opts->vo_screenwidth; - vo->dheight = vo->opts->vo_screenheight; - w32->window_x = xinerama_x; - w32->window_y = xinerama_y; + vo->dwidth = vo->opts->vo.screenwidth; + vo->dheight = vo->opts->vo.screenheight; + w32->window_x = vo->xinerama_x; + w32->window_y = vo->xinerama_y; } else { if (toggle_fs) { // Restore window position and size when switching from fullscreen. @@ -519,7 +519,7 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height, w32->o_dheight = height; // the desired size is ignored in wid mode, it always matches the window size. - if (WinID < 0) { + if (vo->opts->vo.WinID < 0) { if (w32->window_bounds_initialized) { // restore vo_dwidth/vo_dheight, which are reset against our will // in vo_config() @@ -544,7 +544,7 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height, } } - vo_fs = flags & VOFLAG_FULLSCREEN; + vo->opts->vo.fs = flags & VOFLAG_FULLSCREEN; return reinit_window_state(vo); } @@ -594,15 +594,16 @@ int vo_w32_init(struct vo *vo) return 0; } - if (WinID >= 0) { + if (vo->opts->vo.WinID >= 0) { RECT r; - GetClientRect(WIN_ID_TO_HWND(WinID), &r); + GetClientRect(WIN_ID_TO_HWND(vo->opts->vo.WinID), &r); vo->dwidth = r.right; vo->dheight = r.bottom; w32->window = CreateWindowExW(WS_EX_NOPARENTNOTIFY, classname, classname, WS_CHILD | WS_VISIBLE, 0, 0, vo->dwidth, vo->dheight, - WIN_ID_TO_HWND(WinID), 0, hInstance, vo); + WIN_ID_TO_HWND(vo->opts->vo.WinID), + 0, hInstance, vo); } else { w32->window = CreateWindowExW(0, classname, classname, @@ -616,7 +617,7 @@ int vo_w32_init(struct vo *vo) return 0; } - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) EnableWindow(w32->window, 0); // we don't have proper event handling @@ -625,7 +626,7 @@ int vo_w32_init(struct vo *vo) updateScreenProperties(vo); mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d\n", - vo->opts->vo_screenwidth, vo->opts->vo_screenheight); + vo->opts->vo.screenwidth, vo->opts->vo.screenheight); return 1; } @@ -642,7 +643,7 @@ int vo_w32_init(struct vo *vo) void vo_w32_fullscreen(struct vo *vo) { - vo_fs = !vo_fs; + vo->opts->vo.fs = !vo->opts->vo.fs; reinit_window_state(vo); } @@ -664,7 +665,7 @@ void vo_w32_border(struct vo *vo) */ void vo_w32_ontop(struct vo *vo) { - vo->opts->vo_ontop = !vo->opts->vo_ontop; + vo->opts->vo.ontop = !vo->opts->vo.ontop; reinit_window_state(vo); } diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 149e304956..319a9abab1 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -770,8 +770,6 @@ static void destroy_display (struct vo_wayland_state *wl) wl_registry_destroy(wl->display->registry); wl_display_flush(wl->display->display); wl_display_disconnect(wl->display->display); - vo_fs = VO_FALSE; - } static void create_window (struct vo_wayland_state *wl) @@ -891,9 +889,9 @@ void vo_wayland_ontop (struct vo *vo) { struct vo_wayland_state *wl = vo->wayland; - vo->opts->vo_ontop = !vo->opts->vo_ontop; + vo->opts->vo.ontop = !vo->opts->vo.ontop; - if (vo_fs) + if (vo->opts->vo.fs) vo_wayland_fullscreen(vo); /* use the already existing code to leave fullscreen mode and go into * toplevel mode */ @@ -920,7 +918,7 @@ void vo_wayland_fullscreen (struct vo *vo) struct wl_output *fs_output = wl->display->fs_output; - if (!vo_fs) { + if (!vo->opts->vo.fs) { wl->window->p_width = wl->window->width; wl->window->p_height = wl->window->height; wl_shell_surface_set_fullscreen(wl->window->shell_surface, @@ -928,7 +926,7 @@ void vo_wayland_fullscreen (struct vo *vo) 0, fs_output); wl->window->type = TYPE_FULLSCREEN; - vo_fs = VO_TRUE; + vo->opts->vo.fs = true; hide_cursor(wl->display); } @@ -938,7 +936,7 @@ void vo_wayland_fullscreen (struct vo *vo) ssurface_schedule_resize(wl->window, wl->window->p_width, wl->window->p_height); wl->window->type = TYPE_TOPLEVEL; - vo_fs = VO_FALSE; + vo->opts->vo.fs = false; show_cursor(wl->display); } @@ -989,7 +987,7 @@ void vo_wayland_update_screeninfo (struct vo *vo) if (!wl->display->output_mode_received) mp_msg(MSGT_VO, MSGL_ERR, "[wayland] no output mode detected\n"); - xinerama_x = xinerama_y = 0; + vo->xinerama_x = vo->xinerama_y = 0; int screen_id = 0; @@ -998,7 +996,7 @@ void vo_wayland_update_screeninfo (struct vo *vo) struct vo_wayland_output *fsscreen_output = NULL; wl_list_for_each_reverse(output, &wl->display->output_list, link) { - if (opts->vo_fsscreen_id == screen_id) + if (opts->vo.fsscreen_id == screen_id) fsscreen_output = output; if (!first_output) @@ -1009,19 +1007,19 @@ void vo_wayland_update_screeninfo (struct vo *vo) if (fsscreen_output) { wl->display->fs_output = fsscreen_output->output; - opts->vo_screenwidth = fsscreen_output->width; - opts->vo_screenheight = fsscreen_output->height; + opts->vo.screenwidth = fsscreen_output->width; + opts->vo.screenheight = fsscreen_output->height; } else { wl->display->fs_output = NULL; /* current output is always 0 */ if (first_output) { - opts->vo_screenwidth = first_output->width; - opts->vo_screenheight = first_output->height; + opts->vo.screenwidth = first_output->width; + opts->vo.screenheight = first_output->height; } } - aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight); + aspect_save_screenres(vo, opts->vo.screenwidth, opts->vo.screenheight); } void vo_wayland_update_window_title(struct vo *vo) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 0fa8f2ad47..52550f469a 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -131,8 +131,8 @@ static int vo_x11_get_fs_type(struct vo *vo); static void xscreensaver_heartbeat(struct vo_x11_state *x11); static void saver_on(struct vo_x11_state *x11); static void saver_off(struct vo_x11_state *x11); -static void vo_x11_selectinput_witherr(Display *display, Window w, - long event_mask); +static void vo_x11_selectinput_witherr(struct vo *vo, Display *display, + Window w, long event_mask); static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer); static void vo_x11_create_colormap(struct vo_x11_state *x11, XVisualInfo *vinfo); @@ -175,7 +175,7 @@ static void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action) } } -static void vo_hidecursor(Display *disp, Window win) +static void vo_hidecursor(struct vo *vo, Display *disp, Window win) { Cursor no_ptr; Pixmap bm_no; @@ -183,7 +183,7 @@ static void vo_hidecursor(Display *disp, Window win) Colormap colormap; const char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0}; - if (WinID == 0) + if (vo->opts->vo.WinID == 0) return; // do not hide if playing on the root window colormap = DefaultColormap(disp, DefaultScreen(disp)); @@ -198,9 +198,9 @@ static void vo_hidecursor(Display *disp, Window win) XFreeColors(disp, colormap, &black.pixel, 1, 0); } -static void vo_showcursor(Display *disp, Window win) +static void vo_showcursor(struct vo *vo, Display *disp, Window win) { - if (WinID == 0) + if (vo->opts->vo.WinID == 0) return; XDefineCursor(disp, win, 0); } @@ -308,7 +308,7 @@ static int vo_wm_detect(struct vo *vo) unsigned long nitems; Atom *args = NULL; - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) return 0; // -- supports layers @@ -374,17 +374,17 @@ void vo_x11_update_screeninfo(struct vo *vo) { struct MPOpts *opts = vo->opts; struct vo_x11_state *x11 = vo->x11; - bool all_screens = vo_fs && opts->vo_fsscreen_id == -2; - xinerama_x = xinerama_y = 0; + bool all_screens = opts->vo.fs && opts->vo.fsscreen_id == -2; + vo->xinerama_x = vo->xinerama_y = 0; if (all_screens) { - opts->vo_screenwidth = x11->ws_width; - opts->vo_screenheight = x11->ws_height; + opts->vo.screenwidth = x11->ws_width; + opts->vo.screenheight = x11->ws_height; } #ifdef CONFIG_XINERAMA - if (opts->vo_screen_id >= -1 && XineramaIsActive(x11->display) && + if (opts->vo.screen_id >= -1 && XineramaIsActive(x11->display) && !all_screens) { - int screen = vo_fs ? opts->vo_fsscreen_id : opts->vo_screen_id; + int screen = opts->vo.fs ? opts->vo.fsscreen_id : opts->vo.screen_id; XineramaScreenInfo *screens; int num_screens; @@ -405,15 +405,15 @@ void vo_x11_update_screeninfo(struct vo *vo) } if (screen < 0) screen = 0; - opts->vo_screenwidth = screens[screen].width; - opts->vo_screenheight = screens[screen].height; - xinerama_x = screens[screen].x_org; - xinerama_y = screens[screen].y_org; + opts->vo.screenwidth = screens[screen].width; + opts->vo.screenheight = screens[screen].height; + vo->xinerama_x = screens[screen].x_org; + vo->xinerama_y = screens[screen].y_org; XFree(screens); } #endif - aspect_save_screenres(vo, opts->vo_screenwidth, opts->vo_screenheight); + aspect_save_screenres(vo, opts->vo.screenwidth, opts->vo.screenheight); } int vo_x11_init(struct vo *vo) @@ -454,16 +454,16 @@ int vo_x11_init(struct vo *vo) init_atoms(vo->x11); - x11->ws_width = opts->vo_screenwidth; - x11->ws_height = opts->vo_screenheight; + x11->ws_width = opts->vo.screenwidth; + x11->ws_height = opts->vo.screenheight; if (!x11->ws_width) x11->ws_width = DisplayWidth(x11->display, x11->screen); if (!x11->ws_height) x11->ws_height = DisplayHeight(x11->display, x11->screen); - opts->vo_screenwidth = x11->ws_width; - opts->vo_screenheight = x11->ws_height; + opts->vo.screenwidth = x11->ws_width; + opts->vo.screenheight = x11->ws_height; if (strncmp(dispName, "unix:", 5) == 0) dispName += 4; @@ -474,7 +474,7 @@ int vo_x11_init(struct vo *vo) else x11->display_is_local = 0; mp_msg(MSGT_VO, MSGL_V, "vo: X11 running at %dx%d (\"%s\" => %s display)\n", - opts->vo_screenwidth, opts->vo_screenheight, dispName, + opts->vo.screenwidth, opts->vo.screenheight, dispName, x11->display_is_local ? "local" : "remote"); x11->wm_type = vo_wm_detect(vo); @@ -483,7 +483,7 @@ int vo_x11_init(struct vo *vo) fstype_dump(x11->fs_type); - if (opts->vo_stop_screensaver) + if (opts->vo.stop_screensaver) saver_off(x11); vo->event_fd = ConnectionNumber(x11->display); @@ -567,10 +567,10 @@ static void vo_x11_decoration(struct vo *vo, int d) Atom vo_MotifHints; MotifWmHints vo_MotifWmHints; - if (!WinID) + if (!vo->opts->vo.WinID) return; - if (vo_fsmode & 8) { + if (vo->opts->vo.fsmode & 8) { XSetTransientForHint(x11->display, x11->window, RootWindow(x11->display, x11->screen)); } @@ -601,12 +601,12 @@ static void vo_x11_decoration(struct vo *vo, int d) d = x11->olddecor; } vo_MotifWmHints.decorations = - d | ((vo_fsmode & 2) ? MWM_DECOR_MENU : 0); + d | ((vo->opts->vo.fsmode & 2) ? MWM_DECOR_MENU : 0); XChangeProperty(x11->display, x11->window, vo_MotifHints, vo_MotifHints, 32, PropModeReplace, (unsigned char *) &vo_MotifWmHints, - (vo_fsmode & 4) ? 4 : 5); + (vo->opts->vo.fsmode & 4) ? 4 : 5); } } @@ -617,7 +617,7 @@ static void vo_x11_classhint(struct vo *vo, Window window, const char *name) XClassHint wmClass; pid_t pid = getpid(); - wmClass.res_name = opts->vo_winname ? opts->vo_winname : (char *)name; + wmClass.res_name = opts->vo.winname ? opts->vo.winname : (char *)name; wmClass.res_class = "mpv"; XSetClassHint(x11->display, window, &wmClass); XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL, @@ -631,7 +631,7 @@ void vo_x11_uninit(struct vo *vo) saver_on(x11); if (x11->window != None) - vo_showcursor(x11->display, x11->window); + vo_showcursor(vo, x11->display, x11->window); if (x11->f_gc != None) XFreeGC(vo->x11->display, x11->f_gc); @@ -653,7 +653,7 @@ void vo_x11_uninit(struct vo *vo) XDestroyIC(x11->xic); if (x11->colormap != None) XFreeColormap(vo->x11->display, x11->colormap); - vo_fs = 0; + vo->opts->vo.fs = false; mp_msg(MSGT_VO, MSGL_V, "vo: uninit ...\n"); if (x11->xim) @@ -670,11 +670,11 @@ static void vo_x11_unhide_cursor(struct vo *vo) struct vo_x11_state *x11 = vo->x11; struct MPOpts *opts = vo->opts; - if (opts->cursor_autohide_delay > -2) { - vo_showcursor(x11->display, x11->window); - if (opts->cursor_autohide_delay >= 0) { + if (opts->vo.cursor_autohide_delay > -2) { + vo_showcursor(vo, x11->display, x11->window); + if (opts->vo.cursor_autohide_delay >= 0) { x11->mouse_waiting_hide = 1; - x11->mouse_timer = GetTimerMS() + opts->cursor_autohide_delay; + x11->mouse_timer = GetTimerMS() + opts->vo.cursor_autohide_delay; } } } @@ -697,13 +697,13 @@ int vo_x11_check_events(struct vo *vo) XEvent Event; if (x11->mouse_waiting_hide && GetTimerMS() >= x11->mouse_timer) { - vo_hidecursor(display, x11->window); + vo_hidecursor(vo, display, x11->window); x11->mouse_waiting_hide = 0; } xscreensaver_heartbeat(vo->x11); - if (WinID > 0) + if (vo->opts->vo.WinID > 0) vo_x11_update_geometry(vo); while (XPending(display)) { XNextEvent(display, &Event); @@ -798,7 +798,7 @@ int vo_x11_check_events(struct vo *vo) vo->next_wakeup_time = FFMIN(vo->next_wakeup_time, x11->mouse_timer); update_vo_size(vo); - if (WinID >= 0 && (x11->pending_vo_events & VO_EVENT_RESIZE)) { + if (vo->opts->vo.WinID >= 0 && (x11->pending_vo_events & VO_EVENT_RESIZE)) { int x = x11->win_x, y = x11->win_y; unsigned int w = x11->win_width, h = x11->win_height; XMoveResizeWindow(x11->display, x11->window, x, y, w, h); @@ -814,14 +814,14 @@ static void vo_x11_sizehint(struct vo *vo, int x, int y, int width, int height, struct MPOpts *opts = vo->opts; struct vo_x11_state *x11 = vo->x11; - bool force_pos = opts->vo_geometry.xy_valid || // explicitly forced by user - opts->force_window_position || // resize -> reset position - opts->vo_screen_id >= 0 || // force onto screen area - WinID >= 0 || // force to fill parent - override_pos; // for fullscreen and such + bool force_pos = opts->vo.geometry.xy_valid || // explicitly forced by user + opts->vo.force_window_position || // resize -> reset position + opts->vo.screen_id >= 0 || // force onto screen area + vo->opts->vo.WinID >= 0 || // force to fill parent + override_pos; // for fullscreen and such x11->vo_hint.flags = 0; - if (vo_keepaspect) { + if (vo->opts->vo.keepaspect) { x11->vo_hint.flags |= PAspect; x11->vo_hint.min_aspect.x = width; x11->vo_hint.min_aspect.y = height; @@ -960,7 +960,7 @@ static void vo_x11_create_window(struct vo *vo, XVisualInfo *vis, int x, int y, XSetWindowAttributes xswa; setup_window_params(x11, vis, &xswamask, &xswa); - Window parent = WinID >= 0 ? WinID : x11->rootwin; + Window parent = vo->opts->vo.WinID >= 0 ? vo->opts->vo.WinID : x11->rootwin; x11->window = XCreateWindow(x11->display, parent, x, y, w, h, 0, vis->depth, @@ -970,7 +970,7 @@ static void vo_x11_create_window(struct vo *vo, XVisualInfo *vis, int x, int y, x11->vo_gc = XCreateGC(x11->display, x11->window, 0, NULL); XSetForeground(x11->display, x11->f_gc, 0); - vo_hidecursor(x11->display, x11->window); + vo_hidecursor(vo, x11->display, x11->window); x11->xic = XCreateIC(x11->xim, XNInputStyle, XIMPreeditNone | XIMStatusNone, XNClientWindow, x11->window, @@ -984,10 +984,10 @@ static void vo_x11_map_window(struct vo *vo, int x, int y, int w, int h) x11->window_hidden = false; vo_x11_move_resize(vo, true, true, x, y, w, h); - if (!vo_border) + if (!vo->opts->vo.border) vo_x11_decoration(vo, 0); // map window - vo_x11_selectinput_witherr(x11->display, x11->window, + vo_x11_selectinput_witherr(vo, x11->display, x11->window, StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask); @@ -1011,8 +1011,8 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, struct MPOpts *opts = vo->opts; struct vo_x11_state *x11 = vo->x11; - if (WinID >= 0) { - XSelectInput(x11->display, WinID, StructureNotifyMask); + if (opts->vo.WinID >= 0) { + XSelectInput(x11->display, opts->vo.WinID, StructureNotifyMask); vo_x11_update_geometry(vo); x = x11->win_x; y = x11->win_y; width = x11->win_width; height = x11->win_height; @@ -1020,7 +1020,7 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, if (x11->window == None) { vo_x11_create_window(vo, vis, x, y, width, height); vo_x11_classhint(vo, x11->window, classname); - vo_fs = 0; + opts->vo.fs = 0; x11->window_hidden = true; } @@ -1028,8 +1028,8 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, return; vo_x11_update_window_title(vo); - if (opts->vo_ontop) - vo_x11_setlayer(vo, x11->window, opts->vo_ontop); + if (opts->vo.ontop) + vo_x11_setlayer(vo, x11->window, opts->vo.ontop); bool reset_size = !(x11->old_dwidth == width && x11->old_dheight == height); if (x11->window_hidden) { @@ -1049,12 +1049,12 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, if (x11->window_hidden) { vo_x11_map_window(vo, x, y, width, height); } else if (reset_size) { - bool reset_pos = opts->force_window_position; + bool reset_pos = opts->vo.force_window_position; if (reset_pos) { x11->nofs_x = x; x11->nofs_y = y; } - if (vo_fs) { + if (opts->vo.fs) { x11->size_changed_during_fs = true; x11->pos_changed_during_fs = reset_pos; vo_x11_sizehint(vo, x, y, width, height, false); @@ -1063,7 +1063,7 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, } } - if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN)) { + if (!!opts->vo.fs != !!(flags & VOFLAG_FULLSCREEN)) { vo_x11_fullscreen(vo); } @@ -1113,7 +1113,7 @@ void vo_x11_clearwindow(struct vo *vo, Window vo_window) if (x11->f_gc == None) return; XFillRectangle(x11->display, vo_window, x11->f_gc, 0, 0, - opts->vo_screenwidth, opts->vo_screenheight); + opts->vo.screenwidth, opts->vo.screenheight); XFlush(x11->display); } @@ -1121,7 +1121,7 @@ void vo_x11_clearwindow(struct vo *vo, Window vo_window) static void vo_x11_setlayer(struct vo *vo, Window vo_window, int layer) { struct vo_x11_state *x11 = vo->x11; - if (WinID >= 0) + if (vo->opts->vo.WinID >= 0) return; if (x11->fs_type & vo_wm_LAYER) { @@ -1181,7 +1181,7 @@ static int vo_x11_get_fs_type(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; int type = x11->wm_type; - char **fstype_list = vo->opts->vo_fstype_list; + char **fstype_list = vo->opts->vo.fstype_list; int i; if (fstype_list) { @@ -1247,14 +1247,14 @@ static void vo_x11_update_geometry(struct vo *vo) unsigned w, h, dummy_uint; int dummy_int; Window dummy_win; - Window win = WinID >= 0 ? WinID : x11->window; + Window win = vo->opts->vo.WinID >= 0 ? vo->opts->vo.WinID : x11->window; XGetGeometry(x11->display, win, &dummy_win, &dummy_int, &dummy_int, &w, &h, &dummy_int, &dummy_uint); if (w <= INT_MAX && h <= INT_MAX) { x11->win_width = w; x11->win_height = h; } - if (WinID >= 0) { + if (vo->opts->vo.WinID >= 0) { x11->win_x = 0; x11->win_y = 0; } else { @@ -1269,16 +1269,16 @@ void vo_x11_fullscreen(struct vo *vo) struct vo_x11_state *x11 = vo->x11; int x, y, w, h; - if (WinID >= 0) { - vo_fs = !vo_fs; + if (opts->vo.WinID >= 0) { + opts->vo.fs = !opts->vo.fs; return; } if (x11->fs_flip) return; - if (vo_fs) { + if (opts->vo.fs) { // fs->win - vo_fs = VO_FALSE; + opts->vo.fs = VO_FALSE; x = x11->nofs_x; y = x11->nofs_y; @@ -1286,7 +1286,7 @@ void vo_x11_fullscreen(struct vo *vo) h = x11->nofs_height; vo_x11_ewmh_fullscreen(x11, _NET_WM_STATE_REMOVE); // removes fullscreen state if wm supports EWMH - if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->vo_fsscreen_id != -1) { + if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->vo.fsscreen_id != -1) { x11->size_changed_during_fs = true; x11->pos_changed_during_fs = true; } @@ -1297,7 +1297,7 @@ void vo_x11_fullscreen(struct vo *vo) } } else { // win->fs - vo_fs = VO_TRUE; + opts->vo.fs = true; vo_x11_update_geometry(vo); x11->nofs_x = x11->win_x; @@ -1307,12 +1307,12 @@ void vo_x11_fullscreen(struct vo *vo) vo_x11_update_screeninfo(vo); - x = xinerama_x; - y = xinerama_y; - w = opts->vo_screenwidth; - h = opts->vo_screenheight; + x = vo->xinerama_x; + y = vo->xinerama_y; + w = opts->vo.screenwidth; + h = opts->vo.screenheight; - if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->vo_fsscreen_id != -1) { + if ((x11->fs_type & vo_wm_FULLSCREEN) && opts->vo.fsscreen_id != -1) { // The EWMH fullscreen hint always works on the current screen, so // change the current screen forcibly. // This was observed to work under IceWM, but not Unity/Compiz and @@ -1331,23 +1331,23 @@ void vo_x11_fullscreen(struct vo *vo) else x11->old_gravity = x11->vo_hint.win_gravity; } - if (x11->wm_type == 0 && !(vo_fsmode & 16)) { + if (x11->wm_type == 0 && !(vo->opts->vo.fsmode & 16)) { XUnmapWindow(x11->display, x11->window); // required for MWM XWithdrawWindow(x11->display, x11->window, x11->screen); x11->fs_flip = 1; } if (!(x11->fs_type & vo_wm_FULLSCREEN)) { // not needed with EWMH fs - vo_x11_decoration(vo, vo_border && !vo_fs); + vo_x11_decoration(vo, opts->vo.border && !opts->vo.fs); vo_x11_sizehint(vo, x, y, w, h, true); - vo_x11_setlayer(vo, x11->window, vo_fs); + vo_x11_setlayer(vo, x11->window, opts->vo.fs); XMoveResizeWindow(x11->display, x11->window, x, y, w, h); } /* some WMs lose ontop after fullscreen */ - if ((!(vo_fs)) & opts->vo_ontop) - vo_x11_setlayer(vo, x11->window, opts->vo_ontop); + if ((!(opts->vo.fs)) & opts->vo.ontop) + vo_x11_setlayer(vo, x11->window, opts->vo.ontop); XMapRaised(x11->display, x11->window); if (!(x11->fs_type & vo_wm_FULLSCREEN)) // some WMs change window pos on map @@ -1362,15 +1362,15 @@ void vo_x11_fullscreen(struct vo *vo) void vo_x11_ontop(struct vo *vo) { struct MPOpts *opts = vo->opts; - opts->vo_ontop = !opts->vo_ontop; + opts->vo.ontop = !opts->vo.ontop; - vo_x11_setlayer(vo, vo->x11->window, opts->vo_ontop); + vo_x11_setlayer(vo, vo->x11->window, opts->vo.ontop); } void vo_x11_border(struct vo *vo) { - vo_border = !vo_border; - vo_x11_decoration(vo, vo_border && !vo_fs); + vo->opts->vo.border = !vo->opts->vo.border; + vo_x11_decoration(vo, vo->opts->vo.border && !vo->opts->vo.fs); } static void xscreensaver_heartbeat(struct vo_x11_state *x11) @@ -1463,10 +1463,12 @@ static void saver_off(struct vo_x11_state *x11) #endif } -static void vo_x11_selectinput_witherr(Display *display, Window w, +static void vo_x11_selectinput_witherr(struct vo *vo, + Display *display, + Window w, long event_mask) { - if (vo_nomouse_input) + if (vo->opts->vo.nomouse_input) event_mask &= ~(ButtonPressMask | ButtonReleaseMask); XSelectInput(display, w, NoEventMask); -- cgit v1.2.3