From 70346d3be623bc5edc31a15bd1ca205c33050219 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 24 Feb 2013 23:36:40 +0100 Subject: video/out: remove video mode switching (--vm) This allowed making the player switch the monitor video mode when creating the video window. This was a questionable feature, and with today's LCD screens certainly not useful anymore. Switching to a random video mode (going by video width/height) doesn't sound too useful either. I'm not sure about the win32 implementation, but the X part had several bugs. Even in mplayer-svn (where x11_common.c hasn't been receiving any larger changes for a long time), this code is buggy and doesn't do the right thing anyway. (And what the hell _did_ it do when using multiple physical monitors?) If you really want this, write a shell script that calls xrandr before and after calling mpv. vo_sdl still can do mode switching, because SDL has native support for it, and using it is trivial. Add a new sub-option for this. --- DOCS/man/en/options.rst | 4 -- DOCS/man/en/vo.rst | 3 ++ core/cfg-mplayer.h | 5 -- core/options.h | 2 - video/decode/vd.c | 5 +- video/filter/vf_vo.c | 3 +- video/out/vo.c | 1 - video/out/vo.h | 2 - video/out/vo_sdl.c | 5 +- video/out/w32_common.c | 48 ------------------ video/out/w32_common.h | 2 - video/out/x11_common.c | 130 +----------------------------------------------- video/out/x11_common.h | 2 - 13 files changed, 11 insertions(+), 201 deletions(-) diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 2d685f0217..ae83fd50b6 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -2320,10 +2320,6 @@ --vid= Select video channel. ``auto`` selects the default, ``no`` disables video. ---vm - Try to change to a different video mode. Supported by the x11 and xv video - output drivers. - --vo= Specify a priority list of video output drivers to be used. For interactive use you'd normally specify a single one to use, but in diff --git a/DOCS/man/en/vo.rst b/DOCS/man/en/vo.rst index e15436a061..00a598e41b 100644 --- a/DOCS/man/en/vo.rst +++ b/DOCS/man/en/vo.rst @@ -652,6 +652,9 @@ sdl sw Continue even if a software renderer is detected. + switch-mode + Instruct SDL to switch the monitor video mode when going fullscreen. + null Produces no video output. Useful for benchmarking. diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h index 82d030ff1e..57dd5253c8 100644 --- a/core/cfg-mplayer.h +++ b/core/cfg-mplayer.h @@ -561,15 +561,11 @@ const m_option_t mplayer_opts[]={ // set aspect ratio of monitor - useful for 16:9 TV-out OPT_FLOATRANGE("monitoraspect", force_monitor_aspect, 0, 0.0, 9.0), OPT_FLOATRANGE("monitorpixelaspect", monitor_pixel_aspect, 0, 0.2, 9.0), - // video mode switching: (x11,xv,dga) - OPT_FLAG("vm", vidmode, 0), // start in fullscreen mode: OPT_FLAG("fullscreen", fullscreen, 0), OPT_FLAG("fs", fullscreen, 0), // set fullscreen switch method (workaround for buggy WMs) {"fsmode-dontuse", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL}, - // set bpp (x11+vm) - OPT_INTRANGE("bpp", vo_dbpp, 0, 0, 32), {"colorkey", &vo_colorkey, CONF_TYPE_INT, 0, 0, 0, NULL}, {"no-colorkey", &vo_colorkey, CONF_TYPE_STORE, 0, 0, 0x1000000, NULL}, // wait for v-sync (gl) @@ -591,7 +587,6 @@ const m_option_t mplayer_opts[]={ {"limited", MP_CSP_LEVELS_TV}, {"full", MP_CSP_LEVELS_PC})), - {"grabpointer", &vo_grabpointer, CONF_TYPE_FLAG, 0, 0, 1, NULL}, OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0, 0, 30000, ({"no", -1}, {"always", -2})), diff --git a/core/options.h b/core/options.h index 254af2e241..f23ff51e44 100644 --- a/core/options.h +++ b/core/options.h @@ -28,9 +28,7 @@ typedef struct MPOpts { char *vo_wintitle; float force_monitor_aspect; float monitor_pixel_aspect; - int vidmode; int fullscreen; - int vo_dbpp; float vo_panscanrange; int vo_force_rgba_osd; int requested_colorspace; diff --git a/video/decode/vd.c b/video/decode/vd.c index 99710f43d5..b43570f0ad 100644 --- a/video/decode/vd.c +++ b/video/decode/vd.c @@ -147,9 +147,8 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int out_fmt) mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_ASPECT=%1.4f\n", sh->aspect); } - vocfg_flags = (opts->fullscreen ? VOFLAG_FULLSCREEN : 0) - | (opts->vidmode ? VOFLAG_MODESWITCHING : 0) - | (flip ? VOFLAG_FLIPPING : 0); + vocfg_flags = (opts->fullscreen ? VOFLAG_FULLSCREEN : 0) | + (flip ? VOFLAG_FLIPPING : 0); // Time to config libvo! mp_msg(MSGT_CPLAYER, MSGL_V, diff --git a/video/filter/vf_vo.c b/video/filter/vf_vo.c index bb29684b10..d8d00130d7 100644 --- a/video/filter/vf_vo.c +++ b/video/filter/vf_vo.c @@ -48,13 +48,12 @@ static int config(struct vf_instance *vf, } const vo_info_t *info = video_out->driver->info; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "VO: [%s] %dx%d => %dx%d %s %s%s%s\n", + mp_msg(MSGT_CPLAYER, MSGL_INFO, "VO: [%s] %dx%d => %dx%d %s %s%s\n", info->short_name, width, height, d_width, d_height, vo_format_name(outfmt), (flags & VOFLAG_FULLSCREEN) ? " [fs]" : "", - (flags & VOFLAG_MODESWITCHING) ? " [vm]" : "", (flags & VOFLAG_FLIPPING) ? " [flip]" : ""); mp_msg(MSGT_CPLAYER, MSGL_V, "VO: Description: %s\n", info->name); mp_msg(MSGT_CPLAYER, MSGL_V, "VO: Author: %s\n", info->author); diff --git a/video/out/vo.c b/video/out/vo.c index aa34f7704a..76c71518e6 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -50,7 +50,6 @@ int xinerama_x; int xinerama_y; int vo_nomouse_input = 0; -int vo_grabpointer = 1; int vo_vsync = 1; int vo_fs = 0; int vo_fsmode = 0; diff --git a/video/out/vo.h b/video/out/vo.h index f26ec1baff..50a30f82ea 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -118,7 +118,6 @@ typedef struct { #define VO_NOTIMPL -3 #define VOFLAG_FULLSCREEN 0x01 -#define VOFLAG_MODESWITCHING 0x02 #define VOFLAG_FLIPPING 0x08 #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window #define VOFLAG_STEREO 0x20 //< Use to create a stereo-capable window @@ -308,7 +307,6 @@ extern const struct vo_driver *video_out_drivers[]; extern int xinerama_x; extern int xinerama_y; -extern int vo_grabpointer; extern int vo_vsync; extern int vo_fs; extern int vo_fsmode; diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index e9967f37e5..99829aefa6 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -197,6 +197,7 @@ struct priv { // options int allow_sw; + int switch_mode; }; static bool is_good_renderer(SDL_RendererInfo *ri, @@ -370,11 +371,10 @@ static void check_resize(struct vo *vo) static void set_fullscreen(struct vo *vo, int fs) { struct priv *vc = vo->priv; - struct MPOpts *opts = vo->opts; Uint32 fs_flags = 0; if (fs) { - if (opts->vidmode) + if (vc->switch_mode) fs_flags |= SDL_WINDOW_FULLSCREEN; else fs_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; @@ -1036,6 +1036,7 @@ const struct vo_driver video_out_sdl = { }, .options = (const struct m_option []){ OPT_FLAG("sw", allow_sw, 0), + OPT_FLAG("switch-mode", switch_mode, 0), {NULL} }, .preinit = preinit, diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 54620bdec6..ca3d8a7cc5 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -388,50 +388,6 @@ static void updateScreenProperties(struct vo *vo) w32_update_xinerama_info(vo); } -static void changeMode(struct vo *vo) -{ - struct vo_w32_state *w32 = vo->w32; - DEVMODE dm; - dm.dmSize = sizeof dm; - dm.dmDriverExtra = 0; - - dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - dm.dmBitsPerPel = w32->depthonscreen; - dm.dmPelsWidth = vo->opts->vo_screenwidth; - dm.dmPelsHeight = vo->opts->vo_screenheight; - - if (w32->vm) { - int bestMode = -1; - int bestScore = INT_MAX; - int i; - for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) { - int score = (dm.dmPelsWidth - w32->o_dwidth) - * (dm.dmPelsHeight - w32->o_dheight); - if (dm.dmBitsPerPel != w32->depthonscreen - || dm.dmPelsWidth < w32->o_dwidth - || dm.dmPelsHeight < w32->o_dheight) - continue; - - if (score < bestScore) { - bestScore = score; - bestMode = i; - } - } - - if (bestMode != -1) - EnumDisplaySettings(0, bestMode, &dm); - - ChangeDisplaySettings(&dm, CDS_FULLSCREEN); - } -} - -static void resetMode(struct vo *vo) -{ - struct vo_w32_state *w32 = vo->w32; - if (w32->vm) - ChangeDisplaySettings(0, 0); -} - static DWORD update_style(struct vo *vo, DWORD style) { const DWORD NO_FRAME = WS_POPUP; @@ -465,10 +421,8 @@ static int reinit_window_state(struct vo *vo) // xxx not sure if this can trigger any unwanted messages (WM_MOVE/WM_SIZE) if (vo_fs) { - changeMode(vo); while (ShowCursor(0) >= 0) /**/ ; } else { - resetMode(vo); while (ShowCursor(1) < 0) /**/ ; } updateScreenProperties(vo); @@ -594,7 +548,6 @@ int vo_w32_config(struct vo *vo, uint32_t width, uint32_t height, } vo_fs = flags & VOFLAG_FULLSCREEN; - w32->vm = flags & VOFLAG_MODESWITCHING; return reinit_window_state(vo); } @@ -732,7 +685,6 @@ void vo_w32_uninit(struct vo *vo) mp_msg(MSGT_VO, MSGL_V, "vo: win32: uninit\n"); if (!w32) return; - resetMode(vo); ShowCursor(1); DestroyWindow(w32->window); UnregisterClassW(classname, 0); diff --git a/video/out/w32_common.h b/video/out/w32_common.h index 57997dd67b..63a7d19fc9 100644 --- a/video/out/w32_common.h +++ b/video/out/w32_common.h @@ -26,8 +26,6 @@ struct vo_w32_state { HWND window; - bool vm; - int depthonscreen; // last non-fullscreen extends (updated only on fullscreen or on initialization) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 3424d75cef..0514e88fef 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -133,8 +133,6 @@ 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_setlayer(struct vo *vo, Window vo_window, int layer); -static void vo_x11_vm_switch(struct vo *vo); -static void vo_x11_vm_close(struct vo *vo); static void vo_x11_create_colormap(struct vo_x11_state *x11, XVisualInfo *vinfo); @@ -627,7 +625,6 @@ void vo_x11_uninit(struct vo *vo) struct vo_x11_state *x11 = vo->x11; assert(x11); - vo_x11_vm_close(vo); saver_on(x11); if (x11->window != None) vo_showcursor(x11->display, x11->window); @@ -1019,8 +1016,6 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, if (flags & VOFLAG_HIDDEN) goto final; if (x11->window_state & VOFLAG_HIDDEN) { - if (flags & VOFLAG_MODESWITCHING) - vo_x11_vm_switch(vo); XSizeHints hint; x11->window_state &= ~VOFLAG_HIDDEN; vo_x11_classhint(vo, x11->window, classname); @@ -1031,10 +1026,10 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, hint.width = width; hint.height = height; hint.flags = PSize; - if (force_change_xy || x11->vm_set) + if (force_change_xy) hint.flags |= PPosition; XSetWMNormalHints(mDisplay, x11->window, &hint); - if (!vo_border || x11->vm_set) + if (!vo_border) vo_x11_decoration(vo, 0); // map window x11->xic = XCreateIC(x11->xim, @@ -1063,14 +1058,6 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, vo->dwidth = vo->opts->vo_screenwidth; vo->dheight = vo->opts->vo_screenheight; } - if (x11->vm_set) { - /* Grab the mouse pointer in our window */ - if (vo_grabpointer) { - XGrabPointer(x11->display, x11->window, True, 0, GrabModeAsync, - GrabModeAsync, x11->window, None, CurrentTime); - } - XSetInputFocus(x11->display, x11->window, RevertToNone, CurrentTime); - } final: if (x11->vo_gc != None) XFreeGC(mDisplay, x11->vo_gc); @@ -1490,108 +1477,6 @@ static void vo_x11_selectinput_witherr(Display *display, Window w, } #ifdef CONFIG_XF86VM -static void vo_x11_vm_switch(struct vo *vo) -{ - struct vo_x11_state *x11 = vo->x11; - Display *mDisplay = x11->display; - int vm_event, vm_error; - int vm_ver, vm_rev; - int have_vm = 0; - int X = vo->dwidth, Y = vo->dheight; - int modeline_width, modeline_height; - - if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) { - XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev); - mp_msg(MSGT_VO, MSGL_V, "XF86VidMode extension v%i.%i\n", vm_ver, - vm_rev); - have_vm = 1; - } else { - mp_msg(MSGT_VO, MSGL_WARN, - "XF86VidMode extension not available.\n"); - } - - if (have_vm) { - if (!x11->vm_orig_w) { - int clock; - XF86VidModeModeLine modeline; - XF86VidModeGetModeLine(x11->display, x11->screen, &clock, &modeline); - x11->vm_orig_w = modeline.hdisplay; - x11->vm_orig_h = modeline.vdisplay; - } - - int modecount = 0; - XF86VidModeModeInfo **vidmodes = NULL; - XF86VidModeGetAllModeLines(mDisplay, x11->screen, &modecount, &vidmodes); - if (modecount == 0) - return; - - int j = 0; - modeline_width = vidmodes[0]->hdisplay; - modeline_height = vidmodes[0]->vdisplay; - - for (int i = 1; i < modecount; i++) { - if ((vidmodes[i]->hdisplay >= X) - && (vidmodes[i]->vdisplay >= Y)) - { - if ((vidmodes[i]->hdisplay <= modeline_width) - && (vidmodes[i]->vdisplay <= modeline_height)) - { - modeline_width = vidmodes[i]->hdisplay; - modeline_height = vidmodes[i]->vdisplay; - j = i; - } - } - } - - mp_tmsg(MSGT_VO, MSGL_INFO, "XF86VM: Selected video mode %dx%d for image size %dx%d.\n", - modeline_width, modeline_height, X, Y); - XF86VidModeLockModeSwitch(mDisplay, x11->screen, 0); - XF86VidModeSwitchToMode(mDisplay, x11->screen, vidmodes[j]); - - // FIXME: all this is more of a hack than proper solution - // center the video if the screen has different size - X = (x11->vm_orig_w - modeline_width) / 2; - Y = (x11->vm_orig_h - modeline_height) / 2; - XF86VidModeSetViewPort(mDisplay, x11->screen, X, Y); - vo->dx = X; - vo->dy = Y; - vo->dwidth = modeline_width; - vo->dheight = modeline_height; - aspect_save_screenres(vo, modeline_width, modeline_height); - - x11->vm_set = 1; - free(vidmodes); - } -} - -static void vo_x11_vm_close(struct vo *vo) -{ - struct vo_x11_state *x11 = vo->x11; - Display *dpy = x11->display; - if (x11->vm_set) { - int modecount = 0; - XF86VidModeModeInfo **vidmodes = NULL; - XF86VidModeModeInfo *mode = NULL; - - XF86VidModeGetAllModeLines(dpy, x11->screen, &modecount, &vidmodes); - for (int i = 0; i < modecount; i++) { - if ((vidmodes[i]->hdisplay == x11->vm_orig_w) - && (vidmodes[i]->vdisplay == x11->vm_orig_h)) - { - mp_msg(MSGT_VO, MSGL_INFO, "Returning to original mode %dx%d\n", - x11->vm_orig_w, x11->vm_orig_h); - mode = vidmodes[i]; - break; - } - } - - if (mode) - XF86VidModeSwitchToMode(dpy, x11->screen, mode); - - free(vidmodes); - } -} - double vo_x11_vm_get_fps(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; @@ -1603,22 +1488,11 @@ double vo_x11_vm_get_fps(struct vo *vo) XFree(modeline.private); return 1e3 * clock / modeline.htotal / modeline.vtotal; } - #else /* CONFIG_XF86VM */ - -static void vo_x11_vm_switch(struct vo *vo) -{ -} - -static void vo_x11_vm_close(struct vo *vo) -{ -} - double vo_vm_get_fps(struct vo *vo) { return 0; } - #endif diff --git a/video/out/x11_common.h b/video/out/x11_common.h index 71868cd11d..87067fc2a6 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -52,8 +52,6 @@ struct vo_x11_state { int window_state; int fs_flip; int fs_layer; - int vm_set; - int vm_orig_w, vm_orig_h; GC f_gc; XSizeHints vo_hint; -- cgit v1.2.3