diff --git a/awesome.c b/awesome.c index b3411aff..3bd1c3cd 100644 --- a/awesome.c +++ b/awesome.c @@ -225,7 +225,7 @@ static void setup_screen(int screen) { setup(screen); - statusbar_init(globalconf.display, screen, &globalconf.screens[screen].statusbar, + statusbar_init(globalconf.display, screen, globalconf.screens[screen].statusbar, globalconf.cursor[CurNormal], globalconf.screens[screen].font, &globalconf.screens[screen].padding); } diff --git a/client.c b/client.c index 63c521a3..47f7c65c 100644 --- a/client.c +++ b/client.c @@ -292,7 +292,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) } else { - ScreenInfo *display_info = get_display_info(c->display, c->phys_screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + ScreenInfo *display_info = get_display_info(c->display, c->phys_screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); if(c->x + c->w + 2 * c->border > display_info->x_org + display_info->width) c->x = c->rx = display_info->x_org + display_info->width - c->w - 2 * c->border; diff --git a/config.c b/config.c index 89640c33..3ff261bc 100644 --- a/config.c +++ b/config.c @@ -562,10 +562,11 @@ config_parse(const char *confpatharg) cfg_getstr(cfg_colors, "focus_fg")); /* Statusbar */ - virtscreen->statusbar.position = virtscreen->statusbar.dposition = + virtscreen->statusbar = p_new(Statusbar, 1); + virtscreen->statusbar->position = virtscreen->statusbar->dposition = statusbar_get_position_from_str(cfg_getstr(cfg_statusbar, "position")); - create_widgets(cfg_statusbar, &virtscreen->statusbar); + create_widgets(cfg_statusbar, virtscreen->statusbar); /* Layouts */ if(cfg_size(cfg_layouts, "layout")) diff --git a/config.h b/config.h index a1628e7f..f6833151 100644 --- a/config.h +++ b/config.h @@ -211,7 +211,7 @@ typedef struct /** Layout list */ Layout *layouts; /** Status bar */ - Statusbar statusbar; + Statusbar *statusbar; /** Padding */ Padding padding; /** Font */ diff --git a/event.c b/event.c index 93b2b871..64dbade2 100644 --- a/event.c +++ b/event.c @@ -71,28 +71,28 @@ handle_event_buttonpress(XEvent * e) XButtonPressedEvent *ev = &e->xbutton; for(screen = 0; screen < get_screen_count(e->xany.display); screen++) - if(globalconf.screens[screen].statusbar.window == ev->window) + if(globalconf.screens[screen].statusbar->window == ev->window) { for(i = 1, tag = globalconf.screens[screen].tags; tag; tag = tag->next, i++) { x += textwidth_primitive(e->xany.display, globalconf.screens[screen].font, tag->name); - if(((globalconf.screens[screen].statusbar.position == BarTop - || globalconf.screens[screen].statusbar.position == BarBot) + if(((globalconf.screens[screen].statusbar->position == BarTop + || globalconf.screens[screen].statusbar->position == BarBot) && ev->x < x) - || (globalconf.screens[screen].statusbar.position == BarRight && ev->y < x) - || (globalconf.screens[screen].statusbar.position == BarLeft && ev->y > globalconf.screens[screen].statusbar.width - x)) + || (globalconf.screens[screen].statusbar->position == BarRight && ev->y < x) + || (globalconf.screens[screen].statusbar->position == BarLeft && ev->y > globalconf.screens[screen].statusbar->width - x)) { snprintf(arg, sizeof(arg), "%d", i); handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.tag, arg); return; } } - x += globalconf.screens[screen].statusbar.txtlayoutwidth; - if(((globalconf.screens[screen].statusbar.position == BarTop - || globalconf.screens[screen].statusbar.position == BarBot) + x += globalconf.screens[screen].statusbar->txtlayoutwidth; + if(((globalconf.screens[screen].statusbar->position == BarTop + || globalconf.screens[screen].statusbar->position == BarBot) && ev->x < x) - || (globalconf.screens[screen].statusbar.position == BarRight && ev->y < x) - || (globalconf.screens[screen].statusbar.position == BarLeft && ev->y > globalconf.screens[screen].statusbar.width - x)) + || (globalconf.screens[screen].statusbar->position == BarRight && ev->y < x) + || (globalconf.screens[screen].statusbar->position == BarLeft && ev->y > globalconf.screens[screen].statusbar->width - x)) handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.layout, NULL); else handle_mouse_button_press(screen, ev->button, ev->state, globalconf.buttons.title, NULL); @@ -197,13 +197,13 @@ handle_event_configurenotify(XEvent * e) /* update statusbar */ si = get_screen_info(e->xany.display, screen, NULL, &globalconf.screens[screen].padding); - globalconf.screens[screen].statusbar.width = si[screen].width; + globalconf.screens[screen].statusbar->width = si[screen].width; p_delete(&si); XResizeWindow(e->xany.display, - globalconf.screens[screen].statusbar.window, - globalconf.screens[screen].statusbar.width, - globalconf.screens[screen].statusbar.height); + globalconf.screens[screen].statusbar->window, + globalconf.screens[screen].statusbar->width, + globalconf.screens[screen].statusbar->height); statusbar_update_position(e->xany.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); arrange(screen); @@ -250,7 +250,7 @@ handle_event_expose(XEvent * e) if(!ev->count) for(screen = 0; screen < get_screen_count(e->xany.display); screen++) - if(globalconf.screens[screen].statusbar.window == ev->window) + if(globalconf.screens[screen].statusbar->window == ev->window) statusbar_draw(screen); } diff --git a/layout.c b/layout.c index d6bae16d..65d77bc8 100644 --- a/layout.c +++ b/layout.c @@ -180,7 +180,7 @@ restack(int screen) if(!(get_current_layout(screen)->arrange == layout_floating)) { wc.stack_mode = Below; - wc.sibling = globalconf.screens[screen].statusbar.window; + wc.sibling = globalconf.screens[screen].statusbar->window; if(!sel->isfloating) { XConfigureWindow(sel->display, sel->win, CWSibling | CWStackMode, &wc); @@ -280,7 +280,7 @@ maximize(int x, int y, int w, int h, int screen) void uicb_client_togglemax(int screen, char *arg __attribute__ ((unused))) { - ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + ScreenInfo *si = get_screen_info(globalconf.display, screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); maximize(si[screen].x_org, si[screen].y_org, si[screen].width - 2 * globalconf.screens[screen].borderpx, @@ -293,7 +293,7 @@ void uicb_client_toggleverticalmax(int screen, char *arg __attribute__ ((unused))) { Client *sel = globalconf.focus->client; - ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + ScreenInfo *si = get_screen_info(globalconf.display, screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); if(sel) maximize(sel->x, @@ -309,7 +309,7 @@ void uicb_client_togglehorizontalmax(int screen, char *arg __attribute__ ((unused))) { Client *sel = globalconf.focus->client; - ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + ScreenInfo *si = get_screen_info(globalconf.display, screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); if(sel) maximize(si[screen].x_org, diff --git a/layouts/fibonacci.c b/layouts/fibonacci.c index 09c7ad1b..87b49e82 100644 --- a/layouts/fibonacci.c +++ b/layouts/fibonacci.c @@ -32,7 +32,7 @@ layout_fibonacci(int screen, int shape) int n = 0, i = 0, nx, ny, nw, nh; Client *c; ScreenInfo *si = get_screen_info(globalconf.display, screen, - &globalconf.screens[screen].statusbar, + globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); nx = si[screen].x_org; diff --git a/layouts/max.c b/layouts/max.c index aba414a0..74cfae1f 100644 --- a/layouts/max.c +++ b/layouts/max.c @@ -30,7 +30,7 @@ void layout_max(int screen) { Client *c; - ScreenInfo *si = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + ScreenInfo *si = get_screen_info(globalconf.display, screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); for(c = globalconf.clients; c; c = c->next) if(IS_TILED(c, screen)) diff --git a/layouts/tile.c b/layouts/tile.c index e2a771bd..7844e10f 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -103,7 +103,7 @@ _tile(int screen, const Bool right) Client *c; Tag *curtag = get_current_tag(screen); - screens_info = get_screen_info(globalconf.display, screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + screens_info = get_screen_info(globalconf.display, screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); for(n = 0, c = globalconf.clients; c; c = c->next) if(IS_TILED(c, screen)) diff --git a/mouse.c b/mouse.c index 20d4429f..cec9eb01 100644 --- a/mouse.c +++ b/mouse.c @@ -49,7 +49,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) else restack(screen); - si = get_screen_info(c->display, c->screen, &globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); + si = get_screen_info(c->display, c->screen, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); ocx = nx = c->x; ocy = ny = c->y; diff --git a/statusbar.c b/statusbar.c index 04c8c607..a8a98995 100644 --- a/statusbar.c +++ b/statusbar.c @@ -42,57 +42,57 @@ statusbar_draw(int screen) vscreen = globalconf.screens[screen]; /* don't waste our time */ - if(vscreen.statusbar.position == BarOff) + if(vscreen.statusbar->position == BarOff) return; DrawCtx *ctx = draw_get_context(globalconf.display, phys_screen, - vscreen.statusbar.width, - vscreen.statusbar.height); + vscreen.statusbar->width, + vscreen.statusbar->height); drawrectangle(ctx, 0, 0, - vscreen.statusbar.width, - vscreen.statusbar.height, + vscreen.statusbar->width, + vscreen.statusbar->height, True, vscreen.colors_normal[ColBG]); - for(widget = vscreen.statusbar.widgets; widget; widget = widget->next) + for(widget = vscreen.statusbar->widgets; widget; widget = widget->next) if (widget->alignment == AlignLeft) left += widget->draw(widget, ctx, left, (left + right)); else if (widget->alignment == AlignRight) right += widget->draw(widget, ctx, right, (left + right)); - for(widget = vscreen.statusbar.widgets; widget; widget = widget->next) + for(widget = vscreen.statusbar->widgets; widget; widget = widget->next) if (widget->alignment == AlignFlex) left += widget->draw(widget, ctx, left, (left + right)); - if(vscreen.statusbar.position == BarRight || - vscreen.statusbar.position == BarLeft) + if(vscreen.statusbar->position == BarRight || + vscreen.statusbar->position == BarLeft) { Drawable d; - if(vscreen.statusbar.position == BarRight) + if(vscreen.statusbar->position == BarRight) d = draw_rotate(ctx, phys_screen, M_PI_2, - vscreen.statusbar.height, + vscreen.statusbar->height, 0); else d = draw_rotate(ctx, phys_screen, - M_PI_2, 0, - vscreen.statusbar.width); + vscreen.statusbar->width); XCopyArea(globalconf.display, d, - vscreen.statusbar.window, + vscreen.statusbar->window, DefaultGC(globalconf.display, phys_screen), 0, 0, - vscreen.statusbar.height, - vscreen.statusbar.width, 0, 0); + vscreen.statusbar->height, + vscreen.statusbar->width, 0, 0); XFreePixmap(globalconf.display, d); } else XCopyArea(globalconf.display, ctx->drawable, - vscreen.statusbar.window, + vscreen.statusbar->window, DefaultGC(globalconf.display, phys_screen), 0, 0, - vscreen.statusbar.width, vscreen.statusbar.height, 0, 0); + vscreen.statusbar->width, vscreen.statusbar->height, 0, 0); draw_free_context(ctx); XSync(globalconf.display, False); @@ -140,30 +140,30 @@ statusbar_init(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, X calculate_alignments(statusbar->widgets); - statusbar_update_position(disp, *statusbar, padding); + statusbar_update_position(disp, statusbar, padding); XMapRaised(disp, statusbar->window); } void -statusbar_update_position(Display *disp, Statusbar statusbar, Padding *padding) +statusbar_update_position(Display *disp, Statusbar *statusbar, Padding *padding) { XEvent ev; - ScreenInfo *si = get_screen_info(disp, statusbar.screen, NULL, padding); + ScreenInfo *si = get_screen_info(disp, statusbar->screen, NULL, padding); - XMapRaised(disp, statusbar.window); - switch (statusbar.position) + XMapRaised(disp, statusbar->window); + switch (statusbar->position) { default: - XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].y_org); + XMoveWindow(disp, statusbar->window, si[statusbar->screen].x_org, si[statusbar->screen].y_org); break; case BarRight: - XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org + (si[statusbar.screen].width - statusbar.height), si[statusbar.screen].y_org); + XMoveWindow(disp, statusbar->window, si[statusbar->screen].x_org + (si[statusbar->screen].width - statusbar->height), si[statusbar->screen].y_org); break; case BarBot: - XMoveWindow(disp, statusbar.window, si[statusbar.screen].x_org, si[statusbar.screen].height - statusbar.height); + XMoveWindow(disp, statusbar->window, si[statusbar->screen].x_org, si[statusbar->screen].height - statusbar->height); break; case BarOff: - XUnmapWindow(disp, statusbar.window); + XUnmapWindow(disp, statusbar->window); break; } p_delete(&si); @@ -188,10 +188,10 @@ statusbar_get_position_from_str(const char * pos) void uicb_statusbar_toggle(int screen, char *arg __attribute__ ((unused))) { - if(globalconf.screens[screen].statusbar.position == BarOff) - globalconf.screens[screen].statusbar.position = (globalconf.screens[screen].statusbar.dposition == BarOff) ? BarTop : globalconf.screens[screen].statusbar.dposition; + if(globalconf.screens[screen].statusbar->position == BarOff) + globalconf.screens[screen].statusbar->position = (globalconf.screens[screen].statusbar->dposition == BarOff) ? BarTop : globalconf.screens[screen].statusbar->dposition; else - globalconf.screens[screen].statusbar.position = BarOff; + globalconf.screens[screen].statusbar->position = BarOff; statusbar_update_position(globalconf.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); arrange(screen); } @@ -199,8 +199,8 @@ uicb_statusbar_toggle(int screen, char *arg __attribute__ ((unused))) void uicb_statusbar_set_position(int screen, char *arg) { - globalconf.screens[screen].statusbar.dposition = - globalconf.screens[screen].statusbar.position = + globalconf.screens[screen].statusbar->dposition = + globalconf.screens[screen].statusbar->position = statusbar_get_position_from_str(arg); statusbar_update_position(globalconf.display, globalconf.screens[screen].statusbar, &globalconf.screens[screen].padding); } diff --git a/statusbar.h b/statusbar.h index 79eb92ab..87e84bd3 100644 --- a/statusbar.h +++ b/statusbar.h @@ -27,7 +27,7 @@ void statusbar_init(Display *, int, Statusbar *, Cursor, XftFont *, Padding *); void statusbar_draw(int); int statusbar_get_position_from_str(const char *); -void statusbar_update_position(Display *, Statusbar, Padding *); +void statusbar_update_position(Display *, Statusbar*, Padding *); UICB_PROTO(uicb_statusbar_toggle); UICB_PROTO(uicb_statusbar_set_position); diff --git a/widget.c b/widget.c index 25486ddf..d202d92a 100644 --- a/widget.c +++ b/widget.c @@ -49,7 +49,7 @@ static Widget * find_widget(char *name, int screen) { Widget *widget; - widget = globalconf.screens[screen].statusbar.widgets; + widget = globalconf.screens[screen].statusbar->widgets; for(; widget; widget = widget->next) if (strcmp(name, widget->name) == 0) return widget; diff --git a/widgets/focustitle.c b/widgets/focustitle.c index e05e50d1..e4ba8e72 100644 --- a/widgets/focustitle.c +++ b/widgets/focustitle.c @@ -13,15 +13,15 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used) VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; Client *sel = focus_get_latest_client_for_tag(widget->statusbar->screen, get_current_tag(widget->statusbar->screen)); - int location = calculate_offset(vscreen.statusbar.width, + int location = calculate_offset(vscreen.statusbar->width, 0, offset, widget->alignment); if(sel) { - drawtext(ctx, location, 0, vscreen.statusbar.width - used, - vscreen.statusbar.height, vscreen.font, sel->name, + drawtext(ctx, location, 0, vscreen.statusbar->width - used, + vscreen.statusbar->height, vscreen.font, sel->name, vscreen.colors_selected[ColFG], vscreen.colors_selected[ColBG]); if(sel->isfloating) @@ -31,11 +31,11 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used) vscreen.colors_selected[ColFG]); } else - drawtext(ctx, location, 0, vscreen.statusbar.width - used, - vscreen.statusbar.height, vscreen.font, NULL, + drawtext(ctx, location, 0, vscreen.statusbar->width - used, + vscreen.statusbar->height, vscreen.font, NULL, vscreen.colors_normal[ColFG], vscreen.colors_normal[ColBG]); - return vscreen.statusbar.width - used; + return vscreen.statusbar->width - used; } Widget * diff --git a/widgets/layoutinfo.c b/widgets/layoutinfo.c index 405c55bc..a4ed159a 100644 --- a/widgets/layoutinfo.c +++ b/widgets/layoutinfo.c @@ -16,13 +16,13 @@ layoutinfo_draw(Widget *widget, Layout *l; for(l = vscreen.layouts ; l; l = l->next) width = MAX(width, (textwidth(ctx, vscreen.font, l->symbol))); - location = calculate_offset(vscreen.statusbar.width, + location = calculate_offset(vscreen.statusbar->width, width, offset, widget->alignment); drawtext(ctx, location, 0, width, - vscreen.statusbar.height, + vscreen.statusbar->height, vscreen.font, get_current_layout(widget->statusbar->screen)->symbol, vscreen.colors_normal[ColFG], diff --git a/widgets/taglist.c b/widgets/taglist.c index f5e49c07..ab8e585c 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -42,7 +42,7 @@ taglist_draw(Widget *widget, { width += textwidth(ctx, vscreen.font, tag->name); } - location = calculate_offset(vscreen.statusbar.width, + location = calculate_offset(vscreen.statusbar->width, width, offset, widget->alignment); @@ -56,7 +56,7 @@ taglist_draw(Widget *widget, else colors = vscreen.colors_normal; drawtext(ctx, location + width, 0, w, - vscreen.statusbar.height, + vscreen.statusbar->height, vscreen.font, tag->name, colors[ColFG], diff --git a/widgets/textbox.c b/widgets/textbox.c index 593cad1e..f949860b 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -31,11 +31,11 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, Data *d; d = (Data*) widget->data; width = textwidth(ctx, vscreen.font, d->text); - location = calculate_offset(vscreen.statusbar.width, + location = calculate_offset(vscreen.statusbar->width, width, offset, widget->alignment); - drawtext(ctx, location, 0, width, vscreen.statusbar.height, + drawtext(ctx, location, 0, width, vscreen.statusbar->height, vscreen.font, d->text, vscreen.colors_normal[ColFG], vscreen.colors_normal[ColBG]);