/[gxemul]/trunk/src/x11.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/x11.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by dpavlin, Mon Oct 8 16:17:48 2007 UTC revision 6 by dpavlin, Mon Oct 8 16:18:11 2007 UTC
# Line 25  Line 25 
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   */   */
# Line 323  void x11_init(struct machine *m) Line 323  void x11_init(struct machine *m)
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   *   *

Legend:
Removed from v.5  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26