mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 04:36:24 +01:00
Move vo_screenwidth,vo_screenheight to options struct
This commit is contained in:
parent
432e8ff4a5
commit
78172918ff
@ -173,8 +173,8 @@ const m_option_t mplayer_opts[]={
|
||||
{"x", &opt_screen_size_x, CONF_TYPE_INT, CONF_RANGE, 0, 4096, NULL},
|
||||
{"y", &opt_screen_size_y, CONF_TYPE_INT, CONF_RANGE, 0, 4096, NULL},
|
||||
// set screen dimensions (when not detectable or virtual!=visible)
|
||||
{"screenw", &vo_screenwidth, CONF_TYPE_INT, CONF_RANGE|CONF_OLD, 0, 4096, NULL},
|
||||
{"screenh", &vo_screenheight, CONF_TYPE_INT, CONF_RANGE|CONF_OLD, 0, 4096, NULL},
|
||||
INTRANGE("screenw", vo_screenwidth, 0, 4096, CONF_OLD),
|
||||
INTRANGE("screenh", vo_screenheight, 0, 4096, CONF_OLD),
|
||||
// Geometry string
|
||||
{"geometry", &vo_geometry, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
// set aspect ratio of monitor - useful for 16:9 TV-out
|
||||
|
11
command.c
11
command.c
@ -69,13 +69,14 @@ extern int use_menu;
|
||||
static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy,
|
||||
double *dx, double *dy)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
struct vo *vo = mpctx->video_out;
|
||||
//remove the borders, if any, and rescale to the range [0,1],[0,1]
|
||||
if (vo_fs) { //we are in full-screen mode
|
||||
if (vo_screenwidth > vo->dwidth) //there are borders along the x axis
|
||||
ix -= (vo_screenwidth - vo->dwidth) / 2;
|
||||
if (vo_screenheight > vo->dheight) //there are borders along the y axis (usual way)
|
||||
iy -= (vo_screenheight - vo->dheight) / 2;
|
||||
if (opts->vo_screenwidth > vo->dwidth) //there are borders along the x axis
|
||||
ix -= (opts->vo_screenwidth - vo->dwidth) / 2;
|
||||
if (opts->vo_screenheight > vo->dheight) //there are borders along the y axis (usual way)
|
||||
iy -= (opts->vo_screenheight - vo->dheight) / 2;
|
||||
|
||||
if (ix < 0 || ix > vo->dwidth) {
|
||||
*dx = *dy = -1.0;
|
||||
@ -92,7 +93,7 @@ static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy,
|
||||
|
||||
mp_msg(MSGT_CPLAYER, MSGL_V,
|
||||
"\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
|
||||
*dx, *dy, vo_screenwidth, vo_screenheight, vo->dwidth,
|
||||
*dx, *dy, opts->vo_screenwidth, opts->vo_screenheight, vo->dwidth,
|
||||
vo->dheight, vo_fs);
|
||||
}
|
||||
|
||||
|
@ -15,4 +15,6 @@
|
||||
#define vo_dwidth global_vo->dwidth
|
||||
#define vo_dheight global_vo->dheight
|
||||
#define vo_dbpp global_vo->opts->vo_dbpp
|
||||
#define vo_screenwidth global_vo->opts->vo_screenwidth
|
||||
#define vo_screenheight global_vo->opts->vo_screenheight
|
||||
#endif
|
||||
|
@ -30,10 +30,6 @@ int xinerama_screen = -1;
|
||||
int xinerama_x;
|
||||
int xinerama_y;
|
||||
|
||||
// currect resolution/bpp on screen: (should be autodetected by vo_init())
|
||||
int vo_screenwidth=0;
|
||||
int vo_screenheight=0;
|
||||
|
||||
int vo_nomouse_input = 0;
|
||||
int vo_grabpointer = 1;
|
||||
int vo_doublebuffering = 1;
|
||||
@ -353,16 +349,17 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||
char *title, uint32_t format)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
panscan_init();
|
||||
aspect_save_orig(width, height);
|
||||
aspect_save_prescale(d_width, d_height);
|
||||
|
||||
if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
|
||||
aspect(&d_width, &d_height, A_NOZOOM);
|
||||
vo->dx = (int)(vo_screenwidth - d_width) / 2;
|
||||
vo->dy = (int)(vo_screenheight - d_height) / 2;
|
||||
vo->dx = (int)(opts->vo_screenwidth - d_width) / 2;
|
||||
vo->dy = (int)(opts->vo_screenheight - d_height) / 2;
|
||||
geometry(&vo->dx, &vo->dy, &d_width, &d_height,
|
||||
vo_screenwidth, vo_screenheight);
|
||||
opts->vo_screenwidth, opts->vo_screenheight);
|
||||
vo->dx += xinerama_x;
|
||||
vo->dy += xinerama_y;
|
||||
vo->dwidth = d_width;
|
||||
|
@ -245,10 +245,6 @@ extern int xinerama_screen;
|
||||
extern int xinerama_x;
|
||||
extern int xinerama_y;
|
||||
|
||||
// correct resolution/bpp on screen: (should be autodetected by vo_init())
|
||||
extern int vo_screenwidth;
|
||||
extern int vo_screenheight;
|
||||
|
||||
extern int vo_grabpointer;
|
||||
extern int vo_doublebuffering;
|
||||
extern int vo_directrendering;
|
||||
|
@ -152,13 +152,14 @@ static void draw_alpha_null(void *p, int x0, int y0, int w, int h,
|
||||
static void deallocate_xvimage(struct vo *vo, int foo);
|
||||
|
||||
static void calc_drwXY(struct vo *vo, uint32_t *drwX, uint32_t *drwY) {
|
||||
struct MPOpts *opts = vo->opts;
|
||||
*drwX = *drwY = 0;
|
||||
if (vo_fs) {
|
||||
aspect(&vo->dwidth, &vo->dheight, A_ZOOM);
|
||||
vo->dwidth = FFMIN(vo->dwidth, vo_screenwidth);
|
||||
vo->dheight = FFMIN(vo->dheight, vo_screenheight);
|
||||
*drwX = (vo_screenwidth - vo->dwidth) / 2;
|
||||
*drwY = (vo_screenheight - vo->dheight) / 2;
|
||||
vo->dwidth = FFMIN(vo->dwidth, opts->vo_screenwidth);
|
||||
vo->dheight = FFMIN(vo->dheight, opts->vo_screenheight);
|
||||
*drwX = (opts->vo_screenwidth - vo->dwidth) / 2;
|
||||
*drwY = (opts->vo_screenheight - vo->dheight) / 2;
|
||||
mp_msg(MSGT_VO, MSGL_V, "[xv-fs] dx: %d dy: %d dw: %d dh: %d\n",
|
||||
*drwX, *drwY, vo->dwidth, vo->dheight);
|
||||
} else if (WinID == 0) {
|
||||
@ -246,8 +247,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
vo_vm_switch(vo, vm_width, vm_height, &modeline_width,
|
||||
&modeline_height);
|
||||
ctx->mode_switched = 1;
|
||||
hint.x = (vo_screenwidth - modeline_width) / 2;
|
||||
hint.y = (vo_screenheight - modeline_height) / 2;
|
||||
hint.x = (opts->vo_screenwidth - modeline_width) / 2;
|
||||
hint.y = (opts->vo_screenheight - modeline_height) / 2;
|
||||
hint.width = modeline_width;
|
||||
hint.height = modeline_height;
|
||||
aspect_save_screenres(modeline_width, modeline_height);
|
||||
@ -706,7 +707,7 @@ static void uninit(struct vo *vo)
|
||||
deallocate_xvimage(vo, i);
|
||||
#ifdef HAVE_XF86VM
|
||||
if (ctx->mode_switched)
|
||||
vo_vm_close(vo->x11->display);
|
||||
vo_vm_close(vo);
|
||||
#endif
|
||||
if (ctx->event_fd_registered)
|
||||
mp_input_rm_event_fd(ConnectionNumber(vo->x11->display));
|
||||
|
@ -373,6 +373,7 @@ static void init_atoms(Display *d)
|
||||
}
|
||||
|
||||
void update_xinerama_info(struct vo *vo) {
|
||||
struct MPOpts *opts = vo->opts;
|
||||
int screen = xinerama_screen;
|
||||
xinerama_x = xinerama_y = 0;
|
||||
#ifdef HAVE_XINERAMA
|
||||
@ -398,19 +399,20 @@ void update_xinerama_info(struct vo *vo) {
|
||||
}
|
||||
if (screen < 0)
|
||||
screen = 0;
|
||||
vo_screenwidth = screens[screen].width;
|
||||
vo_screenheight = screens[screen].height;
|
||||
opts->vo_screenwidth = screens[screen].width;
|
||||
opts->vo_screenheight = screens[screen].height;
|
||||
xinerama_x = screens[screen].x_org;
|
||||
xinerama_y = screens[screen].y_org;
|
||||
|
||||
XFree(screens);
|
||||
}
|
||||
#endif
|
||||
aspect_save_screenres(vo_screenwidth, vo_screenheight);
|
||||
aspect_save_screenres(opts->vo_screenwidth, opts->vo_screenheight);
|
||||
}
|
||||
|
||||
int vo_init(struct vo *vo)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
// int mScreen;
|
||||
int depth, bpp;
|
||||
@ -462,17 +464,17 @@ int vo_init(struct vo *vo)
|
||||
int clock;
|
||||
|
||||
XF86VidModeGetModeLine(x11->display, mScreen, &clock, &modeline);
|
||||
if (!vo_screenwidth)
|
||||
vo_screenwidth = modeline.hdisplay;
|
||||
if (!vo_screenheight)
|
||||
vo_screenheight = modeline.vdisplay;
|
||||
if (!opts->vo_screenwidth)
|
||||
opts->vo_screenwidth = modeline.hdisplay;
|
||||
if (!opts->vo_screenheight)
|
||||
opts->vo_screenheight = modeline.vdisplay;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
if (!vo_screenwidth)
|
||||
vo_screenwidth = DisplayWidth(x11->display, mScreen);
|
||||
if (!vo_screenheight)
|
||||
vo_screenheight = DisplayHeight(x11->display, mScreen);
|
||||
if (!opts->vo_screenwidth)
|
||||
opts->vo_screenwidth = DisplayWidth(x11->display, mScreen);
|
||||
if (!opts->vo_screenheight)
|
||||
opts->vo_screenheight = DisplayHeight(x11->display, mScreen);
|
||||
}
|
||||
// get color depth (from root window, or the best visual):
|
||||
XGetWindowAttributes(x11->display, mRootWin, &attribs);
|
||||
@ -535,7 +537,7 @@ int vo_init(struct vo *vo)
|
||||
mLocalDisplay = 0;
|
||||
mp_msg(MSGT_VO, MSGL_V,
|
||||
"vo: X11 running at %dx%d with depth %d and %d bpp (\"%s\" => %s display)\n",
|
||||
vo_screenwidth, vo_screenheight, depth, x11->depthonscreen,
|
||||
opts->vo_screenwidth, opts->vo_screenheight, depth, x11->depthonscreen,
|
||||
dispName, mLocalDisplay ? "local" : "remote");
|
||||
|
||||
vo_wm_type = vo_wm_detect(vo);
|
||||
@ -1021,6 +1023,7 @@ static int mouse_waiting_hide;
|
||||
|
||||
int vo_x11_check_events(struct vo *vo)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
Display *display = vo->x11->display;
|
||||
int ret = 0;
|
||||
XEvent Event;
|
||||
@ -1054,8 +1057,8 @@ int vo_x11_check_events(struct vo *vo)
|
||||
ret |= VO_EVENT_EXPOSE;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
// if (!vo_fs && (Event.xconfigure.width == vo_screenwidth || Event.xconfigure.height == vo_screenheight)) break;
|
||||
// if (vo_fs && Event.xconfigure.width != vo_screenwidth && Event.xconfigure.height != vo_screenheight) break;
|
||||
// if (!vo_fs && (Event.xconfigure.width == opts->vo_screenwidth || Event.xconfigure.height == opts->vo_screenheight)) break;
|
||||
// if (vo_fs && Event.xconfigure.width != opts->vo_screenwidth && Event.xconfigure.height != opts->vo_screenheight) break;
|
||||
if (vo_window == None)
|
||||
break;
|
||||
vo->dwidth = Event.xconfigure.width;
|
||||
@ -1346,14 +1349,15 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
||||
void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
|
||||
int img_width, int img_height, int use_fs)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
Display *mDisplay = vo->x11->display;
|
||||
int u_dheight, u_dwidth, left_ov, left_ov2;
|
||||
|
||||
if (!f_gc)
|
||||
return;
|
||||
|
||||
u_dheight = use_fs ? vo_screenheight : vo->dheight;
|
||||
u_dwidth = use_fs ? vo_screenwidth : vo->dwidth;
|
||||
u_dheight = use_fs ? opts->vo_screenheight : vo->dheight;
|
||||
u_dwidth = use_fs ? opts->vo_screenwidth : vo->dwidth;
|
||||
if ((u_dheight <= img_height) && (u_dwidth <= img_width))
|
||||
return;
|
||||
|
||||
@ -1375,14 +1379,15 @@ void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
|
||||
XFlush(mDisplay);
|
||||
}
|
||||
|
||||
void vo_x11_clearwindow(Display * mDisplay, Window vo_window)
|
||||
void vo_x11_clearwindow(struct vo *vo, Window vo_window)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
if (!f_gc)
|
||||
return;
|
||||
XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, vo_screenwidth,
|
||||
vo_screenheight);
|
||||
XFillRectangle(vo->x11->display, vo_window, f_gc, 0, 0,
|
||||
opts->vo_screenwidth, opts->vo_screenheight);
|
||||
//
|
||||
XFlush(mDisplay);
|
||||
XFlush(vo->x11->display);
|
||||
}
|
||||
|
||||
|
||||
@ -1555,8 +1560,8 @@ void vo_x11_fullscreen(struct vo *vo)
|
||||
update_xinerama_info(vo);
|
||||
x = xinerama_x;
|
||||
y = xinerama_y;
|
||||
w = vo_screenwidth;
|
||||
h = vo_screenheight;
|
||||
w = opts->vo_screenwidth;
|
||||
h = opts->vo_screenheight;
|
||||
}
|
||||
{
|
||||
long dummy;
|
||||
@ -1766,6 +1771,7 @@ void vo_x11_selectinput_witherr(Display * display, Window w,
|
||||
void vo_vm_switch(struct vo *vo, uint32_t X, uint32_t Y, int *modeline_width,
|
||||
int *modeline_height)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
Display *mDisplay = vo->x11->display;
|
||||
int vm_event, vm_error;
|
||||
int vm_ver, vm_rev;
|
||||
@ -1808,14 +1814,16 @@ void vo_vm_switch(struct vo *vo, uint32_t X, uint32_t Y, int *modeline_width,
|
||||
XF86VidModeLockModeSwitch(mDisplay, mScreen, 0);
|
||||
XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
|
||||
XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
|
||||
X = (vo_screenwidth - *modeline_width) / 2;
|
||||
Y = (vo_screenheight - *modeline_height) / 2;
|
||||
X = (opts->vo_screenwidth - *modeline_width) / 2;
|
||||
Y = (opts->vo_screenheight - *modeline_height) / 2;
|
||||
XF86VidModeSetViewPort(mDisplay, mScreen, X, Y);
|
||||
}
|
||||
}
|
||||
|
||||
void vo_vm_close(Display * dpy)
|
||||
void vo_vm_close(struct vo *vo)
|
||||
{
|
||||
Display *dpy = vo->x11->display;
|
||||
struct MPOpts *opts = vo->opts;
|
||||
#ifdef HAVE_NEW_GUI
|
||||
if (vidmodes != NULL && vo_window != None)
|
||||
#else
|
||||
@ -1832,12 +1840,12 @@ void vo_vm_close(Display * dpy)
|
||||
XF86VidModeGetAllModeLines(dpy, mScreen, &modecount,
|
||||
&vidmodes);
|
||||
for (i = 0; i < modecount; i++)
|
||||
if ((vidmodes[i]->hdisplay == vo_screenwidth)
|
||||
&& (vidmodes[i]->vdisplay == vo_screenheight))
|
||||
if ((vidmodes[i]->hdisplay == opts->vo_screenwidth)
|
||||
&& (vidmodes[i]->vdisplay == opts->vo_screenheight))
|
||||
{
|
||||
mp_msg(MSGT_VO, MSGL_INFO,
|
||||
"Returning to original mode %dx%d\n",
|
||||
vo_screenwidth, vo_screenheight);
|
||||
opts->vo_screenwidth, opts->vo_screenheight);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2456,6 +2464,7 @@ int vo_xv_init_colorkey(struct vo *vo)
|
||||
void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y,
|
||||
int32_t w, int32_t h)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
if( xv_ck_info.method == CK_METHOD_MANUALFILL ||
|
||||
xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
|
||||
@ -2475,19 +2484,19 @@ void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y,
|
||||
if ( y > 0 )
|
||||
XFillRectangle(x11->display, vo_window, vo_gc,
|
||||
0, 0,
|
||||
vo_screenwidth, y);
|
||||
opts->vo_screenwidth, y);
|
||||
if (x > 0)
|
||||
XFillRectangle(x11->display, vo_window, vo_gc,
|
||||
0, 0,
|
||||
x, vo_screenheight);
|
||||
if (x + w < vo_screenwidth)
|
||||
x, opts->vo_screenheight);
|
||||
if (x + w < opts->vo_screenwidth)
|
||||
XFillRectangle(x11->display, vo_window, vo_gc,
|
||||
x + w, 0,
|
||||
vo_screenwidth, vo_screenheight);
|
||||
if (y + h < vo_screenheight)
|
||||
opts->vo_screenwidth, opts->vo_screenheight);
|
||||
if (y + h < opts->vo_screenheight)
|
||||
XFillRectangle(x11->display, vo_window, vo_gc,
|
||||
0, y + h,
|
||||
vo_screenwidth, vo_screenheight);
|
||||
opts->vo_screenwidth, opts->vo_screenheight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
|
||||
Colormap col_map, const char *classname, const char *title);
|
||||
void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
|
||||
int img_width, int img_height, int use_fs);
|
||||
extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
|
||||
void vo_x11_clearwindow(struct vo *vo, Window vo_window);
|
||||
void vo_x11_ontop(struct vo *vo);
|
||||
void vo_x11_ewmh_fullscreen(Display *mDisplay, int action);
|
||||
|
||||
@ -113,7 +113,7 @@ int xv_test_ckm( void * arg );
|
||||
|
||||
#ifdef HAVE_XF86VM
|
||||
void vo_vm_switch(struct vo *vo, uint32_t, uint32_t, int*, int*);
|
||||
void vo_vm_close(Display*);
|
||||
void vo_vm_close(struct vo *vo);
|
||||
#endif
|
||||
|
||||
void update_xinerama_info(struct vo *vo);
|
||||
@ -142,6 +142,8 @@ int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return)
|
||||
#define vo_xv_init_colorkey() vo_xv_init_colorkey(global_vo)
|
||||
#define vo_xv_draw_colorkey(...) vo_xv_draw_colorkey(global_vo, __VA_ARGS__)
|
||||
#define vo_x11_clearwindow_part(display, ...) vo_x11_clearwindow_part(global_vo, __VA_ARGS__)
|
||||
#define vo_vm_close(display) vo_vm_close(global_vo)
|
||||
#define vo_x11_clearwindow(display, window) vo_x11_clearwindow(global_vo, window)
|
||||
|
||||
#define mDisplay global_vo->x11->display
|
||||
#define vo_depthonscreen global_vo->x11->depthonscreen
|
||||
|
Loading…
Reference in New Issue
Block a user