@ -57,6 +57,8 @@
# define TAGMASK ((1 << LENGTH(tags)) - 1)
# define TAGMASK ((1 << LENGTH(tags)) - 1)
# define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
# define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
# define OPAQUE 0xffU
/* enums */
/* enums */
enum { CurNormal , CurResize , CurMove , CurLast } ; /* cursor */
enum { CurNormal , CurResize , CurMove , CurLast } ; /* cursor */
enum { SchemeNorm , SchemeSel , SchemeStatus , SchemeTagsSel , SchemeTagsNorm , SchemeInfoSel , SchemeInfoNorm , SchemeWarn , SchemeUrgent , SchemeWorking } ; /* color schemes */
enum { SchemeNorm , SchemeSel , SchemeStatus , SchemeTagsSel , SchemeTagsNorm , SchemeInfoSel , SchemeInfoNorm , SchemeWarn , SchemeUrgent , SchemeWorking } ; /* color schemes */
@ -242,6 +244,7 @@ static Monitor *wintomon(Window w);
static int xerror ( Display * dpy , XErrorEvent * ee ) ;
static int xerror ( Display * dpy , XErrorEvent * ee ) ;
static int xerrordummy ( Display * dpy , XErrorEvent * ee ) ;
static int xerrordummy ( Display * dpy , XErrorEvent * ee ) ;
static int xerrorstart ( Display * dpy , XErrorEvent * ee ) ;
static int xerrorstart ( Display * dpy , XErrorEvent * ee ) ;
static void xinitvisual ( ) ;
static void zoom ( const Arg * arg ) ;
static void zoom ( const Arg * arg ) ;
/* variables */
/* variables */
@ -279,6 +282,11 @@ static Drw *drw;
static Monitor * mons , * selmon ;
static Monitor * mons , * selmon ;
static Window root , wmcheckwin ;
static Window root , wmcheckwin ;
static int useargb = 0 ;
static Visual * visual ;
static int depth ;
static Colormap cmap ;
/* configuration, allows nested code to access above variables */
/* configuration, allows nested code to access above variables */
# include "config.h"
# include "config.h"
@ -1706,7 +1714,8 @@ setup(void)
sw = DisplayWidth ( dpy , screen ) ;
sw = DisplayWidth ( dpy , screen ) ;
sh = DisplayHeight ( dpy , screen ) ;
sh = DisplayHeight ( dpy , screen ) ;
root = RootWindow ( dpy , screen ) ;
root = RootWindow ( dpy , screen ) ;
drw = drw_create ( dpy , screen , root , sw , sh ) ;
xinitvisual ( ) ;
drw = drw_create ( dpy , screen , root , sw , sh , visual , depth , cmap ) ;
if ( ! drw_fontset_create ( drw , fonts , LENGTH ( fonts ) ) )
if ( ! drw_fontset_create ( drw , fonts , LENGTH ( fonts ) ) )
die ( " no fonts could be loaded. " ) ;
die ( " no fonts could be loaded. " ) ;
lrpad = drw - > fonts - > h ;
lrpad = drw - > fonts - > h ;
@ -1734,7 +1743,7 @@ setup(void)
/* init appearance */
/* init appearance */
scheme = ecalloc ( LENGTH ( colors ) , sizeof ( Clr * ) ) ;
scheme = ecalloc ( LENGTH ( colors ) , sizeof ( Clr * ) ) ;
for ( i = 0 ; i < LENGTH ( colors ) ; i + + )
for ( i = 0 ; i < LENGTH ( colors ) ; i + + )
scheme [ i ] = drw_scm_create ( drw , colors [ i ] , 3 ) ;
scheme [ i ] = drw_scm_create ( drw , colors [ i ] , alphas [ i ] , 3 ) ;
/* init bars */
/* init bars */
updatebars ( ) ;
updatebars ( ) ;
updatestatus ( ) ;
updatestatus ( ) ;
@ -1992,16 +2001,18 @@ updatebars(void)
Monitor * m ;
Monitor * m ;
XSetWindowAttributes wa = {
XSetWindowAttributes wa = {
. override_redirect = True ,
. override_redirect = True ,
. background_pixmap = ParentRelative ,
. background_pixel = 0 ,
. border_pixel = 0 ,
. colormap = cmap ,
. event_mask = ButtonPressMask | ExposureMask
. event_mask = ButtonPressMask | ExposureMask
} ;
} ;
XClassHint ch = { " dwm " , " dwm " } ;
XClassHint ch = { " dwm " , " dwm " } ;
for ( m = mons ; m ; m = m - > next ) {
for ( m = mons ; m ; m = m - > next ) {
if ( m - > barwin )
if ( m - > barwin )
continue ;
continue ;
m - > barwin = XCreateWindow ( dpy , root , m - > wx , m - > by , m - > ww , bh , 0 , DefaultDepth ( dpy , screen ) ,
m - > barwin = XCreateWindow ( dpy , root , m - > wx , m - > by , m - > ww , bh , 0 , depth ,
CopyFromParent , DefaultVisual ( dpy , screen ) ,
InputOutput , visual ,
CWOverrideRedirect | CWBackPix map| CWEventMask , & wa ) ;
CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColor map| CWEventMask , & wa ) ;
XDefineCursor ( dpy , m - > barwin , cursor [ CurNormal ] - > cursor ) ;
XDefineCursor ( dpy , m - > barwin , cursor [ CurNormal ] - > cursor ) ;
XMapRaised ( dpy , m - > barwin ) ;
XMapRaised ( dpy , m - > barwin ) ;
XSetClassHint ( dpy , m - > barwin , & ch ) ;
XSetClassHint ( dpy , m - > barwin , & ch ) ;
@ -2346,6 +2357,43 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
return - 1 ;
return - 1 ;
}
}
void
xinitvisual ( )
{
XVisualInfo * infos ;
XRenderPictFormat * fmt ;
int nitems ;
int i ;
XVisualInfo tpl = {
. screen = screen ,
. depth = 32 ,
. class = TrueColor
} ;
long masks = VisualScreenMask | VisualDepthMask | VisualClassMask ;
infos = XGetVisualInfo ( dpy , masks , & tpl , & nitems ) ;
visual = NULL ;
for ( i = 0 ; i < nitems ; i + + ) {
fmt = XRenderFindVisualFormat ( dpy , infos [ i ] . visual ) ;
if ( fmt - > type = = PictTypeDirect & & fmt - > direct . alphaMask ) {
visual = infos [ i ] . visual ;
depth = infos [ i ] . depth ;
cmap = XCreateColormap ( dpy , root , visual , AllocNone ) ;
useargb = 1 ;
break ;
}
}
XFree ( infos ) ;
if ( ! visual ) {
visual = DefaultVisual ( dpy , screen ) ;
depth = DefaultDepth ( dpy , screen ) ;
cmap = DefaultColormap ( dpy , screen ) ;
}
}
void
void
zoom ( const Arg * arg )
zoom ( const Arg * arg )
{
{