Mercurial > mplayer.hg
annotate libvo/geometry.c @ 9160:2a67f587c792
Here is updated manual (24.01.2003).
- by imoteph
author | gabucino |
---|---|
date | Wed, 29 Jan 2003 17:23:23 +0000 |
parents | 44b7d4c7e61c |
children | 420e2b2f8e5a |
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 |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
3 #include "geometry.h" |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
4 #include "../mp_msg.h" |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8123
diff
changeset
|
5 #include "../mplayer.h" /* exit_player() */ |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
6 #include <string.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; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
10 |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
11 int geometry_error() |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
12 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
13 mp_msg(MSGT_VO, MSGL_ERR, "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
14 exit_player(NULL); /* ????? what else could we do ? */ |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
15 return 0; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
16 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
17 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
18 // A little kludge as to not to have to update all drivers |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
19 // Only the vo_xv driver supports now the full [WxH][+X+Y] option |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
20 int geometryFull(int *pwidth, int *pheight, int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh) |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
21 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
22 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
|
23 |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
24 width = height = xoff = yoff = xper = yper = -1; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
25 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
26 /* no need to save a few extra cpu cycles here ;) */ |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
27 /* PUKE i will rewrite this code sometime maybe - euck but it works */ |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
28 if(vo_geometry != NULL) { |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
29 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
30 sscanf(vo_geometry, "%ix%i", &width, &height) != 2 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
31 sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
32 sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
33 sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
34 sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
35 sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2 && |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
36 sscanf(vo_geometry, "%i%%", &xper) != 1) |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
37 return geometry_error(); |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
38 |
8768 | 39 if(xper >= 0 && xper <= 100) xoff = (scrw - vidw) * ((float)xper / 100.0); |
40 if(yper >= 0 && yper <= 100) yoff = (scrh - vidh) * ((float)yper / 100.0); | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
41 |
8768 | 42 /* FIXME: better checking of bounds... */ |
43 if(width < 0 || width > scrw) width = vidw; | |
44 if(height < 0 || height > scrh) height = vidh; | |
45 if(xoff < 0 || xoff + vidw > scrw) xoff = 0; | |
46 if(yoff < 0 || yoff + vidh > scrh) yoff = 0; | |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
47 |
8768 | 48 if(xpos) *xpos = xoff; |
49 if(ypos) *ypos = yoff; | |
50 if(pwidth) *pwidth = width; | |
51 if(pheight) *pheight = height; | |
8767 | 52 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
53 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
54 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
55 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
56 // compatibility function |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
57 // only libvo working with full geometry options. |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
58 int geometry(int *xpos, int *ypos, int scrw, int scrh, int vidw, int vidh) |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
59 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
60 return geometryFull(NULL, NULL, xpos, ypos, scrw, scrh, vidw, vidh); |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
61 } |