use 2 vars for knowing if users supplied coords
This commit is contained in:
parent
a34d1bc583
commit
609318cbec
3
config.h
3
config.h
|
@ -106,6 +106,9 @@ struct Widget
|
|||
Alignment alignment;
|
||||
/** Misc private data */
|
||||
void *data;
|
||||
/** True if user supplied coords */
|
||||
Bool user_supplied_x;
|
||||
Bool user_supplied_y;
|
||||
/** Area */
|
||||
Area area;
|
||||
/** Buttons bindings */
|
||||
|
|
2
widget.c
2
widget.c
|
@ -117,6 +117,8 @@ widget_common_new(Widget *widget, Statusbar *statusbar, cfg_t* config)
|
|||
widget->button_press = widget_common_button_press;
|
||||
widget->area.x = cfg_getint(config, "x");
|
||||
widget->area.y = cfg_getint(config, "y");
|
||||
widget->user_supplied_x = (widget->area.x >= 0);
|
||||
widget->user_supplied_y = (widget->area.y >= 0);
|
||||
}
|
||||
|
||||
/** Send command to widget
|
||||
|
|
|
@ -43,32 +43,31 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
{
|
||||
Data *d = widget->data;
|
||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||
Area widget_area = widget->area;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
if(sel)
|
||||
{
|
||||
draw_text(ctx, widget_area.x, widget_area.y,
|
||||
draw_text(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->width - used,
|
||||
widget->statusbar->height,
|
||||
d->align,
|
||||
widget->font->height / 2, widget->font, sel->name,
|
||||
d->fg, d->bg);
|
||||
if(sel->isfloating)
|
||||
draw_circle(ctx, widget_area.x, widget_area.y,
|
||||
draw_circle(ctx, widget->area.x, widget->area.y,
|
||||
(widget->font->height + 2) / 4,
|
||||
sel->ismax, d->fg);
|
||||
}
|
||||
else
|
||||
draw_rectangle(ctx, widget_area.x, widget_area.y,
|
||||
draw_rectangle(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->width - used, widget->statusbar->height, True, d->bg);
|
||||
|
||||
widget->area.width = widget->statusbar->width - used;
|
||||
|
|
|
@ -35,23 +35,23 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Data *d = widget->data;
|
||||
Area area = draw_get_image_size(d->image), widget_area = widget->area;
|
||||
Area area = draw_get_image_size(d->image);
|
||||
|
||||
if(d->resize)
|
||||
widget->area.width = ((double) widget->statusbar->height / area.height) * area.width;
|
||||
else
|
||||
widget->area.width = area.width;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
draw_image(ctx, widget_area.x, widget_area.y,
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
d->resize ? widget->statusbar->height : 0, d->image);
|
||||
|
||||
return widget->area.width;
|
||||
|
|
|
@ -34,20 +34,19 @@ layoutinfo_draw(Widget *widget,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Tag **curtags = get_current_tags(widget->statusbar->screen);
|
||||
Area widget_area = widget->area;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->statusbar->height,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
widget->area.width = widget->statusbar->height;
|
||||
|
||||
draw_image(ctx, widget_area.x, widget_area.y,
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->height,
|
||||
curtags[0]->layout->image);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ static int
|
|||
netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Area area, widget_area = widget->area;
|
||||
Area area;
|
||||
Rule* r;
|
||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||
NetWMIcon *icon;
|
||||
|
@ -51,15 +51,15 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
area = draw_get_image_size(r->icon);
|
||||
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
||||
* area.width;
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
draw_image(ctx, widget_area.x, widget_area.y,
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->height, r->icon);
|
||||
|
||||
return widget->area.width;
|
||||
|
@ -74,17 +74,17 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
|
||||
widget->area.width = ((double) widget->statusbar->height / (double) icon->height) * icon->width;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
draw_image_from_argb_data(ctx,
|
||||
widget_area.x, widget_area.y,
|
||||
widget->area.x, widget->area.y,
|
||||
icon->width, icon->height,
|
||||
widget->statusbar->height, icon->image);
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
int i, width, pwidth, margin_top, pb_height, left_offset;
|
||||
Area widget_area = widget->area;
|
||||
|
||||
Data *d = widget->data;
|
||||
|
||||
|
@ -64,18 +63,18 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
|
||||
width = d->width - d->lpadding;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
d->width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
margin_top = (int) (widget->statusbar->height * (1 - d->height)) / 2 + 0.5 + widget_area.y;
|
||||
margin_top = (int) (widget->statusbar->height * (1 - d->height)) / 2 + 0.5 + widget->area.y;
|
||||
pb_height = (int) (widget->statusbar->height * d->height - (d->gap * (d->bars - 1))) / d->bars + 0.5;
|
||||
left_offset = widget_area.x + d->lpadding;
|
||||
left_offset = widget->area.x + d->lpadding;
|
||||
|
||||
for(i = 0; i < d->bars; i++)
|
||||
{
|
||||
|
|
|
@ -75,12 +75,13 @@ taglist_draw(Widget *widget,
|
|||
for(tag = vscreen.tags; tag; tag = tag->next)
|
||||
widget->area.width += textwidth(vscreen.font, tag->name) + vscreen.font->height;
|
||||
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
widget->area.width = 0;
|
||||
|
|
|
@ -67,14 +67,14 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
|
||||
box_width = (widget->statusbar->width - used) / n;
|
||||
|
||||
if(widget->area.x < 0)
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
0,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(widget->area.y < 0)
|
||||
widget->area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = widget->area.y = 0;
|
||||
|
||||
for(c = globalconf.clients; c; c = c->next)
|
||||
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen))
|
||||
|
|
|
@ -40,22 +40,21 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
int used __attribute__ ((unused)))
|
||||
{
|
||||
Data *d = widget->data;
|
||||
Area widget_area = widget->area;
|
||||
|
||||
if(d->width)
|
||||
widget->area.width = d->width;
|
||||
else
|
||||
widget->area.width = textwidth(widget->font, d->text);
|
||||
|
||||
if(widget->area.x < 0)
|
||||
widget_area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if(widget->area.y < 0)
|
||||
widget_area.y = 0;
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
|
||||
draw_text(ctx, widget_area.x, widget_area.y, widget->area.width,
|
||||
draw_text(ctx, widget->area.x, widget->area.y, widget->area.width,
|
||||
widget->statusbar->height, d->align, 0, widget->font,
|
||||
d->text, d->fg, d->bg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue