summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-03-03 20:57:56 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-03-03 20:57:56 +0000
commit90188f0e5fce3948dde3d89a409804c492f8375b (patch)
tree78b43d954eda94918997f97b1ae15ffddc64e04f
parent0833aaa64d0a933b3d65d00643f0b737683c2801 (diff)
downloadmpv-90188f0e5fce3948dde3d89a409804c492f8375b.tar.bz2
mpv-90188f0e5fce3948dde3d89a409804c492f8375b.tar.xz
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]. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30822 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--DOCS/man/en/mplayer.17
-rw-r--r--libvo/geometry.c15
2 files changed, 15 insertions, 7 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 0f3bfb1e95..cf89c3ba70 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -3143,13 +3143,16 @@ Fixes fullscreen switching on OpenBox 1.x.
.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.
diff --git a/libvo/geometry.c b/libvo/geometry.c
index 7576f9feb4..6653373976 100644
--- a/libvo/geometry.c
+++ b/libvo/geometry.c
@@ -36,20 +36,23 @@ int geometry_xy_changed;
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 @@ int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh)
}
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);