0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
wm4 2013-02-24 23:36:40 +01:00
parent b23dce6d7c
commit 70346d3be6
13 changed files with 11 additions and 201 deletions

View File

@ -2320,10 +2320,6 @@
--vid=<ID|auto|no>
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=<driver1[:suboption1[=value]:...],driver2,...[,]>
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

View File

@ -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.

View File

@ -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})),

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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;