annotate libvo/geometry.c @ 11719:6f87aab0d881

10l
author gabucino
date Fri, 02 Jan 2004 08:34:35 +0000
parents d9478c8e5ffe
children 398c24cecdc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
10 // set when either width or height is changed
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
11 int geometry_wh_changed = 0;
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
12
9517
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
13 #define RESET_GEOMETRY width = height = xoff = yoff = xper = yper = -1;
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
14
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
15 // xpos,ypos: position of the left upper corner
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
16 // widw,widh: width and height of the window
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
17 // scrw,scrh: width and height of the current screen
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
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
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
25 if(sscanf(vo_geometry, "%ix%i+%i+%i", &width, &height, &xoff, &yoff) != 4 )
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
26 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
27 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
28 if(sscanf(vo_geometry, "%ix%i", &width, &height) != 2)
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
29 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
30 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
31 if(sscanf(vo_geometry, "+%i+%i", &xoff, &yoff) != 2)
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
32 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
33 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
34 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2)
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
35 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
36 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
37 if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2)
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
38 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
39 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
40 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2)
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
41 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
42 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
43 if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2)
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
44 {
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
45 RESET_GEOMETRY
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
46 if(sscanf(vo_geometry, "%i%%", &xper) != 1)
10734
b105d7aba10d remove exit_player and exit references
alex
parents: 9947
diff changeset
47 {
b105d7aba10d remove exit_player and exit references
alex
parents: 9947
diff changeset
48 mp_msg(MSGT_VO, MSGL_ERR,
b105d7aba10d remove exit_player and exit references
alex
parents: 9947
diff changeset
49 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry);
b105d7aba10d remove exit_player and exit references
alex
parents: 9947
diff changeset
50 return 0;
b105d7aba10d remove exit_player and exit references
alex
parents: 9947
diff changeset
51 }
9517
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
52 }
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
53 }
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
54 }
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
55 }
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
56 }
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
57 }
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
58 }
7866
732a8bfc7681 Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff changeset
59
9517
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
60 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i,"
9947
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
61 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n",
9517
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
62 width, height, xoff, yoff, xper, yper);
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
63
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
64 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0);
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
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
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
67 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i,"
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
68 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n",
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
69 width, height, xoff, yoff, xper, yper);
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
70 mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i,"
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
71 " widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh);
b552e7939ca2 adding geometry support for xvidix
attila
parents: 9517
diff changeset
72
8768
44b7d4c7e61c cosmetics
attila
parents: 8767
diff changeset
73 /* FIXME: better checking of bounds... */
11125
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
74 if( width != -1 && (width < 0 || width > scrw))
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
75 width = (scrw < *widw) ? scrw : *widw;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
76 if( height != -1 && (height < 0 || height > scrh))
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
77 height = (scrh < *widh) ? scrh : *widh;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
78 if(xoff != -1 && (xoff < 0 || xoff + width > scrw)) xoff = 0;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
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
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
81 if(xoff != -1 && xpos) *xpos = xoff;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
82 if(yoff != -1 && ypos) *ypos = yoff;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
83 if(width != -1 && widw) *widw = width;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
84 if(height != -1 && widh) *widh = height;
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
85
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
86 if( width != -1 || height != -1)
d9478c8e5ffe fix aspect hack
attila
parents: 10734
diff changeset
87 geometry_wh_changed = 1;
8767
e497d7e42d8a fix xv window position problem
attila
parents: 8745
diff changeset
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
d65ddafbc404 clean up of -geometry code.
attila
parents: 9217
diff changeset
92 #undef RESET_GEOMETRY