swm

sigma window manager
git clone git://wolog.xyz/swm
Log | Files | Refs | README | LICENSE

drw.h (1752B)


      1 /*
      2  * Copyright (C) Raymond Cole <rc@wolog.xyz>
      3  * License: GPL-3.0-or-later
      4  *
      5  * Portions of the code are derived from suckless dwm.  See file
      6  * LICENSE-dwm for copyright and license details of those portions.
      7  */
      8 
      9 typedef struct Fnt {
     10 	Display *dpy;
     11 	unsigned int h;
     12 	struct _XftFont *xfont;
     13 	struct _FcPattern *pattern;
     14 	struct Fnt *next;
     15 } Fnt;
     16 
     17 typedef XftColor Clr;
     18 
     19 typedef struct {
     20 	Clr fg, bg;
     21 } Scm;
     22 
     23 typedef struct {
     24 	unsigned int w, h;
     25 	Display *dpy;
     26 	int screen;
     27 	Window root;
     28 	Drawable drawable;
     29 	GC gc;
     30 	Scm *scheme;
     31 	Fnt *fonts;
     32 } Drw;
     33 
     34 /* drawable abstraction */
     35 Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
     36 void drw_resize(Drw *drw, unsigned int w, unsigned int h);
     37 void drw_free(Drw *drw);
     38 
     39 /* font abstraction */
     40 Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
     41 void drw_fontset_free(Fnt* set);
     42 unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
     43 unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
     44 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
     45 
     46 /* colorscheme abstraction */
     47 Clr *drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
     48 Scm *drw_scm_create(Drw *drw, const char *fg, const char *bg);
     49 
     50 /* drawing context manipulation */
     51 void drw_setfontset(Drw *drw, Fnt *set);
     52 void drw_setscheme(Drw *drw, Scm *scm);
     53 
     54 /* drawing functions */
     55 void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
     56 int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
     57 
     58 /* Map functions */
     59 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);