2008-09-07 16:09:51 +02: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 18:52:54 +02:00
|
|
|
|
2003-02-02 03:42:59 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-03-31 18:16:12 +02:00
|
|
|
#include <limits.h>
|
2002-10-23 18:52:54 +02:00
|
|
|
#include "geometry.h"
|
2012-11-09 01:06:43 +01:00
|
|
|
#include "core/mp_msg.h"
|
2002-10-23 18:52:54 +02:00
|
|
|
|
2003-01-03 21:46:44 +01:00
|
|
|
/* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */
|
2010-02-02 22:18:21 +01:00
|
|
|
char *vo_geometry;
|
2003-10-15 17:17:09 +02:00
|
|
|
// set when either width or height is changed
|
2010-02-02 22:18:21 +01:00
|
|
|
int geometry_wh_changed;
|
|
|
|
int geometry_xy_changed;
|
2002-10-23 18:52:54 +02:00
|
|
|
|
2003-03-02 22:09:15 +01:00
|
|
|
// xpos,ypos: position of the left upper corner
|
|
|
|
// widw,widh: width and height of the window
|
2009-05-13 04:58:57 +02:00
|
|
|
// scrw,scrh: width and height of the current screen
|
2003-03-02 22:09:15 +01:00
|
|
|
int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh)
|
2002-10-23 18:52:54 +02:00
|
|
|
{
|
2003-01-03 21:46:44 +01:00
|
|
|
if(vo_geometry != NULL) {
|
2010-06-01 22:12:58 +02:00
|
|
|
char xsign[2], ysign[2], dummy[2];
|
2010-03-03 21:24:46 +01:00
|
|
|
int width, height, xoff, yoff, xper, yper;
|
|
|
|
int i;
|
|
|
|
int ok = 0;
|
2010-06-05 08:28:58 +02:00
|
|
|
for (i = 0; !ok && i < 9; i++) {
|
2010-03-03 21:24:46 +01:00
|
|
|
width = height = xoff = yoff = xper = yper = INT_MIN;
|
2010-03-03 21:57:56 +01:00
|
|
|
strcpy(xsign, "+");
|
|
|
|
strcpy(ysign, "+");
|
2010-03-03 21:24:46 +01:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%ix%i%1[+-]%i%1[+-]%i%c",
|
|
|
|
&width, &height, xsign, &xoff, ysign,
|
|
|
|
&yoff, dummy) == 6;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%ix%i%c", &width, &height, dummy) == 2;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%1[+-]%i%1[+-]%i%c",
|
|
|
|
xsign, &xoff, ysign, &yoff, dummy) == 4;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%i%%:%i%1[%]%c", &xper, &yper, dummy, dummy) == 3;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%i:%i%1[%]%c", &xoff, &yper, dummy, dummy) == 3;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%i%%:%i%c", &xper, &yoff, dummy) == 2;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%i:%i%c", &xoff, &yoff, dummy) == 2;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2010-06-01 22:12:58 +02:00
|
|
|
ok = sscanf(vo_geometry, "%i%1[%]%c", &xper, dummy, dummy) == 2;
|
2010-03-03 21:24:46 +01:00
|
|
|
break;
|
2010-06-05 08:28:58 +02:00
|
|
|
case 8:
|
|
|
|
ok = sscanf(vo_geometry, "%i%c", &xoff, dummy) == 1;
|
|
|
|
break;
|
2010-03-03 21:24:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ok) {
|
2003-08-31 20:33:02 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR,
|
2010-03-03 21:57:56 +01:00
|
|
|
"-geometry must be in [WxH][[+-]X[+-]Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
|
2003-08-31 20:33:02 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2002-10-23 18:52:54 +02:00
|
|
|
|
2010-03-03 22:01:57 +01: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 22:09:15 +01:00
|
|
|
mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i,"
|
2010-03-03 21:57:56 +01: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 04:58:57 +02:00
|
|
|
|
2012-10-30 18:09:14 +01:00
|
|
|
if (width > 0) *widw = width;
|
|
|
|
if (height > 0) *widh = height;
|
2010-03-03 22:01:57 +01:00
|
|
|
|
2010-03-03 21:57:56 +01:00
|
|
|
if(xoff != INT_MIN && xsign[0] == '-') xoff = scrw - *widw - xoff;
|
|
|
|
if(yoff != INT_MIN && ysign[0] == '-') yoff = scrh - *widh - yoff;
|
2003-03-02 22:09:15 +01: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 14:12:13 +01:00
|
|
|
|
2003-04-20 17:09:19 +02: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 04:58:57 +02:00
|
|
|
|
2009-03-31 18:16:12 +02:00
|
|
|
if (xoff != INT_MIN && xpos) *xpos = xoff;
|
|
|
|
if (yoff != INT_MIN && ypos) *ypos = yoff;
|
2003-01-04 14:12:13 +01:00
|
|
|
|
2010-02-02 22:18:21 +01:00
|
|
|
geometry_wh_changed = width > 0 || height > 0;
|
|
|
|
geometry_xy_changed = xoff != INT_MIN || yoff != INT_MIN;
|
2003-01-04 14:11:18 +01:00
|
|
|
}
|
2002-10-23 18:52:54 +02:00
|
|
|
return 1;
|
|
|
|
}
|