1 /* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */
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 )
29 if(sscanf(vo_geometry
, "%ix%i", &width
, &height
) != 2)
32 if(sscanf(vo_geometry
, "+%i+%i", &xoff
, &yoff
) != 2)
36 if(sscanf(vo_geometry
, "%i%%:%i%1[%]", &xper
, &yper
, percent
) != 3)
39 if(sscanf(vo_geometry
, "%i:%i%1[%]", &xoff
, &yper
, percent
) != 3)
42 if(sscanf(vo_geometry
, "%i%%:%i", &xper
, &yoff
) != 2)
45 if(sscanf(vo_geometry
, "%i:%i", &xoff
, &yoff
) != 2)
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
);
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;