2 * copyright (C) 2002 Mark Zealey <mark@zealos.org>
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 /* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */
28 char *vo_geometry
= NULL
;
29 // set when either width or height is changed
30 int geometry_wh_changed
= 0;
31 int geometry_xy_changed
= 0;
33 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1;
35 // xpos,ypos: position of the left upper corner
36 // widw,widh: width and height of the window
37 // scrw,scrh: width and height of the current screen
38 int geometry(int *xpos
, int *ypos
, int *widw
, int *widh
, int scrw
, int scrh
)
40 int width
, height
, xoff
, yoff
, xper
, yper
;
42 width
= height
= xoff
= yoff
= xper
= yper
= INT_MIN
;
44 if(vo_geometry
!= NULL
) {
45 if(sscanf(vo_geometry
, "%ix%i+%i+%i", &width
, &height
, &xoff
, &yoff
) != 4 )
48 if(sscanf(vo_geometry
, "%ix%i", &width
, &height
) != 2)
51 if(sscanf(vo_geometry
, "+%i+%i", &xoff
, &yoff
) != 2)
55 if(sscanf(vo_geometry
, "%i%%:%i%1[%]", &xper
, &yper
, percent
) != 3)
58 if(sscanf(vo_geometry
, "%i:%i%1[%]", &xoff
, &yper
, percent
) != 3)
61 if(sscanf(vo_geometry
, "%i%%:%i", &xper
, &yoff
) != 2)
64 if(sscanf(vo_geometry
, "%i:%i", &xoff
, &yoff
) != 2)
67 if(sscanf(vo_geometry
, "%i%1[%]", &xper
, percent
) != 2)
69 mp_msg(MSGT_VO
, MSGL_ERR
,
70 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry
);
81 mp_msg(MSGT_VO
, MSGL_V
,"geometry set to width: %i,"
82 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n",
83 width
, height
, xoff
, yoff
, xper
, yper
);
85 if(xper
>= 0 && xper
<= 100) xoff
= (scrw
- *widw
) * ((float)xper
/ 100.0);
86 if(yper
>= 0 && yper
<= 100) yoff
= (scrh
- *widh
) * ((float)yper
/ 100.0);
88 mp_msg(MSGT_VO
, MSGL_V
,"geometry set to width: %i,"
89 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n",
90 width
, height
, xoff
, yoff
, xper
, yper
);
91 mp_msg(MSGT_VO
, MSGL_V
,"geometry window parameter: widw: %i,"
92 " widh: %i, scrw: %i, scrh: %i\n",*widw
, *widh
, scrw
, scrh
);
94 if (xoff
!= INT_MIN
&& xpos
) *xpos
= xoff
;
95 if (yoff
!= INT_MIN
&& ypos
) *ypos
= yoff
;
96 if (width
> 0 && widw
) *widw
= width
;
97 if (height
> 0 && widh
) *widh
= height
;
99 if (width
> 0 || height
> 0)
100 geometry_wh_changed
= 1;
101 if (xoff
!= INT_MIN
|| yoff
!= INT_MIN
)
102 geometry_xy_changed
= 1;
107 #undef RESET_GEOMETRY