2008-09-07 14:09:51 +00:00
|
|
|
/*
|
|
|
|
* copyright (C) 2002 Mark Zealey <mark@zealos.org>
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2003-02-02 02:42:59 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-03-31 16:16:12 +00:00
|
|
|
#include <limits.h>
|
2002-10-23 16:52:54 +00:00
|
|
|
#include "geometry.h"
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "mp_msg.h"
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2003-01-03 20:46:44 +00:00
|
|
|
/* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */
|
2010-02-02 21:18:21 +00:00
|
|
|
char *vo_geometry;
|
2003-10-15 15:17:09 +00:00
|
|
|
// set when either width or height is changed
|
2010-02-02 21:18:21 +00:00
|
|
|
int geometry_wh_changed;
|
|
|
|
int geometry_xy_changed;
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2003-03-02 21:09:15 +00:00
|
|
|
// xpos,ypos: position of the left upper corner
|
|
|
|
// widw,widh: width and height of the window
|
2009-05-13 02:58:57 +00:00
|
|
|
// scrw,scrh: width and height of the current screen
|
2003-03-02 21:09:15 +00:00
|
|
|
int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh)
|
2002-10-23 16:52:54 +00:00
|
|
|
{
|
2003-01-03 20:46:44 +00:00
|
|
|
if(vo_geometry != NULL) {
|
2010-06-01 20:12:58 +00:00
|
|
|
char xsign[2], ysign[2], dummy[2];
|
2010-03-03 20:24:46 +00:00
|
|
|
int width, height, xoff, yoff, xper, yper;
|
|
|
|
int i;
|
|
|
|
int ok = 0;
|
2010-06-05 06:28:58 +00:00
|
|
|
for (i = 0; !ok && i < 9; i++) {
|
2010-03-03 20:24:46 +00:00
|
|
|
width = height = xoff = yoff = xper = yper = INT_MIN;
|
2010-03-03 20:57:56 +00:00
|
|
|
strcpy(xsign, "+");
|
|
|
|
strcpy(ysign, "+");
|
2010-03-03 20:24:46 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%ix%i%1[+-]%i%1[+-]%i%c",
|
|
|
|
&width, &height, xsign, &xoff, ysign,
|
|
|
|
&yoff, dummy) == 6;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%ix%i%c", &width, &height, dummy) == 2;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%1[+-]%i%1[+-]%i%c",
|
|
|
|
xsign, &xoff, ysign, &yoff, dummy) == 4;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%i%%:%i%1[%]%c", &xper, &yper, dummy, dummy) == 3;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%i:%i%1[%]%c", &xoff, &yper, dummy, dummy) == 3;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%i%%:%i%c", &xper, &yoff, dummy) == 2;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%i:%i%c", &xoff, &yoff, dummy) == 2;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2010-06-01 20:12:58 +00:00
|
|
|
ok = sscanf(vo_geometry, "%i%1[%]%c", &xper, dummy, dummy) == 2;
|
2010-03-03 20:24:46 +00:00
|
|
|
break;
|
2010-06-05 06:28:58 +00:00
|
|
|
case 8:
|
|
|
|
ok = sscanf(vo_geometry, "%i%c", &xoff, dummy) == 1;
|
|
|
|
break;
|
2010-03-03 20:24:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ok) {
|
2003-08-31 18:33:02 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,
|
2010-03-03 20:57:56 +00:00
|
|
|
"-geometry must be in [WxH][[+-]X[+-]Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
|
2003-08-31 18:33:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2002-10-23 16:52:54 +00:00
|
|
|
|
2010-03-03 21:01:57 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i,"
|
|
|
|
" widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh);
|
|
|
|
|
2003-03-02 21:09:15 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i,"
|
2010-03-03 20:57:56 +00:00
|
|
|
"height: %i, xoff: %s%i, yoff: %s%i, xper: %i, yper: %i\n",
|
|
|
|
width, height, xsign, xoff, ysign, yoff, xper, yper);
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2010-03-03 21:01:57 +00:00
|
|
|
if (width > 0 && widw) *widw = width;
|
|
|
|
if (height > 0 && widh) *widh = height;
|
|
|
|
|
2010-03-03 20:57:56 +00:00
|
|
|
if(xoff != INT_MIN && xsign[0] == '-') xoff = scrw - *widw - xoff;
|
|
|
|
if(yoff != INT_MIN && ysign[0] == '-') yoff = scrh - *widh - yoff;
|
2003-03-02 21:09:15 +00:00
|
|
|
if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0);
|
|
|
|
if(yper >= 0 && yper <= 100) yoff = (scrh - *widh) * ((float)yper / 100.0);
|
2003-01-04 13:12:13 +00:00
|
|
|
|
2003-04-20 15:09:19 +00:00
|
|
|
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);
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2009-03-31 16:16:12 +00:00
|
|
|
if (xoff != INT_MIN && xpos) *xpos = xoff;
|
|
|
|
if (yoff != INT_MIN && ypos) *ypos = yoff;
|
2003-01-04 13:12:13 +00:00
|
|
|
|
2010-02-02 21:18:21 +00:00
|
|
|
geometry_wh_changed = width > 0 || height > 0;
|
|
|
|
geometry_xy_changed = xoff != INT_MIN || yoff != INT_MIN;
|
2003-01-04 13:11:18 +00:00
|
|
|
}
|
2002-10-23 16:52:54 +00:00
|
|
|
return 1;
|
|
|
|
}
|