[widget] Remove useless drawing args

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-03 16:08:33 +02:00
parent 26632ae48c
commit 807c5bf208
8 changed files with 43 additions and 43 deletions

View File

@ -119,16 +119,16 @@ statusbar_draw(statusbar_t *statusbar)
for(w = statusbar->widgets; w; w = w->next) for(w = statusbar->widgets; w; w = w->next)
if(w->widget->isvisible && w->widget->align == AlignLeft) if(w->widget->isvisible && w->widget->align == AlignLeft)
left += w->widget->draw(statusbar->ctx, statusbar->screen, w, statusbar->width, statusbar->height, left, (left + right), statusbar); left += w->widget->draw(statusbar->ctx, statusbar->screen, w, left, (left + right), statusbar);
/* renders right widget from last to first */ /* renders right widget from last to first */
for(w = *widget_node_list_last(&statusbar->widgets); w; w = w->prev) for(w = *widget_node_list_last(&statusbar->widgets); w; w = w->prev)
if(w->widget->isvisible && w->widget->align == AlignRight) if(w->widget->isvisible && w->widget->align == AlignRight)
right += w->widget->draw(statusbar->ctx, statusbar->screen, w, statusbar->width, statusbar->height, right, (left + right), statusbar); right += w->widget->draw(statusbar->ctx, statusbar->screen, w, right, (left + right), statusbar);
for(w = statusbar->widgets; w; w = w->next) for(w = statusbar->widgets; w; w = w->next)
if(w->widget->isvisible && w->widget->align == AlignFlex) if(w->widget->isvisible && w->widget->align == AlignFlex)
left += w->widget->draw(statusbar->ctx, statusbar->screen, w, statusbar->width, statusbar->height, left, (left + right), statusbar); left += w->widget->draw(statusbar->ctx, statusbar->screen, w, left, (left + right), statusbar);
switch(statusbar->position) switch(statusbar->position)
{ {

View File

@ -136,7 +136,7 @@ struct widget_t
/** widget_t name */ /** widget_t name */
char *name; char *name;
/** Draw function */ /** Draw function */
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, int, int, void *); int (*draw)(draw_context_t *, int, widget_node_t *, int, int, void *);
/** Update function */ /** Update function */
widget_tell_status_t (*tell)(widget_t *, const char *, const char *); widget_tell_status_t (*tell)(widget_t *, const char *, const char *);
/** ButtonPressedEvent handler */ /** ButtonPressedEvent handler */

View File

@ -137,7 +137,7 @@ static int
graph_draw(draw_context_t *ctx, graph_draw(draw_context_t *ctx,
int screen __attribute__ ((unused)), int screen __attribute__ ((unused)),
widget_node_t *w, widget_node_t *w,
int width, int height, int offset, int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
void *p __attribute__ ((unused))) void *p __attribute__ ((unused)))
{ {
@ -149,16 +149,16 @@ graph_draw(draw_context_t *ctx,
if(!d->data_items) if(!d->data_items)
return 0; return 0;
w->area.x = widget_calculate_offset(width, w->area.x = widget_calculate_offset(ctx->width,
d->width, offset, d->width, offset,
w->widget->align); w->widget->align);
w->area.y = 0; w->area.y = 0;
/* box = the graph inside the rectangle */ /* box = the graph inside the rectangle */
if(!(d->box_height)) if(!(d->box_height))
d->box_height = (int) (height * d->height + 0.5) - 2; d->box_height = (int) (ctx->height * d->height + 0.5) - 2;
margin_top = (int)((height - (d->box_height + 2)) / 2 + 0.5) + w->area.y; margin_top = (int)((ctx->height - (d->box_height + 2)) / 2 + 0.5) + w->area.y;
/* draw background */ /* draw background */
rectangle.x = w->area.x + 1; rectangle.x = w->area.x + 1;
@ -328,7 +328,7 @@ graph_draw(draw_context_t *ctx,
draw_rectangle(ctx, rectangle, 1.0, false, d->bordercolor); draw_rectangle(ctx, rectangle, 1.0, false, d->bordercolor);
w->area.width = d->width; w->area.width = d->width;
w->area.height = height; w->area.height = ctx->height;
return w->area.width; return w->area.width;
} }

View File

@ -31,7 +31,7 @@ typedef struct
static int static int
iconbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), iconbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
widget_node_t *w, widget_node_t *w,
int width, int height, int offset, int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
void *p __attribute__ ((unused))) void *p __attribute__ ((unused)))
{ {
@ -43,16 +43,16 @@ iconbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
return (w->area.width = 0); return (w->area.width = 0);
if(d->resize) if(d->resize)
w->area.width = ((double) height / area.height) * area.width; w->area.width = ((double) ctx->height / area.height) * area.width;
else else
w->area.width = area.width; w->area.width = area.width;
if(w->area.width > width - used) if(w->area.width > ctx->width - used)
return (w->area.width = 0); return (w->area.width = 0);
w->area.height = height; w->area.height = ctx->height;
w->area.x = widget_calculate_offset(width, w->area.x = widget_calculate_offset(ctx->width,
w->area.width, w->area.width,
offset, offset,
w->widget->align); w->widget->align);
@ -60,7 +60,7 @@ iconbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
w->area.y = 0; w->area.y = 0;
draw_image(ctx, w->area.x, w->area.y, draw_image(ctx, w->area.x, w->area.y,
d->resize ? height : 0, d->image); d->resize ? ctx->height : 0, d->image);
return w->area.width; return w->area.width;
} }

View File

@ -123,7 +123,7 @@ static int
progressbar_draw(draw_context_t *ctx, progressbar_draw(draw_context_t *ctx,
int screen __attribute__ ((unused)), int screen __attribute__ ((unused)),
widget_node_t *w, widget_node_t *w,
int width, int height, int offset, int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
void *p __attribute__ ((unused))) void *p __attribute__ ((unused)))
{ {
@ -155,7 +155,7 @@ progressbar_draw(draw_context_t *ctx,
w->area.width = pb_width + 2 * (d->border_width + d->border_padding); w->area.width = pb_width + 2 * (d->border_width + d->border_padding);
} }
w->area.x = widget_calculate_offset(width, w->area.x = widget_calculate_offset(ctx->width,
w->area.width, w->area.width,
offset, offset,
w->widget->align); w->widget->align);
@ -179,7 +179,7 @@ progressbar_draw(draw_context_t *ctx,
{ {
/** \todo maybe prevent to calculate that stuff below over and over again /** \todo maybe prevent to calculate that stuff below over and over again
* (->use static-values) */ * (->use static-values) */
pb_height = (int) (height * d->height + 0.5) pb_height = (int) (ctx->height * d->height + 0.5)
- 2 * (d->border_width + d->border_padding); - 2 * (d->border_width + d->border_padding);
if(d->ticks_count && d->ticks_gap) if(d->ticks_count && d->ticks_gap)
{ {
@ -188,7 +188,7 @@ progressbar_draw(draw_context_t *ctx,
pb_height = unit * d->ticks_count - d->ticks_gap; pb_height = unit * d->ticks_count - d->ticks_gap;
} }
pb_y = w->area.y + ((int) (height * (1 - d->height)) / 2) pb_y = w->area.y + ((int) (ctx->height * (1 - d->height)) / 2)
+ d->border_width + d->border_padding; + d->border_width + d->border_padding;
for(i = 0; i < d->data_items; i++) for(i = 0; i < d->data_items; i++)
@ -289,10 +289,10 @@ progressbar_draw(draw_context_t *ctx,
} }
else /* a horizontal progressbar */ else /* a horizontal progressbar */
{ {
pb_height = (int) ((height * d->height pb_height = (int) ((ctx->height * d->height
- d->data_items * 2 * (d->border_width + d->border_padding) - d->data_items * 2 * (d->border_width + d->border_padding)
- (d->gap * (d->data_items - 1))) / d->data_items + 0.5); - (d->gap * (d->data_items - 1))) / d->data_items + 0.5);
pb_y = w->area.y + ((int) (height * (1 - d->height)) / 2) pb_y = w->area.y + ((int) (ctx->height * (1 - d->height)) / 2)
+ d->border_width + d->border_padding; + d->border_width + d->border_padding;
for(i = 0; i < d->data_items; i++) for(i = 0; i < d->data_items; i++)
@ -389,7 +389,7 @@ progressbar_draw(draw_context_t *ctx,
} }
} }
w->area.height = height; w->area.height = ctx->height;
return w->area.width; return w->area.width;
} }

View File

@ -115,7 +115,7 @@ taglist_text_get(tag_t *tag, taglist_data_t *data)
static int static int
taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w, taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
int width, int height, int offset, int offset,
int used __attribute__ ((unused)), int used __attribute__ ((unused)),
void *object) void *object)
{ {
@ -159,7 +159,7 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
} }
/* Now that we have widget width we can compute widget x coordinate */ /* Now that we have widget width we can compute widget x coordinate */
w->area.x = widget_calculate_offset(width, w->area.width, w->area.x = widget_calculate_offset(ctx->width, w->area.width,
offset, w->widget->align); offset, w->widget->align);
for(area = tda->area, tag = vscreen->tags, i = 0; for(area = tda->area, tag = vscreen->tags, i = 0;
@ -186,7 +186,7 @@ taglist_draw(draw_context_t *ctx, int screen, widget_node_t *w,
p_delete(&text); p_delete(&text);
w->area.height = height; w->area.height = ctx->height;
return w->area.width; return w->area.width;
} }

View File

@ -64,7 +64,7 @@ tasklist_isvisible(client_t *c, int screen, showclient_t show)
static int static int
tasklist_draw(draw_context_t *ctx, int screen, tasklist_draw(draw_context_t *ctx, int screen,
widget_node_t *w, int width, int height, widget_node_t *w,
int offset, int used, void *p __attribute__ ((unused))) int offset, int used, void *p __attribute__ ((unused)))
{ {
client_t *c; client_t *c;
@ -74,7 +74,7 @@ tasklist_draw(draw_context_t *ctx, int screen,
int n = 0, i = 0, box_width = 0, icon_width = 0, box_width_rest = 0; int n = 0, i = 0, box_width = 0, icon_width = 0, box_width_rest = 0;
NetWMIcon *icon; NetWMIcon *icon;
if(used >= width) if(used >= ctx->width)
return (w->area.width = 0); return (w->area.width = 0);
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
@ -84,11 +84,11 @@ tasklist_draw(draw_context_t *ctx, int screen,
if(!n) if(!n)
return (w->area.width = 0); return (w->area.width = 0);
box_width = (width - used) / n; box_width = (ctx->width - used) / n;
/* compute how many pixel we left empty */ /* compute how many pixel we left empty */
box_width_rest = (width - used) % n; box_width_rest = (ctx->width - used) % n;
w->area.x = widget_calculate_offset(width, w->area.x = widget_calculate_offset(ctx->width,
0, offset, w->widget->align); 0, offset, w->widget->align);
w->area.y = 0; w->area.y = 0;
@ -112,7 +112,7 @@ tasklist_draw(draw_context_t *ctx, int screen,
/* draw a background for icons */ /* draw a background for icons */
area.x = w->area.x + box_width * i; area.x = w->area.x + box_width * i;
area.y = w->area.y; area.y = w->area.y;
area.height = height; area.height = ctx->height;
area.width = box_width; area.width = box_width;
if(c->icon_path) if(c->icon_path)
@ -120,24 +120,24 @@ tasklist_draw(draw_context_t *ctx, int screen,
area = draw_get_image_size(c->icon_path); area = draw_get_image_size(c->icon_path);
if(area.width > 0 && area.height > 0) if(area.width > 0 && area.height > 0)
{ {
icon_width = ((double) height / (double) area.height) * area.width; icon_width = ((double) ctx->height / (double) area.height) * area.width;
draw_image(ctx, draw_image(ctx,
w->area.x + box_width * i, w->area.x + box_width * i,
w->area.y, w->area.y,
height, ctx->height,
c->icon_path); c->icon_path);
} }
} }
if(!icon_width && (icon = ewmh_get_window_icon(c->win))) if(!icon_width && (icon = ewmh_get_window_icon(c->win)))
{ {
icon_width = ((double) height / (double) icon->height) icon_width = ((double) ctx->height / (double) icon->height)
* icon->width; * icon->width;
draw_image_from_argb_data(ctx, draw_image_from_argb_data(ctx,
w->area.x + box_width * i, w->area.x + box_width * i,
w->area.y, w->area.y,
icon->width, icon->height, icon->width, icon->height,
height, icon->image); ctx->height, icon->image);
p_delete(&icon->image); p_delete(&icon->image);
p_delete(&icon); p_delete(&icon);
} }
@ -146,7 +146,7 @@ tasklist_draw(draw_context_t *ctx, int screen,
area.x = w->area.x + icon_width + box_width * i; area.x = w->area.x + icon_width + box_width * i;
area.y = w->area.y; area.y = w->area.y;
area.width = box_width - icon_width; area.width = box_width - icon_width;
area.height = height; area.height = ctx->height;
/* if we're on last elem, it has the last pixels left */ /* if we're on last elem, it has the last pixels left */
if(i == n - 1) if(i == n - 1)
@ -165,8 +165,8 @@ tasklist_draw(draw_context_t *ctx, int screen,
i++; i++;
} }
w->area.width = width - used; w->area.width = ctx->width - used;
w->area.height = height; w->area.height = ctx->height;
return w->area.width; return w->area.width;
} }

View File

@ -36,7 +36,7 @@ typedef struct
static int static int
textbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)), textbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
widget_node_t *w, widget_node_t *w,
int width, int height, int offset, int used, int offset, int used,
void *p __attribute__ ((unused))) void *p __attribute__ ((unused)))
{ {
Data *d = w->widget->data; Data *d = w->widget->data;
@ -44,16 +44,16 @@ textbox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
if(d->width) if(d->width)
w->area.width = d->width; w->area.width = d->width;
else if(w->widget->align == AlignFlex) else if(w->widget->align == AlignFlex)
w->area.width = width - used; w->area.width = ctx->width - used;
else else
w->area.width = MIN(draw_text_extents(ctx->connection, w->area.width = MIN(draw_text_extents(ctx->connection,
ctx->phys_screen, ctx->phys_screen,
globalconf.font, d->text).width, globalconf.font, d->text).width,
width - used); ctx->width - used);
w->area.height = height; w->area.height = ctx->height;
w->area.x = widget_calculate_offset(width, w->area.x = widget_calculate_offset(ctx->width,
w->area.width, w->area.width,
offset, offset,
w->widget->align); w->widget->align);