Mercurial > mplayer.hg
comparison libvo/geometry.c @ 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 |
comparison
equal
deleted
inserted
replaced
30779:106543495f5b | 30780:0ab92d0c1901 |
---|---|
34 // widw,widh: width and height of the window | 34 // widw,widh: width and height of the window |
35 // scrw,scrh: width and height of the current screen | 35 // scrw,scrh: width and height of the current screen |
36 int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) | 36 int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) |
37 { | 37 { |
38 if(vo_geometry != NULL) { | 38 if(vo_geometry != NULL) { |
39 char xsign[2], ysign[2]; | |
39 int width, height, xoff, yoff, xper, yper; | 40 int width, height, xoff, yoff, xper, yper; |
40 int i; | 41 int i; |
41 int ok = 0; | 42 int ok = 0; |
42 for (i = 0; !ok && i < 8; i++) { | 43 for (i = 0; !ok && i < 8; i++) { |
43 width = height = xoff = yoff = xper = yper = INT_MIN; | 44 width = height = xoff = yoff = xper = yper = INT_MIN; |
45 strcpy(xsign, "+"); | |
46 strcpy(ysign, "+"); | |
44 switch (i) { | 47 switch (i) { |
45 case 0: | 48 case 0: |
46 ok = sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) == 4; | 49 ok = sscanf(vo_geometry, "%ix%i%1[+-]%i%1[+-]%i", &width, &height, xsign, &xoff, ysign, &yoff) == 6; |
47 break; | 50 break; |
48 case 1: | 51 case 1: |
49 ok = sscanf(vo_geometry, "%ix%i", &width, &height) == 2; | 52 ok = sscanf(vo_geometry, "%ix%i", &width, &height) == 2; |
50 break; | 53 break; |
51 case 2: | 54 case 2: |
52 ok = sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) == 2; | 55 ok = sscanf(vo_geometry, "%1[+-]%i%1[+-]%i", xsign, &xoff, ysign, &yoff) == 4; |
53 break; | 56 break; |
54 case 3: | 57 case 3: |
55 ok = sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) == 2; | 58 ok = sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) == 2; |
56 break; | 59 break; |
57 case 4: | 60 case 4: |
68 break; | 71 break; |
69 } | 72 } |
70 } | 73 } |
71 if (!ok) { | 74 if (!ok) { |
72 mp_msg(MSGT_VO, MSGL_ERR, | 75 mp_msg(MSGT_VO, MSGL_ERR, |
73 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | 76 "-geometry must be in [WxH][[+-]X[+-]Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); |
74 return 0; | 77 return 0; |
75 } | 78 } |
76 | 79 |
77 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," | 80 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
78 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", | 81 "height: %i, xoff: %s%i, yoff: %s%i, xper: %i, yper: %i\n", |
79 width, height, xoff, yoff, xper, yper); | 82 width, height, xsign, xoff, ysign, yoff, xper, yper); |
80 | 83 |
84 if(xoff != INT_MIN && xsign[0] == '-') xoff = scrw - *widw - xoff; | |
85 if(yoff != INT_MIN && ysign[0] == '-') yoff = scrh - *widh - yoff; | |
81 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); | 86 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); |
82 if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0); | 87 if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0); |
83 | 88 |
84 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," | 89 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
85 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", | 90 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", |