comparison libvo/vo_ggi.c @ 16470:fbaf51e1c3b2

- improved performance on truecolor modes - fixed all known bugs, i.e. palette mode works right again patch by Christoph Egger < Christoph_Egger -- at -- gmx -- dot -- de >
author diego
date Tue, 13 Sep 2005 08:47:46 +0000
parents 3523630c28cf
children 98eaf29b5dee
comparison
equal deleted inserted replaced
16469:8c1c8d10c163 16470:fbaf51e1c3b2
4 (C) Alex Beregszaszi 4 (C) Alex Beregszaszi
5 5
6 Uses libGGI - http://www.ggi-project.org/ 6 Uses libGGI - http://www.ggi-project.org/
7 7
8 TODO: 8 TODO:
9 * check on many devices
10 * implement gamma handling (VAA isn't obsoleted?) 9 * implement gamma handling (VAA isn't obsoleted?)
11
12 BUGS:
13 * palettized playback has bad colors, probably swapped palette?
14 * fbdev & DR produces two downscaled images
15 * fbdev & FLIP (& DR) produces no image
16 10
17 Thanks to Andreas Beck for his patches. 11 Thanks to Andreas Beck for his patches.
18 12
19 Many thanks to Atmosfear, he hacked this driver to work with Planar 13 Many thanks to Atmosfear, he hacked this driver to work with Planar
20 formats, and he fixed the RGB handling. 14 formats, and he fixed the RGB handling.
54 48
55 49
56 static struct ggi_conf_s { 50 static struct ggi_conf_s {
57 char *driver; 51 char *driver;
58 52
59 ggi_visual_t parentvis;
60 ggi_visual_t vis; 53 ggi_visual_t vis;
54 ggi_visual_t drawvis;
61 55
62 /* source image format */ 56 /* source image format */
63 int srcwidth; 57 int srcwidth;
64 int srcheight; 58 int srcheight;
65 int srcformat; 59 int srcformat;
70 struct { 64 struct {
71 int x1, y1; 65 int x1, y1;
72 int x2, y2; 66 int x2, y2;
73 } flushregion; 67 } flushregion;
74 68
75 /* destination */
76 int dstwidth;
77 int dstheight;
78
79 int async;
80
81 int voflags; 69 int voflags;
82 } ggi_conf; 70 } ggi_conf;
83 71
84 72
85 #ifdef HAVE_GGIWMH 73 #ifdef HAVE_GGIWMH
86 static void window_ontop(void) 74 static void window_ontop(void)
87 { 75 {
88 mp_msg(MSGT_VO, MSGL_V, "[ggi] debug: window_ontop() called\n"); 76 mp_msg(MSGT_VO, MSGL_V, "[ggi] debug: window_ontop() called\n");
89 ggiWmhZOrder(ggi_conf.parentvis, ZO_TOP); 77 ggiWmhZOrder(ggi_conf.vis, ZO_TOP);
90 return; 78 return;
91 } 79 }
92 #endif 80 #endif
93 81
94 82
130 static int config(uint32_t width, uint32_t height, uint32_t d_width, 118 static int config(uint32_t width, uint32_t height, uint32_t d_width,
131 uint32_t d_height, uint32_t flags, char *title, 119 uint32_t d_height, uint32_t flags, char *title,
132 uint32_t format) 120 uint32_t format)
133 { 121 {
134 ggi_mode mode = { 122 ggi_mode mode = {
135 1, /* frames */
136 {0, 0}, /* top, left corner */
137 {width, height}, /* bottem, right corner */
138 {GGI_AUTO, GGI_AUTO}, /* size */
139 GT_AUTO, /* graphtype */
140 {GGI_AUTO, GGI_AUTO} /* dots per pixel */
141 };
142 ggi_mode parentmode = {
143 1, /* frames */ 123 1, /* frames */
144 {width, height}, /* visible */ 124 {width, height}, /* visible */
145 {GGI_AUTO, GGI_AUTO}, /* virt */ 125 {GGI_AUTO, GGI_AUTO}, /* virt */
146 {GGI_AUTO, GGI_AUTO}, /* size */ 126 {GGI_AUTO, GGI_AUTO}, /* size */
147 GT_AUTO, /* graphtype */ 127 GT_AUTO, /* graphtype */
148 {GGI_AUTO, GGI_AUTO} /* dots per pixel */ 128 {GGI_AUTO, GGI_AUTO} /* dots per pixel */
149 }; 129 };
150 130
151 131
152 set_graphtype(format, &parentmode); 132 set_graphtype(format, &mode);
153 133
154 #if 0 134 #if 0
155 printf("[ggi] mode: "); 135 printf("[ggi] mode: ");
156 ggiPrintMode(&parentmode);
157 printf("\n");
158
159 printf("[ggi] submode: ");
160 ggiPrintMode(&mode); 136 ggiPrintMode(&mode);
161 printf("\n"); 137 printf("\n");
162 #endif 138 #endif
163 139
164 ggiCheckMode(ggi_conf.parentvis, &parentmode); 140 ggiCheckMode(ggi_conf.vis, &mode);
165 141
166 if (ggiSetMode(ggi_conf.parentvis, &parentmode) < 0) { 142 if (ggiSetMode(ggi_conf.vis, &mode) < 0) {
167 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set display mode\n"); 143 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set display mode\n");
168 return (-1); 144 return (-1);
169 } 145 }
170 if (ggiGetMode(ggi_conf.parentvis, &parentmode) < 0) { 146 if (ggiGetMode(ggi_conf.vis, &mode) < 0) {
171 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get display mode\n"); 147 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get display mode\n");
172 return (-1); 148 return (-1);
173 } 149 }
174 if ((parentmode.graphtype == GT_INVALID) 150 if ((mode.graphtype == GT_INVALID)
175 || (parentmode.graphtype == GT_AUTO)) 151 || (mode.graphtype == GT_AUTO))
176 { 152 {
177 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n"); 153 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n");
178 return (-1); 154 return (-1);
179 } 155 }
180 156
181 #if 0 157 #if 0
182 printf("[ggi] mode: "); 158 printf("[ggi] mode: ");
183 ggiPrintMode(&parentmode);
184 printf("\n");
185 #endif
186
187 /* calculate top, left corner */
188 mode.visible.x = (parentmode.virt.x - width) / 2;
189 mode.visible.y = (parentmode.virt.y - height) / 2;
190
191 /* calculate bottom, right corner */
192 mode.virt.x = width;
193 mode.virt.y = height;
194
195 ggiCheckMode(ggi_conf.vis, &mode);
196
197 if (ggiSetMode(ggi_conf.vis, &mode) < 0) {
198 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set video mode\n");
199 return (-1);
200 }
201 if (ggiGetMode(ggi_conf.vis, &mode) < 0) {
202 mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get video mode\n");
203 return (-1);
204 }
205
206 #ifdef HAVE_GGIWMH
207 ggiWmhSetTitle(ggi_conf.parentvis, title);
208 if (vo_ontop) window_ontop();
209 #endif
210
211 #if 0
212 printf("[ggi] submode: ");
213 ggiPrintMode(&mode); 159 ggiPrintMode(&mode);
214 printf("\n"); 160 printf("\n");
215 #endif 161 #endif
216 162
217 vo_depthonscreen = GT_DEPTH(parentmode.graphtype); 163
218 vo_screenwidth = parentmode.visible.x; 164 #ifdef HAVE_GGIWMH
219 vo_screenheight = parentmode.visible.y; 165 ggiWmhSetTitle(ggi_conf.vis, title);
220 166 if (vo_ontop) window_ontop();
221 vo_dx = vo_dy = 0; 167 #endif
222 vo_dwidth = mode.virt.x; 168
223 vo_dheight = mode.virt.y; 169 ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC);
224 vo_dbpp = GT_SIZE(parentmode.graphtype); 170
171 if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
172 ggiSetColorfulPalette(ggi_conf.vis);
173
174 if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) {
175 ggi_mode drawmode;
176
177 ggi_conf.drawvis = ggiOpen("display-memory", NULL);
178 if (ggi_conf.drawvis == NULL) {
179 mp_msg(MSGT_VO, MSGL_ERR,
180 "[ggi] unable to get backbuffer for conversion\n");
181 return -1;
182 }
183 memcpy(&drawmode, &mode, sizeof(ggi_mode));
184 drawmode.graphtype = GT_32BIT;
185 drawmode.size.x = GGI_AUTO;
186 drawmode.size.y = GGI_AUTO;
187 ggiCheckMode(ggi_conf.drawvis, &drawmode);
188 if (ggiSetMode(ggi_conf.drawvis, &drawmode) < 0) {
189 mp_msg(MSGT_VO, MSGL_ERR,
190 "[ggi] unable to set backbuffer mode\n");
191 return -1;
192 }
193 mode.graphtype = drawmode.graphtype;
194
195 ggiSetFlags(ggi_conf.drawvis, GGIFLAG_ASYNC);
196 }
197 vo_depthonscreen = GT_DEPTH(mode.graphtype);
198 vo_screenwidth = mode.virt.x;
199 vo_screenheight = mode.virt.y;
200
201 vo_dwidth = width;
202 vo_dheight = height;
203 vo_dbpp = GT_SIZE(mode.graphtype);
204
205
206 /* calculate top, left corner */
207 vo_dx = (vo_screenwidth - vo_dwidth) / 2;
208 vo_dy = (vo_screenheight - vo_dheight) / 2;
209
225 210
226 ggi_conf.srcwidth = width; 211 ggi_conf.srcwidth = width;
227 ggi_conf.srcheight = height; 212 ggi_conf.srcheight = height;
228 ggi_conf.srcformat = format; 213 ggi_conf.srcformat = format;
229
230 ggi_conf.dstwidth = mode.virt.x;
231 ggi_conf.dstheight = mode.virt.y;
232 214
233 ggi_conf.voflags = flags; 215 ggi_conf.voflags = flags;
234 216
235 if (IMGFMT_IS_RGB(ggi_conf.srcformat)) { 217 if (IMGFMT_IS_RGB(ggi_conf.srcformat)) {
236 ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat); 218 ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat);
240 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", 222 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n",
241 vo_format_name(ggi_conf.srcformat)); 223 vo_format_name(ggi_conf.srcformat));
242 return (-1); 224 return (-1);
243 } 225 }
244 226
245 ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC);
246
247 if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
248 ggiSetColorfulPalette(ggi_conf.vis);
249
250 if (ggiGetFlags(ggi_conf.vis) & GGIFLAG_ASYNC)
251 ggi_conf.async = 1;
252
253 mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d\n", 227 mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d\n",
254 ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth, 228 ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth,
255 vo_dwidth, vo_dheight, vo_dbpp); 229 mode.virt.x, mode.virt.y, vo_dbpp);
256 mp_msg(MSGT_VO, MSGL_INFO, "[ggi] async mode: %s\n",
257 ggi_conf.async ? "yes" : "no");
258 230
259 ggi_conf.srcbpp = (ggi_conf.srcdepth + 7) / 8; 231 ggi_conf.srcbpp = (ggi_conf.srcdepth + 7) / 8;
260 232
261 ggi_conf.flushregion.x1 = ggi_conf.flushregion.y1 = 0; 233 ggi_conf.flushregion.x1 = vo_dx;
262 ggi_conf.flushregion.x2 = ggi_conf.dstwidth; 234 ggi_conf.flushregion.y1 = vo_dy;
263 ggi_conf.flushregion.y2 = ggi_conf.dstheight; 235 ggi_conf.flushregion.x2 = vo_dwidth;
236 ggi_conf.flushregion.y2 = vo_dheight;
264 237
265 return (0); 238 return (0);
266 } 239 }
267 240
268 static uint32_t get_image(mp_image_t *mpi) 241 static uint32_t get_image(mp_image_t *mpi)
269 { 242 {
270 /* GGI DirectRendering supports (yet) only BGR/RGB modes */ 243 /* GGI DirectRendering supports (yet) only BGR/RGB modes */
271 if ( 244 if (!((IMGFMT_IS_BGR(mpi->imgfmt)) &&
272 #if 1 245 (IMGFMT_BGR_DEPTH(mpi->imgfmt) == vo_dbpp)))
273 (IMGFMT_IS_RGB(mpi->imgfmt) && 246 {
274 (IMGFMT_RGB_DEPTH(mpi->imgfmt) != vo_dbpp)) || 247 return (VO_FALSE);
275 (IMGFMT_IS_BGR(mpi->imgfmt) && 248 }
276 (IMGFMT_BGR_DEPTH(mpi->imgfmt) != vo_dbpp)) || 249
277 #else 250 if (!((IMGFMT_IS_RGB(mpi->imgfmt)) &&
278 (mpi->imgfmt != ggi_conf.srcformat) || 251 (IMGFMT_RGB_DEPTH(mpi->imgfmt) == vo_dbpp)))
279 #endif 252 {
280 ((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || 253 return (VO_FALSE);
281 (mpi->flags & MP_IMGFLAG_PLANAR) || 254 }
282 (mpi->flags & MP_IMGFLAG_YUV) || 255
283 (mpi->width != ggi_conf.srcwidth) || 256 if (!((mpi->width == ggi_conf.srcwidth) &&
284 (mpi->height != ggi_conf.srcheight)) 257 (mpi->height == ggi_conf.srcheight)))
285 { 258 {
286 return (VO_FALSE); 259 return (VO_FALSE);
287 } 260 }
288 261
289 mpi->planes[1] = mpi->planes[2] = NULL; 262 mpi->planes[1] = mpi->planes[2] = NULL;
303 } 276 }
304 277
305 278
306 static int draw_frame(uint8_t *src[]) 279 static int draw_frame(uint8_t *src[])
307 { 280 {
308 ggiPutBox(ggi_conf.vis, 0, 0, 281 ggiPutBox(ggi_conf.drawvis, vo_dx, vo_dy,
309 ggi_conf.dstwidth, ggi_conf.dstheight, 282 vo_dwidth, vo_dheight, src[0]);
310 src[0]); 283
311 284 ggi_conf.flushregion.x1 = vo_dx;
312 ggi_conf.flushregion.x1 = ggi_conf.flushregion.y1 = 0; 285 ggi_conf.flushregion.y1 = vo_dy;
313 ggi_conf.flushregion.x2 = ggi_conf.dstwidth; 286 ggi_conf.flushregion.x2 = vo_dwidth;
314 ggi_conf.flushregion.y2 = ggi_conf.dstheight; 287 ggi_conf.flushregion.y2 = vo_dheight;
315 288
316 return (0); 289 return (0);
317 } 290 }
318 291
319 static void draw_osd(void) 292 static void draw_osd(void)
321 return; 294 return;
322 } 295 }
323 296
324 static void flip_page(void) 297 static void flip_page(void)
325 { 298 {
299 if (ggi_conf.drawvis != ggi_conf.vis) {
300 #if 0
301 ggiFlushRegion(ggi_conf.drawvis,
302 ggi_conf.flushregion.x1, ggi_conf.flushregion.y1,
303 ggi_conf.flushregion.x2 - ggi_conf.flushregion.x1,
304 ggi_conf.flushregion.y2 - ggi_conf.flushregion.y1);
305 #endif
306 ggiCrossBlit(ggi_conf.drawvis,
307 ggi_conf.flushregion.x1, ggi_conf.flushregion.y1,
308 ggi_conf.flushregion.x2 - ggi_conf.flushregion.x1,
309 ggi_conf.flushregion.y2 - ggi_conf.flushregion.y1,
310 ggi_conf.vis,
311 ggi_conf.flushregion.x1, ggi_conf.flushregion.y1);
312
313 }
326 ggiFlushRegion(ggi_conf.vis, 314 ggiFlushRegion(ggi_conf.vis,
327 ggi_conf.flushregion.x1, ggi_conf.flushregion.y1, 315 ggi_conf.flushregion.x1, ggi_conf.flushregion.y1,
328 ggi_conf.flushregion.x2 - ggi_conf.flushregion.x1, 316 ggi_conf.flushregion.x2 - ggi_conf.flushregion.x1,
329 ggi_conf.flushregion.y2 - ggi_conf.flushregion.y1); 317 ggi_conf.flushregion.y2 - ggi_conf.flushregion.y1);
330 318
333 } 321 }
334 322
335 static int draw_slice(uint8_t *src[], int stride[], 323 static int draw_slice(uint8_t *src[], int stride[],
336 int w, int h, int x, int y) 324 int w, int h, int x, int y)
337 { 325 {
338 ggiPutBox(ggi_conf.vis, x, y, w, h, src[0]); 326 ggiPutBox(ggi_conf.drawvis, vo_dx + x, vo_dy + y, w, h, src[0]);
339 327
340 if ((ggi_conf.flushregion.x1 == -1) || (x < ggi_conf.flushregion.x1)) 328 if ((ggi_conf.flushregion.x1 == -1) ||
341 ggi_conf.flushregion.x1 = x; 329 ((vo_dx + x) < ggi_conf.flushregion.x1))
342 if ((ggi_conf.flushregion.y1 == -1) || (y < ggi_conf.flushregion.y1)) 330 {
343 ggi_conf.flushregion.y1 = y; 331 ggi_conf.flushregion.x1 = vo_dx + x;
344 if ((ggi_conf.flushregion.x2 == -1) || ((x + w) > ggi_conf.flushregion.x2)) 332 }
345 ggi_conf.flushregion.x2 = x + w; 333 if ((ggi_conf.flushregion.y1 == -1) ||
346 if ((ggi_conf.flushregion.y2 == -1) || ((y + h) > ggi_conf.flushregion.y2)) 334 ((vo_dy + y) < ggi_conf.flushregion.y1))
347 ggi_conf.flushregion.y2 = y + h; 335 {
336 ggi_conf.flushregion.y1 = vo_dy + y;
337 }
338 if ((ggi_conf.flushregion.x2 == -1) ||
339 ((vo_dx + x + w) > ggi_conf.flushregion.x2))
340 {
341 ggi_conf.flushregion.x2 = vo_dx + x + w;
342 }
343 if ((ggi_conf.flushregion.y2 == -1) ||
344 ((vo_dy + y + h) > ggi_conf.flushregion.y2))
345 {
346 ggi_conf.flushregion.y2 = vo_dy + y + h;
347 }
348 348
349 return (1); 349 return (1);
350 } 350 }
351 351
352 static int query_format(uint32_t format) 352 static int query_format(uint32_t format)
356 356
357 vfcap = VFCAP_CSP_SUPPORTED 357 vfcap = VFCAP_CSP_SUPPORTED
358 | VFCAP_CSP_SUPPORTED_BY_HW 358 | VFCAP_CSP_SUPPORTED_BY_HW
359 | VFCAP_ACCEPT_STRIDE; 359 | VFCAP_ACCEPT_STRIDE;
360 360
361 if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.parentvis) { 361 if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.vis) {
362 if (ggiGetMode(ggi_conf.parentvis, &mode) == 0) { 362 if (ggiGetMode(ggi_conf.vis, &mode) == 0) {
363 vo_depthonscreen = GT_DEPTH(mode.graphtype); 363 vo_depthonscreen = GT_DEPTH(mode.graphtype);
364 vo_dbpp = GT_SIZE(mode.graphtype); 364 vo_dbpp = GT_SIZE(mode.graphtype);
365 } 365 }
366 if (GT_SCHEME(mode.graphtype) == GT_AUTO) {
367 ggiCheckMode(ggi_conf.vis, &mode);
368 }
369 if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) {
370 mode.graphtype = GT_32BIT;
371 vo_depthonscreen = GT_DEPTH(mode.graphtype);
372 vo_dbpp = GT_SIZE(mode.graphtype);
373 }
366 } 374 }
367 if ((IMGFMT_IS_BGR(format) && (IMGFMT_BGR_DEPTH(format) == vo_dbpp)) || 375 if ((IMGFMT_IS_BGR(format) && (IMGFMT_BGR_DEPTH(format) == vo_dbpp)) ||
368 (IMGFMT_IS_RGB(format) && (IMGFMT_RGB_DEPTH(format) == vo_dbpp))) 376 (IMGFMT_IS_RGB(format) && (IMGFMT_RGB_DEPTH(format) == vo_dbpp)))
369 { 377 {
370 return vfcap; 378 return vfcap;
371 } 379 }
372 if (IMGFMT_IS_BGR(format) || IMGFMT_IS_RGB(format)) { 380 if (IMGFMT_IS_BGR(format) || IMGFMT_IS_RGB(format)) {
373 set_graphtype(format, &mode); 381 set_graphtype(format, &mode);
374 382
375 if (ggiCheckMode(ggi_conf.parentvis, &mode) < 0) { 383 if (ggiCheckMode(ggi_conf.drawvis, &mode) < 0) {
376 return 0; 384 return 0;
377 } else { 385 } else {
378 return vfcap; 386 return vfcap;
379 } 387 }
380 } 388 }
392 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize libggiwmh\n"); 400 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize libggiwmh\n");
393 return (-1); 401 return (-1);
394 } 402 }
395 #endif 403 #endif
396 404
397 if ((char *) arg) { 405 if (arg) {
398 int i = 0; 406 int i = 0;
399 ggi_conf.driver = strdup(arg); 407 ggi_conf.driver = strdup(arg);
400 while (ggi_conf.driver[i]) { 408 while (ggi_conf.driver[i] != '\0') {
401 if (ggi_conf.driver[i] == '.') 409 if (ggi_conf.driver[i] == '.')
402 ggi_conf.driver[i] = ','; 410 ggi_conf.driver[i] = ',';
403 i++; 411 i++;
404 } 412 }
405 } else { 413 } else {
406 ggi_conf.driver = NULL; 414 ggi_conf.driver = NULL;
407 } 415 }
408 416
409 ggi_conf.parentvis = ggiOpen(ggi_conf.driver); 417 ggi_conf.vis = ggiOpen(ggi_conf.driver);
410 if (ggi_conf.parentvis == NULL) { 418 if (ggi_conf.vis == NULL) {
411 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to open '%s' output\n", 419 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to open '%s' output\n",
412 (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); 420 (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver);
413 ggiExit(); 421 ggiExit();
414 return (-1); 422 return (-1);
415 } 423 }
416 ggi_conf.vis = ggiOpen("display-sub", ggi_conf.parentvis); 424 ggi_conf.drawvis = ggi_conf.vis;
417 if (ggi_conf.vis == NULL) { 425
418 mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to open the video output\n"); 426
419 ggiExit(); 427 #ifdef HAVE_GGIWMH
420 return (-1); 428 ggiWmhAttach(ggi_conf.vis);
421 }
422 #ifdef HAVE_GGIWMH
423 ggiWmhAttach(ggi_conf.parentvis);
424 #endif 429 #endif
425 430
426 431
427 mp_msg(MSGT_VO, MSGL_V, "[ggi] using '%s' output\n", 432 mp_msg(MSGT_VO, MSGL_V, "[ggi] using '%s' output\n",
428 (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); 433 (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver);
434 { 439 {
435 if (ggi_conf.driver) 440 if (ggi_conf.driver)
436 free(ggi_conf.driver); 441 free(ggi_conf.driver);
437 442
438 #ifdef HAVE_GGIWMH 443 #ifdef HAVE_GGIWMH
439 ggiWmhDetach(ggi_conf.parentvis); 444 ggiWmhDetach(ggi_conf.vis);
440 ggiWmhExit(); 445 ggiWmhExit();
441 #endif 446 #endif
442 447
448 if (ggi_conf.drawvis != NULL && ggi_conf.drawvis != ggi_conf.vis)
449 ggiClose(ggi_conf.drawvis);
450
443 ggiClose(ggi_conf.vis); 451 ggiClose(ggi_conf.vis);
444 ggiClose(ggi_conf.parentvis);
445 ggiExit(); 452 ggiExit();
446 } 453 }
447 454
448 static int control(uint32_t request, void *data, ...) 455 static int control(uint32_t request, void *data, ...)
449 { 456 {
470 { 477 {
471 struct timeval tv = {0, 0}; 478 struct timeval tv = {0, 0};
472 ggi_event event; 479 ggi_event event;
473 ggi_event_mask mask; 480 ggi_event_mask mask;
474 481
475 if ((mask = ggiEventPoll(ggi_conf.parentvis, emAll, &tv))) { 482 if ((mask = ggiEventPoll(ggi_conf.vis, emAll, &tv))) {
476 if (ggiEventRead(ggi_conf.parentvis, &event, emAll) != 0) { 483 if (ggiEventRead(ggi_conf.vis, &event, emAll) != 0) {
477 mp_dbg(MSGT_VO, MSGL_DBG3, 484 mp_dbg(MSGT_VO, MSGL_DBG3,
478 "type: %4x, origin: %4x, " 485 "type: %4x, origin: %4x, "
479 "sym: %4x, label: %4x, button=%4x\n", 486 "sym: %4x, label: %4x, button=%4x\n",
480 event.any.origin, event.any.type, event.key.sym, 487 event.any.origin, event.any.type, event.key.sym,
481 event.key.label, event.key.button); 488 event.key.label, event.key.button);