diff options
author | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-03-02 21:09:15 +0000 |
---|---|---|
committer | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-03-02 21:09:15 +0000 |
commit | 6514fbb0767930249dfb7accdddf5989691f7953 (patch) | |
tree | 6aac625cfc385fb73b5b6a4dfaed4aa7ac0f29b6 /libvo/geometry.c | |
parent | 84e15e6fe4822175cba6181d90f16bfa9620b5b7 (diff) | |
download | mpv-6514fbb0767930249dfb7accdddf5989691f7953.tar.bz2 mpv-6514fbb0767930249dfb7accdddf5989691f7953.tar.xz |
clean up of -geometry code.
disabled -geometry for all but -vo xv (will be fixed later)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9518 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/geometry.c')
-rw-r--r-- | libvo/geometry.c | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/libvo/geometry.c b/libvo/geometry.c index 4f7c45a1a2..c7277cde2c 100644 --- a/libvo/geometry.c +++ b/libvo/geometry.c @@ -16,47 +16,68 @@ int geometry_error() return 0; } -// 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) +#define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1; + +// xpos,ypos: position of the left upper corner +// widw,widh: width and height of the window +// scrw,scrh: width and height of the current screen +int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) { int width, height, xoff, yoff, xper, yper; width = height = xoff = yoff = xper = yper = -1; - /* 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) + if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2) + { + RESET_GEOMETRY + if(sscanf(vo_geometry, "%i%%", &xper) != 1) return geometry_error(); + } + } + } + } + } + } + } - if(xper >= 0 && xper <= 100) xoff = (scrw - vidw) * ((float)xper / 100.0); - if(yper >= 0 && yper <= 100) yoff = (scrh - vidh) * ((float)yper / 100.0); + mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," + "height: %i, xoff: %i, yoff: %i, xper: %1, yper: %i\n", + width, height, xoff, yoff, xper, yper); + + if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); + if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((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(width < 0 || width > scrw) width = *widw; + if(height < 0 || height > scrh) height = *widh; + if(xoff < 0 || xoff + *widw > scrw) xoff = 0; + if(yoff < 0 || yoff + *widh > scrh) yoff = 0; if(xpos) *xpos = xoff; if(ypos) *ypos = yoff; - if(pwidth) *pwidth = width; - if(pheight) *pheight = height; + if(widw) *widw = width; + if(widh) *widh = height; } return 1; } -// compatibility function -// only libvo working with full geometry options. -int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh) -{ - return geometryFull(NULL, NULL, xpos, ypos, scrw, scrh, vidw, vidh); -} +#undef RESET_GEOMETRY |