From 5180613fe53e9453d19b286a856f000c5946c0de Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 16 Jan 2008 17:47:12 +0100 Subject: [PATCH] fix bug with statusbar recovering each others (FS#37) --- awesome.c | 5 +++- statusbar.c | 70 +++++++++++++++++++++++++++++++++++++---------------- statusbar.h | 3 ++- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/awesome.c b/awesome.c index d0df13e4c..59c2cb51d 100644 --- a/awesome.c +++ b/awesome.c @@ -136,7 +136,10 @@ setup(int screen) grabkeys(phys_screen); for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next) - statusbar_init(statusbar, screen); + statusbar_preinit(statusbar, screen); + + for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next) + statusbar_init(statusbar); } /** Startup Error handler to check if another window manager diff --git a/statusbar.c b/statusbar.c index 9ccd6947e..859787333 100644 --- a/statusbar.c +++ b/statusbar.c @@ -33,29 +33,38 @@ extern AwesomeConf globalconf; static void statusbar_update_position(Statusbar *statusbar) { - Area area = get_screen_area(statusbar->screen, - NULL, - &globalconf.screens[statusbar->screen].padding); + Area area; XMapRaised(globalconf.display, statusbar->window); + + /* Top and Bottom Statusbar have prio */ + if(statusbar->position == Top || statusbar->position == Bottom) + area = get_screen_area(statusbar->screen, + NULL, + &globalconf.screens[statusbar->screen].padding); + else + area = get_screen_area(statusbar->screen, + globalconf.screens[statusbar->screen].statusbar, + &globalconf.screens[statusbar->screen].padding); + switch(statusbar->position) { - default: + case Top: XMoveWindow(globalconf.display, statusbar->window, area.x, area.y); break; - case Left: - XMoveWindow(globalconf.display, statusbar->window, - area.x, (area.y + area.height) - statusbar->width); - break; - case Right: - XMoveWindow(globalconf.display, statusbar->window, - area.x + (area.width - statusbar->height), area.y); - break; case Bottom: XMoveWindow(globalconf.display, statusbar->window, area.x, area.height - statusbar->height); break; + case Left: + XMoveWindow(globalconf.display, statusbar->window, + area.x - statusbar->height, (area.y + area.height) - statusbar->width); + break; + case Right: + XMoveWindow(globalconf.display, statusbar->window, + area.x + area.width, area.y); + break; case Off: XUnmapWindow(globalconf.display, statusbar->window); break; @@ -153,24 +162,45 @@ statusbar_display(Statusbar *statusbar) } void -statusbar_init(Statusbar *statusbar, int screen) +statusbar_preinit(Statusbar *statusbar, int screen) { Widget *widget; - XSetWindowAttributes wa; - int phys_screen = get_phys_screen(screen); - Area area = get_screen_area(screen, - globalconf.screens[screen].statusbar, - &globalconf.screens[screen].padding); + + statusbar->screen = screen; if(statusbar->height <= 0) { /* 1.5 as default factor, it fits nice but no one know why */ - statusbar->height = globalconf.screens[screen].font->height * 1.5; + statusbar->height = globalconf.screens[statusbar->screen].font->height * 1.5; for(widget = statusbar->widgets; widget; widget = widget->next) if(widget->font) statusbar->height = MAX(statusbar->height, widget->font->height * 1.5); } +} + +void +statusbar_init(Statusbar *statusbar) +{ + Statusbar *sb; + XSetWindowAttributes wa; + int phys_screen = get_phys_screen(statusbar->screen); + Area area = get_screen_area(statusbar->screen, + globalconf.screens[statusbar->screen].statusbar, + &globalconf.screens[statusbar->screen].padding); + + + /* Top and Bottom Statusbar have prio */ + for(sb = globalconf.screens[statusbar->screen].statusbar; sb; sb = sb->next) + switch(sb->position) + { + case Left: + case Right: + area.width += sb->height; + break; + default: + break; + } if(statusbar->width <= 0) { @@ -180,8 +210,6 @@ statusbar_init(Statusbar *statusbar, int screen) statusbar->width = area.width; } - statusbar->screen = screen; - wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; wa.cursor = globalconf.cursor[CurNormal]; diff --git a/statusbar.h b/statusbar.h index cdc78f987..d2be6240d 100644 --- a/statusbar.h +++ b/statusbar.h @@ -25,7 +25,8 @@ #include "structs.h" void statusbar_refresh(void); -void statusbar_init(Statusbar *, int); +void statusbar_preinit(Statusbar *, int); +void statusbar_init(Statusbar *); void statusbar_display(Statusbar *); Position statusbar_get_position_from_str(const char *);