Mercurial > mplayer.hg
annotate libvo/geometry.c @ 29439:02dec439f717
100l, av_fifo_generic_read does not return anything useful, so ignore its
return value and return len instead.
author | reimar |
---|---|
date | Sat, 08 Aug 2009 08:17:35 +0000 |
parents | a5c49ea5059a |
children | 201c9a709547 |
rev | line source |
---|---|
27509
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
1 /* |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
2 * copyright (C) 2002 Mark Zealey <mark@zealos.org> |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
3 * |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
4 * This file is part of MPlayer. |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
5 * |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
6 * MPlayer is free software; you can redistribute it and/or modify |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
9 * (at your option) any later version. |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
10 * |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
11 * MPlayer is distributed in the hope that it will be useful, |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
14 * GNU General Public License for more details. |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
15 * |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d97a607821f1
Replace casual GPL notices by proper license headers.
diego
parents:
15058
diff
changeset
|
19 */ |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
20 |
9217
420e2b2f8e5a
compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
8768
diff
changeset
|
21 #include <stdio.h> |
420e2b2f8e5a
compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
8768
diff
changeset
|
22 #include <string.h> |
29073
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
23 #include <limits.h> |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
24 #include "geometry.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
11996
diff
changeset
|
25 #include "mp_msg.h" |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
26 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
27 /* A string of the form [WxH][+X+Y] or xpos[%]:ypos[%] */ |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
28 char *vo_geometry = NULL; |
11125 | 29 // set when either width or height is changed |
30 int geometry_wh_changed = 0; | |
11996
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
31 int geometry_xy_changed = 0; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
32 |
29349
26347e1dc763
100l, RESET_GEOMETRY must reset values to INT_MIN, not -1, -1 is a
reimar
parents:
29263
diff
changeset
|
33 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = INT_MIN; |
9517 | 34 |
35 // xpos,ypos: position of the left upper corner | |
36 // widw,widh: width and height of the window | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29073
diff
changeset
|
37 // scrw,scrh: width and height of the current screen |
9517 | 38 int geometry(int *xpos, int *ypos, int *widw, int *widh, int scrw, int scrh) |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
39 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
40 int width, height, xoff, yoff, xper, yper; |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
41 |
29350
a5c49ea5059a
Use the RESET_GEOMETRY macro in one more place instead of duplicating its code.
reimar
parents:
29349
diff
changeset
|
42 RESET_GEOMETRY |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
43 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
44 if(vo_geometry != NULL) { |
9517 | 45 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) |
46 { | |
47 RESET_GEOMETRY | |
48 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) | |
49 { | |
50 RESET_GEOMETRY | |
51 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) | |
52 { | |
14678
58f061d12c83
Fix the behaviour of -geometry according to the documentation.
al
parents:
13787
diff
changeset
|
53 char percent[2]; |
9517 | 54 RESET_GEOMETRY |
15058 | 55 if(sscanf(vo_geometry, "%i%%:%i%1[%]", &xper, &yper, percent) != 3) |
9517 | 56 { |
57 RESET_GEOMETRY | |
15058 | 58 if(sscanf(vo_geometry, "%i:%i%1[%]", &xoff, &yper, percent) != 3) |
9517 | 59 { |
60 RESET_GEOMETRY | |
14678
58f061d12c83
Fix the behaviour of -geometry according to the documentation.
al
parents:
13787
diff
changeset
|
61 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) != 2) |
9517 | 62 { |
63 RESET_GEOMETRY | |
14678
58f061d12c83
Fix the behaviour of -geometry according to the documentation.
al
parents:
13787
diff
changeset
|
64 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) |
9517 | 65 { |
66 RESET_GEOMETRY | |
15058 | 67 if(sscanf(vo_geometry, "%i%1[%]", &xper, percent) != 2) |
10734 | 68 { |
69 mp_msg(MSGT_VO, MSGL_ERR, | |
70 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | |
71 return 0; | |
72 } | |
9517 | 73 } |
74 } | |
75 } | |
76 } | |
77 } | |
78 } | |
79 } | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
80 |
9517 | 81 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
9947 | 82 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", |
9517 | 83 width, height, xoff, yoff, xper, yper); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29073
diff
changeset
|
84 |
9517 | 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); | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
87 |
9947 | 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); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29073
diff
changeset
|
93 |
29073
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
94 if (xoff != INT_MIN && xpos) *xpos = xoff; |
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
95 if (yoff != INT_MIN && ypos) *ypos = yoff; |
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
96 if (width > 0 && widw) *widw = width; |
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
97 if (height > 0 && widh) *widh = height; |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
98 |
29073
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
99 if (width > 0 || height > 0) |
11125 | 100 geometry_wh_changed = 1; |
29073
a5f19a8ecc86
Get rid of nonsensical limits on -geometry x, y,w and h values, they only
reimar
parents:
27509
diff
changeset
|
101 if (xoff != INT_MIN || yoff != INT_MIN) |
11996
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
102 geometry_xy_changed = 1; |
8767 | 103 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
104 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
105 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
106 |
9517 | 107 #undef RESET_GEOMETRY |