URI: 
       draw_util.c - ledit - Text editor (WIP)
  HTML git clone git://lumidify.org/ledit.git (fast, but not encrypted)
  HTML git clone https://lumidify.org/ledit.git (encrypted, but very slow)
  HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ledit.git (over tor)
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       draw_util.c (1298B)
       ---
            1 #include <X11/Xlib.h>
            2 #include <X11/Xft/Xft.h>
            3 
            4 #include "memory.h"
            5 #include "window.h"
            6 #include "draw_util.h"
            7 
            8 ledit_draw *
            9 draw_create(ledit_window *window, int w, int h) {
           10         ledit_draw *draw = ledit_malloc(sizeof(ledit_draw));
           11         draw->w = w;
           12         draw->h = h;
           13         draw->pixmap = XCreatePixmap(
           14             window->common->dpy, window->drawable, w, h, window->common->depth
           15         );
           16         draw->xftdraw = XftDrawCreate(
           17             window->common->dpy, draw->pixmap, window->common->vis, window->common->cm
           18         );
           19         return draw;
           20 }
           21 
           22 void
           23 draw_grow(ledit_window *window, ledit_draw *draw, int w, int h) {
           24         /* FIXME: sensible default pixmap sizes here */
           25         /* FIXME: maybe shrink the pixmaps at some point */
           26         if (draw->w < w || draw->h < h) {
           27                 draw->w = w > draw->w ? w + 10 : draw->w;
           28                 draw->h = h > draw->h ? h + 10 : draw->h;
           29                 XFreePixmap(window->common->dpy, draw->pixmap);
           30                 draw->pixmap = XCreatePixmap(
           31                     window->common->dpy, window->drawable,
           32                     draw->w, draw->h, window->common->depth
           33                 );
           34                 XftDrawChange(draw->xftdraw, draw->pixmap);
           35         }
           36 }
           37 
           38 void
           39 draw_destroy(ledit_window *window, ledit_draw *draw) {
           40         XFreePixmap(window->common->dpy, draw->pixmap);
           41         XftDrawDestroy(draw->xftdraw);
           42         free(draw);
           43 }