Mercurial > mplayer.hg
annotate libvo/geometry.c @ 11287:5fde9e4e1d17
_ --> - in option names
author | wight |
---|---|
date | Mon, 27 Oct 2003 07:14:32 +0000 |
parents | d9478c8e5ffe |
children | 398c24cecdc7 |
rev | line source |
---|---|
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
1 /* This file (C) Mark Zealey <mark@zealos.org> 2002, released under GPL */ |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
2 |
9217
420e2b2f8e5a
compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
8768
diff
changeset
|
3 #include <stdio.h> |
420e2b2f8e5a
compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
8768
diff
changeset
|
4 #include <string.h> |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
5 #include "geometry.h" |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
6 #include "../mp_msg.h" |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
7 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
8 /* 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
|
9 char *vo_geometry = NULL; |
11125 | 10 // set when either width or height is changed |
11 int geometry_wh_changed = 0; | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
12 |
9517 | 13 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1; |
14 | |
15 // xpos,ypos: position of the left upper corner | |
16 // widw,widh: width and height of the window | |
17 // scrw,scrh: width and height of the current screen | |
18 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
|
19 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
20 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
|
21 |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
22 width = height = xoff = yoff = xper = yper = -1; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
23 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
24 if(vo_geometry != NULL) { |
9517 | 25 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) |
26 { | |
27 RESET_GEOMETRY | |
28 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) | |
29 { | |
30 RESET_GEOMETRY | |
31 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) | |
32 { | |
33 RESET_GEOMETRY | |
34 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) | |
35 { | |
36 RESET_GEOMETRY | |
37 if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2) | |
38 { | |
39 RESET_GEOMETRY | |
40 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2) | |
41 { | |
42 RESET_GEOMETRY | |
43 if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2) | |
44 { | |
45 RESET_GEOMETRY | |
46 if(sscanf(vo_geometry, "%i%%", &xper) != 1) | |
10734 | 47 { |
48 mp_msg(MSGT_VO, MSGL_ERR, | |
49 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | |
50 return 0; | |
51 } | |
9517 | 52 } |
53 } | |
54 } | |
55 } | |
56 } | |
57 } | |
58 } | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
59 |
9517 | 60 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
9947 | 61 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", |
9517 | 62 width, height, xoff, yoff, xper, yper); |
63 | |
64 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); | |
65 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
|
66 |
9947 | 67 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
68 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", | |
69 width, height, xoff, yoff, xper, yper); | |
70 mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i," | |
71 " widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh); | |
72 | |
8768 | 73 /* FIXME: better checking of bounds... */ |
11125 | 74 if( width != -1 && (width < 0 || width > scrw)) |
75 width = (scrw < *widw) ? scrw : *widw; | |
76 if( height != -1 && (height < 0 || height > scrh)) | |
77 height = (scrh < *widh) ? scrh : *widh; | |
78 if(xoff != -1 && (xoff < 0 || xoff + width > scrw)) xoff = 0; | |
79 if(yoff != -1 && (yoff < 0 || yoff + height > scrh)) yoff = 0; | |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
80 |
11125 | 81 if(xoff != -1 && xpos) *xpos = xoff; |
82 if(yoff != -1 && ypos) *ypos = yoff; | |
83 if(width != -1 && widw) *widw = width; | |
84 if(height != -1 && widh) *widh = height; | |
85 | |
86 if( width != -1 || height != -1) | |
87 geometry_wh_changed = 1; | |
8767 | 88 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
89 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
90 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
91 |
9517 | 92 #undef RESET_GEOMETRY |