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);
statusbar_init(globalconf.display, screen, globalconf.screens[screen].statusbar,
globalconf.cursor[CurNormal], globalconf.screens[screen].font,
&globalconf.screens[screen].padding);
statusbar_init(screen);
}
/** Startup Error handler to check if another window manager

View file

@ -99,13 +99,16 @@ statusbar_draw(int screen)
}
void
statusbar_init(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, XftFont *font, Padding *padding)
statusbar_init(int screen)
{
XSetWindowAttributes wa;
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)
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
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
wa.cursor = cursor;
wa.cursor = globalconf.cursor[CurNormal];
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask;
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->width,
0, DefaultDepth(disp, phys_screen), CopyFromParent,
DefaultVisual(disp, phys_screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
0,
DefaultDepth(globalconf.display,
phys_screen),
CopyFromParent,
DefaultVisual(globalconf.display,
phys_screen),
CWOverrideRedirect |
CWBackPixmap |
CWEventMask,
&wa);
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->height,
0, DefaultDepth(disp, phys_screen), CopyFromParent,
DefaultVisual(disp, phys_screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(disp, statusbar->window, cursor);
0,
DefaultDepth(globalconf.display,
phys_screen),
CopyFromParent,
DefaultVisual(globalconf.display,
phys_screen),
CWOverrideRedirect |
CWBackPixmap |
CWEventMask,
&wa);
XDefineCursor(globalconf.display,
statusbar->window,
globalconf.cursor[CurNormal]);
calculate_alignments(statusbar->widgets);
statusbar_update_position(disp, statusbar, padding);
XMapRaised(disp, statusbar->window);
statusbar_update_position(globalconf.display,
statusbar,
&globalconf.screens[screen].padding);
XMapRaised(globalconf.display, statusbar->window);
}
void

View file

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