25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: x11.c,v 1.56 2005/03/05 12:17:53 debug Exp $ |
* $Id: x11.c,v 1.58 2005/05/20 22:35:59 debug Exp $ |
29 |
* |
* |
30 |
* X11-related functions. |
* X11-related functions. |
31 |
*/ |
*/ |
323 |
} |
} |
324 |
|
|
325 |
|
|
326 |
|
/* |
327 |
|
* x11_fb_resize(): |
328 |
|
* |
329 |
|
* Set a new size for an X11 framebuffer window. (NOTE: I didn't think of |
330 |
|
* this kind of functionality during the initial design, so it is probably |
331 |
|
* buggy. It also needs some refactoring.) |
332 |
|
*/ |
333 |
|
void x11_fb_resize(struct fb_window *win, int new_xsize, int new_ysize) |
334 |
|
{ |
335 |
|
int alloc_depth; |
336 |
|
|
337 |
|
if (win == NULL) { |
338 |
|
fatal("x11_fb_resize(): win == NULL\n"); |
339 |
|
return; |
340 |
|
} |
341 |
|
|
342 |
|
win->x11_fb_winxsize = new_xsize; |
343 |
|
win->x11_fb_winysize = new_ysize; |
344 |
|
|
345 |
|
alloc_depth = win->x11_screen_depth; |
346 |
|
if (alloc_depth == 24) |
347 |
|
alloc_depth = 32; |
348 |
|
if (alloc_depth == 15) |
349 |
|
alloc_depth = 16; |
350 |
|
|
351 |
|
/* Note: ximage_data seems to be freed by XDestroyImage below. */ |
352 |
|
/* if (win->ximage_data != NULL) |
353 |
|
free(win->ximage_data); */ |
354 |
|
win->ximage_data = malloc(new_xsize * new_ysize * alloc_depth / 8); |
355 |
|
if (win->ximage_data == NULL) { |
356 |
|
fprintf(stderr, "x11_fb_resize(): out of memory " |
357 |
|
"allocating ximage_data\n"); |
358 |
|
exit(1); |
359 |
|
} |
360 |
|
|
361 |
|
/* TODO: clear for non-truecolor modes */ |
362 |
|
memset(win->ximage_data, 0, new_xsize * new_ysize * alloc_depth / 8); |
363 |
|
|
364 |
|
if (win->fb_ximage != NULL) |
365 |
|
XDestroyImage(win->fb_ximage); |
366 |
|
win->fb_ximage = XCreateImage(win->x11_display, CopyFromParent, |
367 |
|
win->x11_screen_depth, ZPixmap, 0, (char *)win->ximage_data, |
368 |
|
new_xsize, new_ysize, 8, new_xsize * alloc_depth / 8); |
369 |
|
if (win->fb_ximage == NULL) { |
370 |
|
fprintf(stderr, "x11_fb_resize(): out of memory " |
371 |
|
"allocating fb_ximage\n"); |
372 |
|
exit(1); |
373 |
|
} |
374 |
|
|
375 |
|
XResizeWindow(win->x11_display, win->x11_fb_window, |
376 |
|
new_xsize, new_ysize); |
377 |
|
} |
378 |
|
|
379 |
|
|
380 |
/* |
/* |
381 |
* x11_fb_init(): |
* x11_fb_init(): |
382 |
* |
* |