From 48f17aa9f110461cffaf8e597a544821e0347bcf Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 15 Sep 2007 22:25:49 +0200 Subject: [PATCH] add initstatusbar() to init statusbar! --- awesome.c | 13 +------------ statusbar.c | 23 +++++++++++++++++++++++ statusbar.h | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/awesome.c b/awesome.c index 3d6e8cfa..6cccd737 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 f5a40fa4..46455265 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 ae41e2a0..4e4060bc 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 *);