mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 04:44:32 +01:00
Added support for X style -geometry options (adapted from Henk's patch)
-- Mark git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8746 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
659dd449be
commit
0842caf6f0
@ -1296,14 +1296,18 @@ See also \-zoom.
|
||||
.B \-fsmode-dontuse <0-31> (OBSOLETE) (use \-fs option)
|
||||
Try this option if you still experience fullscreen problems.
|
||||
.TP
|
||||
.B \-geometry x[%][:y[%]]
|
||||
.B \-geometry x[%][:y[%]] or [WxH][+x+y]
|
||||
Adjust where the output is on the screen initially.
|
||||
The x and y specifications are in pixels measured from the top-right of the
|
||||
screen to the top-right of the image being displayed, however if a percentage
|
||||
sign is given after the argument it turns the value into a percentage of the
|
||||
screen size in that direction.
|
||||
screen size in that direction. It also supports the standard option format to
|
||||
the standard X \-geometry option.
|
||||
The values given must be integers.
|
||||
|
||||
Note: This option is only supported by a few vo's, including tdfxfb, fbdev and
|
||||
xv.
|
||||
|
||||
.I EXAMPLE:
|
||||
.PD 0
|
||||
.RSs
|
||||
|
@ -4,80 +4,58 @@
|
||||
#include "../mp_msg.h"
|
||||
#include "../mplayer.h" /* exit_player() */
|
||||
#include <string.h>
|
||||
#include <stdlib.h> /* strtol */
|
||||
|
||||
/* A string of the form xpos[%]:ypos[%] */
|
||||
/* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */
|
||||
char *vo_geometry = NULL;
|
||||
|
||||
int geometry_error()
|
||||
{
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "-geometry option format incorrect (%s)\n", vo_geometry);
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
|
||||
exit_player(NULL); /* ????? what else could we do ? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_num(char *s, int *num, char *end)
|
||||
// A little kludge as to not to have to update all drivers
|
||||
// Only the vo_xv driver supports now the full [WxH][+X+Y] option
|
||||
int geometryFull(int *pwidth, int *pheight, int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh)
|
||||
{
|
||||
char *e;
|
||||
long int t;
|
||||
int width, height, xoff, yoff, xper, yper;
|
||||
|
||||
t = strtol(s, &e, 10);
|
||||
width = height = xoff = yoff = xper = yper = -1;
|
||||
|
||||
if(e != end)
|
||||
return 0;
|
||||
/* no need to save a few extra cpu cycles here ;) */
|
||||
/* PUKE i will rewrite this code sometime maybe - euck but it works */
|
||||
if(vo_geometry != NULL) {
|
||||
if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 &&
|
||||
sscanf(vo_geometry, "%ix%i", &width, &height) != 2 &&
|
||||
sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2 &&
|
||||
sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2 &&
|
||||
sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2 &&
|
||||
sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2 &&
|
||||
sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2 &&
|
||||
sscanf(vo_geometry, "%i%%", &xper) != 1)
|
||||
return geometry_error();
|
||||
}
|
||||
|
||||
*num = t;
|
||||
if(xper >= 0 && xper <= 100) xoff = (scrw - vidw) * ((float)xper / 100.0);
|
||||
if(yper >= 0 && yper <= 100) yoff = (scrh - vidh) * ((float)yper / 100.0);
|
||||
|
||||
/* FIXME: better checking of bounds... */
|
||||
if(width < 0 || width > scrw) width = vidw;
|
||||
if(height < 0 || height > scrh) height = vidh;
|
||||
if(xoff < 0 || xoff + vidw > scrw) xoff = 0;
|
||||
if(yoff < 0 || yoff + vidh > scrh) yoff = 0;
|
||||
|
||||
if(xpos) *xpos = xoff;
|
||||
if(ypos) *ypos = yoff;
|
||||
if(pwidth) *pwidth = width;
|
||||
if(pheight) *pheight = height;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh, int fs)
|
||||
// compatibility function
|
||||
// only libvo working with full geometry options.
|
||||
int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh)
|
||||
{
|
||||
int xper = 0, yper = 0;
|
||||
int glen;
|
||||
char *colpos;
|
||||
|
||||
*xpos = 0; *ypos = 0;
|
||||
|
||||
if(vo_geometry == NULL)
|
||||
return 1;
|
||||
|
||||
glen = strlen(vo_geometry);
|
||||
colpos = strchr(vo_geometry, ':');
|
||||
if(colpos == NULL)
|
||||
colpos = (char *)(vo_geometry + glen);
|
||||
|
||||
/* Parse the x bit */
|
||||
if(colpos[-1] == '%') {
|
||||
if(!get_num(vo_geometry, &xper, colpos - 1))
|
||||
return geometry_error();
|
||||
} else {
|
||||
if(!get_num(vo_geometry, xpos, colpos))
|
||||
return geometry_error();
|
||||
}
|
||||
|
||||
if(*colpos != '\0') {
|
||||
if(vo_geometry[glen - 1] == '%') {
|
||||
if(!get_num(colpos + 1, &yper, vo_geometry + glen - 1))
|
||||
return geometry_error();
|
||||
} else {
|
||||
if(!get_num(colpos + 1, ypos, vo_geometry + glen))
|
||||
return geometry_error();
|
||||
}
|
||||
}
|
||||
|
||||
if(xper)
|
||||
*xpos = (scrw - vidw) * ((float)xper / 100.0);
|
||||
if(yper)
|
||||
*ypos = (scrh - vidh) * ((float)yper / 100.0);
|
||||
|
||||
if(*xpos + vidw > scrw) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "X position is too large\n");
|
||||
return geometry_error();
|
||||
}
|
||||
if(*ypos + vidh > scrh) {
|
||||
mp_msg(MSGT_VO, MSGL_ERR, "Y position is too large\n");
|
||||
return geometry_error();
|
||||
}
|
||||
|
||||
return 1;
|
||||
return geometryFull(NULL, NULL, xpos, ypos, scrw, scrh, vidw, vidh);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define __GEOMETRY_H
|
||||
|
||||
extern char *vo_geometry;
|
||||
int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh, int fs);
|
||||
int geometryFull(int *pwidth, int *pheight, int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh);
|
||||
int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh);
|
||||
|
||||
#endif /* !__GEOMETRY_H */
|
||||
|
@ -1039,7 +1039,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||
image_width=width;
|
||||
image_height=height;
|
||||
}
|
||||
geometry(&x_offset,&y_offset,fb_xres,fb_yres,image_width,image_height,fs);
|
||||
geometry(&x_offset,&y_offset,fb_xres,fb_yres,image_width,image_height);
|
||||
|
||||
if(vidix_init(width,height,x_offset,y_offset,image_width,
|
||||
image_height,format,fb_bpp,
|
||||
@ -1063,7 +1063,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||
return 1;
|
||||
}
|
||||
|
||||
geometry(&x_offset,&y_offset,fb_xres,fb_yres,out_width,out_height,fs);
|
||||
geometry(&x_offset,&y_offset,fb_xres,fb_yres,out_width,out_height);
|
||||
|
||||
L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size /
|
||||
2 + ( (out_height - in_height) / 2 ) * fb_line_len +
|
||||
|
@ -204,7 +204,7 @@ static void clear_screen()
|
||||
static void setup_screen(uint32_t full)
|
||||
{
|
||||
aspect(&vidwidth, &vidheight, full ? A_ZOOM : A_NOZOOM);
|
||||
geometry(&vidx, &vidy, screenwidth, screenheight, vidwidth, vidheight, full);
|
||||
geometry(&vidx, &vidy, screenwidth, screenheight, vidwidth, vidheight);
|
||||
vo_fs = full;
|
||||
clear_screen();
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32
|
||||
vo_mouse_autohide=1;
|
||||
|
||||
vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2;
|
||||
geometry(&vo_dx, &vo_dy, vo_screenwidth, vo_screenheight, d_width, d_height,0);
|
||||
geometry(&vo_dx, &vo_dy, vo_screenwidth, vo_screenheight, d_width, d_height);
|
||||
vo_dwidth=d_width; vo_dheight=d_height;
|
||||
|
||||
#ifdef HAVE_XF86VM
|
||||
|
@ -110,6 +110,8 @@ play_tree_iter_t* playtree_iter = NULL;
|
||||
// Config
|
||||
//**************************************************************************//
|
||||
|
||||
#include "libvo/geometry.h"
|
||||
|
||||
m_config_t* mconfig;
|
||||
|
||||
#ifdef NEW_CONFIG
|
||||
@ -698,6 +700,9 @@ int gui_no_filename=0;
|
||||
if(m_config_parse_command_line(mconfig, argc, argv) < 0) exit(1); // error parsing cmdline
|
||||
#endif
|
||||
|
||||
geometryFull(&opt_screen_size_x, &opt_screen_size_y, NULL, NULL,
|
||||
vo_screenwidth, vo_screenheight, vo_screenwidth, vo_screenheight);
|
||||
|
||||
playtree = play_tree_cleanup(playtree);
|
||||
if(playtree) {
|
||||
playtree_iter = play_tree_iter_new(playtree,mconfig);
|
||||
|
Loading…
x
Reference in New Issue
Block a user