Mercurial > mplayer.hg
changeset 30780:0ab92d0c1901
Add support for specifying window position relative to right and bottom
screen borders with -geometry.
Based on patch by Melchior FRANZ [melchior franz gmail com].
author | reimar |
---|---|
date | Wed, 03 Mar 2010 20:57:56 +0000 |
parents | 106543495f5b |
children | 1b4d24af52a7 |
files | DOCS/man/en/mplayer.1 libvo/geometry.c |
diffstat | 2 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1 Wed Mar 03 20:36:35 2010 +0000 +++ b/DOCS/man/en/mplayer.1 Wed Mar 03 20:57:56 2010 +0000 @@ -3143,13 +3143,16 @@ .PD 1 . .TP -.B \-geometry x[%][:y[%]] or [WxH][+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-left of the screen to the top-left 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. -It also supports the standard X11 \-geometry option format. +It also supports the standard X11 \-geometry option format, in which e.g. ++10-50 means "place 10 pixels from the left border and 50 pixels from the lower +border" and "--20+-10" means "place 20 pixels beyond the right and 10 pixels +beyond the top border". If an external window is specified using the \-wid option, then the x and y coordinates are relative to the top-left corner of the window rather than the screen.
--- a/libvo/geometry.c Wed Mar 03 20:36:35 2010 +0000 +++ b/libvo/geometry.c Wed Mar 03 20:57:56 2010 +0000 @@ -36,20 +36,23 @@ int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) { if(vo_geometry != NULL) { + char xsign[2], ysign[2]; int width, height, xoff, yoff, xper, yper; int i; int ok = 0; for (i = 0; !ok && i < 8; i++) { width = height = xoff = yoff = xper = yper = INT_MIN; + strcpy(xsign, "+"); + strcpy(ysign, "+"); switch (i) { case 0: - ok = sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) == 4; + ok = sscanf(vo_geometry, "%ix%i%1[+-]%i%1[+-]%i", &width, &height, xsign, &xoff, ysign, &yoff) == 6; break; case 1: ok = sscanf(vo_geometry, "%ix%i", &width, &height) == 2; break; case 2: - ok = sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) == 2; + ok = sscanf(vo_geometry, "%1[+-]%i%1[+-]%i", xsign, &xoff, ysign, &yoff) == 4; break; case 3: ok = sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) == 2; @@ -70,14 +73,16 @@ } if (!ok) { mp_msg(MSGT_VO, MSGL_ERR, - "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); + "-geometry must be in [WxH][[+-]X[+-]Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); return 0; } mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," - "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", - width, height, xoff, yoff, xper, yper); + "height: %i, xoff: %s%i, yoff: %s%i, xper: %i, yper: %i\n", + width, height, xsign, xoff, ysign, yoff, xper, yper); + if(xoff != INT_MIN && xsign[0] == '-') xoff = scrw - *widw - xoff; + if(yoff != INT_MIN && ysign[0] == '-') yoff = scrh - *widh - yoff; if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0);