Mercurial > mplayer.hg
annotate libvo/geometry.c @ 13106:1ff6e072861f
wrong formats
author | diego |
---|---|
date | Mon, 23 Aug 2004 23:18:31 +0000 |
parents | 398c24cecdc7 |
children | e047e70a9767 |
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; | |
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 { | |
34 RESET_GEOMETRY | |
35 if(sscanf(vo_geometry, "%i:%i", &xoff, &yoff) != 2) | |
36 { | |
37 RESET_GEOMETRY | |
38 if(sscanf(vo_geometry, "%i:%i%%", &xper, &yper) != 2) | |
39 { | |
40 RESET_GEOMETRY | |
41 if(sscanf(vo_geometry, "%i%%:%i", &xper, &yper) != 2) | |
42 { | |
43 RESET_GEOMETRY | |
44 if(sscanf(vo_geometry, "%i%%:%i%%", &xper, &yper) != 2) | |
45 { | |
46 RESET_GEOMETRY | |
47 if(sscanf(vo_geometry, "%i%%", &xper) != 1) | |
10734 | 48 { |
49 mp_msg(MSGT_VO, MSGL_ERR, | |
50 "-geometry must be in [WxH][+X+Y] | [X[%%]:[Y[%%]]] format, incorrect (%s)\n", vo_geometry); | |
51 return 0; | |
52 } | |
9517 | 53 } |
54 } | |
55 } | |
56 } | |
57 } | |
58 } | |
59 } | |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
60 |
9517 | 61 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
9947 | 62 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", |
9517 | 63 width, height, xoff, yoff, xper, yper); |
64 | |
65 if(xper >= 0 && xper <= 100) xoff = (scrw - *widw) * ((float)xper / 100.0); | |
66 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
|
67 |
9947 | 68 mp_msg(MSGT_VO, MSGL_V,"geometry set to width: %i," |
69 "height: %i, xoff: %i, yoff: %i, xper: %i, yper: %i\n", | |
70 width, height, xoff, yoff, xper, yper); | |
71 mp_msg(MSGT_VO, MSGL_V,"geometry window parameter: widw: %i," | |
72 " widh: %i, scrw: %i, scrh: %i\n",*widw, *widh, scrw, scrh); | |
73 | |
8768 | 74 /* FIXME: better checking of bounds... */ |
11125 | 75 if( width != -1 && (width < 0 || width > scrw)) |
76 width = (scrw < *widw) ? scrw : *widw; | |
77 if( height != -1 && (height < 0 || height > scrh)) | |
78 height = (scrh < *widh) ? scrh : *widh; | |
79 if(xoff != -1 && (xoff < 0 || xoff + width > scrw)) xoff = 0; | |
80 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
|
81 |
11125 | 82 if(xoff != -1 && xpos) *xpos = xoff; |
83 if(yoff != -1 && ypos) *ypos = yoff; | |
84 if(width != -1 && widw) *widw = width; | |
85 if(height != -1 && widh) *widh = height; | |
86 | |
87 if( width != -1 || height != -1) | |
88 geometry_wh_changed = 1; | |
11996
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
89 if( xoff != -1 || yoff != -1) |
398c24cecdc7
dont mess with the window position in xinerama when -geometry changes it.
attila
parents:
11125
diff
changeset
|
90 geometry_xy_changed = 1; |
8767 | 91 } |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
92 return 1; |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
93 } |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
diff
changeset
|
94 |
9517 | 95 #undef RESET_GEOMETRY |