Mercurial > mplayer.hg
annotate libvo/geometry.c @ 9574:eada4280c3fa
sync
author | nicolas |
---|---|
date | Wed, 12 Mar 2003 18:11:40 +0000 |
parents | d65ddafbc404 |
children | b552e7939ca2 |
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" |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8123
diff
changeset
|
7 #include "../mplayer.h" /* exit_player() */ |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
8 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
9 /* 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
|
10 char *vo_geometry = NULL; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
11 |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
12 int geometry_error() |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
13 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
14 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
|
15 exit_player(NULL); /* ????? what else could we do ? */ |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
16 return 0; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
17 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
18 |
9517 | 19 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1; |
20 | |
21 // xpos,ypos: position of the left upper corner | |
22 // widw,widh: width and height of the window | |
23 // scrw,scrh: width and height of the current screen | |
24 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
|
25 { |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
26 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
|
27 |
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
28 width = height = xoff = yoff = xper = yper = -1; |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
29 |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
30 if(vo_geometry != NULL) { |
9517 | 31 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 ) |
32 { | |
33 RESET_GEOMETRY | |
34 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2) | |
35 { | |
36 RESET_GEOMETRY | |
37 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2) | |
38 { | |
39 RESET_GEOMETRY | |
40 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 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%%:%i", &xper, &yper) != 2) | |
47 { | |
48 RESET_GEOMETRY | |
49 if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2) | |
50 { | |
51 RESET_GEOMETRY | |
52 if(sscanf(vo_geometry, "%i%%", &xper) != 1) | |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
53 return geometry_error(); |
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," |
63 "height: %i, xoff: %i, yoff: %i, xper: %1, yper: %i\n", | |
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 |
8768 | 69 /* FIXME: better checking of bounds... */ |
9517 | 70 if(width < 0 || width > scrw) width = *widw; |
71 if(height < 0 || height > scrh) height = *widh; | |
72 if(xoff < 0 || xoff + *widw > scrw) xoff = 0; | |
73 if(yoff < 0 || yoff + *widh > scrh) yoff = 0; | |
8745
93f78fb709e6
Added support for X style -geometry options (adapted from Henk's patch)
mark
parents:
8254
diff
changeset
|
74 |
8768 | 75 if(xpos) *xpos = xoff; |
76 if(ypos) *ypos = yoff; | |
9517 | 77 if(widw) *widw = width; |
78 if(widh) *widh = height; | |
8767 | 79 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
80 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
81 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
82 |
9517 | 83 #undef RESET_GEOMETRY |