Clean interface of statusbar_init.

This commit is contained in:
Aldo Cortesi 2007-12-19 15:16:49 +11:00 committed by Julien Danjou
parent 7190e4fa48
commit 4d4001b41f
3 changed files with 44 additions and 19 deletions

View File

@ -227,9 +227,7 @@ static void
setup_screen(int screen) setup_screen(int screen)
{ {
setup(screen); setup(screen);
statusbar_init(globalconf.display, screen, globalconf.screens[screen].statusbar, statusbar_init(screen);
globalconf.cursor[CurNormal], globalconf.screens[screen].font,
&globalconf.screens[screen].padding);
} }
/** Startup Error handler to check if another window manager /** Startup Error handler to check if another window manager

View File

@ -99,13 +99,16 @@ statusbar_draw(int screen)
} }
void void
statusbar_init(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, XftFont *font, Padding *padding) statusbar_init(int screen)
{ {
XSetWindowAttributes wa; XSetWindowAttributes wa;
int phys_screen = get_phys_screen(screen); int phys_screen = get_phys_screen(screen);
ScreenInfo *si = get_screen_info(screen, NULL, padding); ScreenInfo *si = get_screen_info(screen,
NULL,
&globalconf.screens[screen].padding);
Statusbar *statusbar = globalconf.screens[screen].statusbar;
statusbar->height = font->height * 1.5; statusbar->height = globalconf.screens[screen].font->height * 1.5;
if(statusbar->position == BarRight || statusbar->position == BarLeft) if(statusbar->position == BarRight || statusbar->position == BarLeft)
statusbar->width = si[screen].height; statusbar->width = si[screen].height;
@ -118,30 +121,54 @@ statusbar_init(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, X
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask; | EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
wa.cursor = cursor; wa.cursor = globalconf.cursor[CurNormal];
wa.override_redirect = 1; wa.override_redirect = 1;
wa.background_pixmap = ParentRelative; wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask; wa.event_mask = ButtonPressMask | ExposureMask;
if(statusbar->dposition == BarRight || statusbar->dposition == BarLeft) if(statusbar->dposition == BarRight || statusbar->dposition == BarLeft)
statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0, statusbar->window = XCreateWindow(globalconf.display,
RootWindow(globalconf.display,
phys_screen),
0, 0,
statusbar->height, statusbar->height,
statusbar->width, statusbar->width,
0, DefaultDepth(disp, phys_screen), CopyFromParent, 0,
DefaultVisual(disp, phys_screen), DefaultDepth(globalconf.display,
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); phys_screen),
CopyFromParent,
DefaultVisual(globalconf.display,
phys_screen),
CWOverrideRedirect |
CWBackPixmap |
CWEventMask,
&wa);
else else
statusbar->window = XCreateWindow(disp, RootWindow(disp, phys_screen), 0, 0, statusbar->window = XCreateWindow(globalconf.display,
RootWindow(globalconf.display,
phys_screen),
0, 0,
statusbar->width, statusbar->width,
statusbar->height, statusbar->height,
0, DefaultDepth(disp, phys_screen), CopyFromParent, 0,
DefaultVisual(disp, phys_screen), DefaultDepth(globalconf.display,
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); phys_screen),
XDefineCursor(disp, statusbar->window, cursor); CopyFromParent,
DefaultVisual(globalconf.display,
phys_screen),
CWOverrideRedirect |
CWBackPixmap |
CWEventMask,
&wa);
XDefineCursor(globalconf.display,
statusbar->window,
globalconf.cursor[CurNormal]);
calculate_alignments(statusbar->widgets); calculate_alignments(statusbar->widgets);
statusbar_update_position(disp, statusbar, padding); statusbar_update_position(globalconf.display,
XMapRaised(disp, statusbar->window); statusbar,
&globalconf.screens[screen].padding);
XMapRaised(globalconf.display, statusbar->window);
} }
void void

View File

@ -24,7 +24,7 @@
#include "common.h" #include "common.h"
void statusbar_init(Display *, int, Statusbar *, Cursor, XftFont *, Padding *); void statusbar_init(int);
void statusbar_draw(int); void statusbar_draw(int);
int statusbar_get_position_from_str(const char *); int statusbar_get_position_from_str(const char *);
void statusbar_update_position(Display *, Statusbar*, Padding *); void statusbar_update_position(Display *, Statusbar*, Padding *);