Remove unused static variable pass, fixes the warning:
[mplayer/greg.git] / libvo / geometry.c
blob0d145ee989a132b29eee7ead731e7c8a722a5e76
1 /* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */
3 #include <stdio.h>
4 #include <string.h>
5 #include "geometry.h"
6 #include "mp_msg.h"
8 /* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */
9 char *vo_geometry = NULL;
10 // set when either width or height is changed
11 int geometry_wh_changed = 0;
12 int geometry_xy_changed = 0;
14 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1;
16 // xpos,ypos: position of the left upper corner
17 // widw,widh: width and height of the window
18 // scrw,scrh: width and height of the current screen
19 int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh)
21 int width, height, xoff, yoff, xper, yper;
23 width = height = xoff = yoff = xper = yper = -1;
25 if(vo_geometry != NULL) {
26 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 )
28 RESET_GEOMETRY
29 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2)
31 RESET_GEOMETRY
32 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2)
34 char percent[2];
35 RESET_GEOMETRY
36 if(sscanf(vo_geometry, "%i%%:%i%1[%]", &xper, &yper, percent) != 3)
38 RESET_GEOMETRY
39 if(sscanf(vo_geometry, "%i:%i%1[%]", &xoff, &yper, percent) != 3)
41 RESET_GEOMETRY
42 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) != 2)
44 RESET_GEOMETRY
45 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2)
47 RESET_GEOMETRY
48 if(sscanf(vo_geometry, "%i%1[%]", &xper, percent) != 2)
50 mp_msg(MSGT_VO, MSGL_ERR,
51 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
52 return 0;
62 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i,"
63 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n",
64 width, height, xoff, yoff, xper, yper);
66 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0);
67 if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0);
69 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i,"
70 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n",
71 width, height, xoff, yoff, xper, yper);
72 mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i,"
73 " widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh);
75 /* FIXME: better checking of bounds... */
76 if( width != -1 && (width < 0 || width > scrw))
77 width = (scrw < *widw) ? scrw : *widw;
78 if( height != -1 && (height < 0 || height > scrh))
79 height = (scrh < *widh) ? scrh : *widh;
80 if(xoff != -1 && (xoff < 0 || xoff + width > scrw)) xoff = 0;
81 if(yoff != -1 && (yoff < 0 || yoff + height > scrh)) yoff = 0;
83 if(xoff != -1 && xpos) *xpos = xoff;
84 if(yoff != -1 && ypos) *ypos = yoff;
85 if(width != -1 && widw) *widw = width;
86 if(height != -1 && widh) *widh = height;
88 if( width != -1 || height != -1)
89 geometry_wh_changed = 1;
90 if( xoff != -1 || yoff != -1)
91 geometry_xy_changed = 1;
93 return 1;
96 #undef RESET_GEOMETRY