Make "Statusbar statusbar" the in VirtScreen "Statusbar *statusbar". This is

more consistent with the rest of the interface, and will make our life easier
when we have mulitiple statusbars per screen.
This commit is contained in:
Aldo Cortesi 2007-12-18 18:17:46 +11:00 committed by Julien Danjou
parent 21fe1add9e
commit 205f2c55ca
17 changed files with 74 additions and 73 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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"))

View File

@ -211,7 +211,7 @@ typedef struct
/** Layout list */
Layout *layouts;
/** Status bar */
Statusbar statusbar;
Statusbar *statusbar;
/** Padding */
Padding padding;
/** Font */

30
event.c
View File

@ -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);
}

View File

@ -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,

View File

@ -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;

View File

@ -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))

View File

@ -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))

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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 *

View File

@ -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],

View File

@ -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],

View File

@ -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]);