Mercurial > mplayer.hg
annotate libvo/geometry.c @ 22884:3f571edb7550
restored previous definition of -mpegopts :drop and :tsaf (r22900); they were there for a good reason
author | nicodvb |
---|---|
date | Sun, 01 Apr 2007 21:54:18 +0000 |
parents | f48dc20c9185 |
children | d97a607821f1 |
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" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
11996
diff
changeset
|
6 #include "mp_msg.h" |
7866
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; | |
11996
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
12 int geometry_xy_changed = 0; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
13 |
9517 | 14 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1; |
15 | |
16 // xpos,ypos: position of the left upper corner | |
17 // widw,widh: width and height of the window | |
18 // scrw,scrh: width and height of the current screen | |
19 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
|
20 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
21 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
|
22 |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
23 width = height = xoff = yoff = xper = yper = -1; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
24 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
25 if(vo_geometry != NULL) { |
9517 | 26 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) |
27 { | |
28 RESET_GEOMETRY | |
29 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) | |
30 { | |
31 RESET_GEOMETRY | |
32 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) | |
33 { | |
14678
58f061d12c83
Fix the behaviour of -geometry according to the documentation.
al
parents:
13787
diff
changeset
|
34 char percent[2]; |
9517 | 35 RESET_GEOMETRY |
15058 | 36 if(sscanf(vo_geometry, "%i%%:%i%1[%]", &xper, &yper, percent) != 3) |
9517 | 37 { |
38 RESET_GEOMETRY | |
15058 | 39 if(sscanf(vo_geometry, "%i:%i%1[%]", &xoff, &yper, percent) != 3) |
9517 | 40 { |
41 RESET_GEOMETRY | |
14678
58f061d12c83
Fix the behaviour of -geometry according to the documentation.
al
parents:
13787
diff
changeset
|
42 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yoff) != 2) |
9517 | 43 { |
44 RESET_GEOMETRY | |
14678
58f061d12c83
Fix the behaviour of -geometry according to the documentation.
al
parents:
13787
diff
changeset
|
45 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) |
9517 | 46 { |
47 RESET_GEOMETRY | |
15058 | 48 if(sscanf(vo_geometry, "%i%1[%]", &xper, percent) != 2) |
10734 | 49 { |
50 mp_msg(MSGT_VO, MSGL_ERR, | |
51 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | |
52 return 0; | |
53 } | |
9517 | 54 } |
55 } | |
56 } | |
57 } | |
58 } | |
59 } | |
60 } | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
61 |
9517 | 62 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
9947 | 63 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", |
9517 | 64 width, height, xoff, yoff, xper, yper); |
65 | |
66 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); | |
67 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
|
68 |
9947 | 69 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
70 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", | |
71 width, height, xoff, yoff, xper, yper); | |
72 mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i," | |
73 " widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh); | |
74 | |
8768 | 75 /* FIXME: better checking of bounds... */ |
11125 | 76 if( width != -1 && (width < 0 || width > scrw)) |
77 width = (scrw < *widw) ? scrw : *widw; | |
78 if( height != -1 && (height < 0 || height > scrh)) | |
79 height = (scrh < *widh) ? scrh : *widh; | |
80 if(xoff != -1 && (xoff < 0 || xoff + width > scrw)) xoff = 0; | |
81 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
|
82 |
11125 | 83 if(xoff != -1 && xpos) *xpos = xoff; |
84 if(yoff != -1 && ypos) *ypos = yoff; | |
85 if(width != -1 && widw) *widw = width; | |
86 if(height != -1 && widh) *widh = height; | |
87 | |
88 if( width != -1 || height != -1) | |
89 geometry_wh_changed = 1; | |
11996
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
90 if( xoff != -1 || yoff != -1) |
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
91 geometry_xy_changed = 1; |
8767 | 92 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
93 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
94 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
95 |
9517 | 96 #undef RESET_GEOMETRY |