diff --git a/awesome.c b/awesome.c index 3d6e8cfa6..6cccd7374 100644 --- a/awesome.c +++ b/awesome.c @@ -156,18 +156,7 @@ setup(Display *disp, DC *drawcontext, awesome_config *awesomeconf) compileregs(awesomeconf->rules, awesomeconf->nrules); /* bar */ drawcontext->h = awesomeconf->statusbar.height = drawcontext->font.height + 2; - wa.override_redirect = 1; - wa.background_pixmap = ParentRelative; - wa.event_mask = ButtonPressMask | ExposureMask; - awesomeconf->statusbar.window = XCreateWindow(disp, DefaultRootWindow(disp), 0, 0, DisplayWidth(disp, DefaultScreen(disp)), awesomeconf->statusbar.height, 0, - DefaultDepth(disp, DefaultScreen(disp)), CopyFromParent, - DefaultVisual(disp, DefaultScreen(disp)), - CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); - XDefineCursor(disp, awesomeconf->statusbar.window, drawcontext->cursor[CurNormal]); - updatebarpos(disp, awesomeconf->statusbar); - XMapRaised(disp, awesomeconf->statusbar.window); - /* pixmap for everything */ - awesomeconf->statusbar.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), DisplayWidth(disp, DefaultScreen(disp)), awesomeconf->statusbar.height, DefaultDepth(disp, DefaultScreen(disp))); + initstatusbar(disp, DefaultScreen(disp), drawcontext, &awesomeconf->statusbar); drawcontext->gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0); XSetLineAttributes(disp, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter); if(!drawcontext->font.set) diff --git a/statusbar.c b/statusbar.c index f5a40fa40..46455265e 100644 --- a/statusbar.c +++ b/statusbar.c @@ -88,6 +88,29 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf) XSync(disp, False); } +void +initstatusbar(Display *disp, int screen, DC *drawcontext, Statusbar *statusbar) +{ + XSetWindowAttributes wa; + + wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask + | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; + wa.cursor = drawcontext->cursor[CurNormal]; + wa.override_redirect = 1; + wa.background_pixmap = ParentRelative; + wa.event_mask = ButtonPressMask | ExposureMask; + statusbar->window = XCreateWindow(disp, RootWindow(disp, screen), 0, 0, DisplayWidth(disp, screen), + statusbar->height, 0, DefaultDepth(disp, screen), CopyFromParent, + DefaultVisual(disp, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); + XDefineCursor(disp, statusbar->window, drawcontext->cursor[CurNormal]); + updatebarpos(disp, *statusbar); + XMapRaised(disp, statusbar->window); + statusbar->drawable = XCreatePixmap(disp, + RootWindow(disp, screen), + DisplayWidth(disp, screen), + statusbar->height, + DefaultDepth(disp, screen)); +} void updatebarpos(Display *disp, Statusbar statusbar) diff --git a/statusbar.h b/statusbar.h index ae41e2a04..4e4060bcd 100644 --- a/statusbar.h +++ b/statusbar.h @@ -24,6 +24,7 @@ #include "config.h" +void initstatusbar(Display *, int, DC *, Statusbar *); void drawstatusbar(Display *, DC *, awesome_config *); void updatebarpos(Display *, Statusbar); void uicb_togglebar(Display *, DC *, awesome_config *, const char *);