mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
wibox: simplify render proto
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
b1ab27a576
commit
74cff05428
3 changed files with 18 additions and 28 deletions
6
wibox.c
6
wibox.c
|
@ -497,11 +497,7 @@ wibox_draw(wibox_t *wibox)
|
||||||
{
|
{
|
||||||
if(wibox->isvisible)
|
if(wibox->isvisible)
|
||||||
{
|
{
|
||||||
widget_render(&wibox->widgets, &wibox->sw.ctx, wibox->sw.gc,
|
widget_render(wibox);
|
||||||
wibox->sw.pixmap,
|
|
||||||
wibox->screen, wibox->sw.orientation,
|
|
||||||
wibox->sw.geometry.x, wibox->sw.geometry.y,
|
|
||||||
wibox);
|
|
||||||
simplewindow_refresh_pixmap(&wibox->sw);
|
simplewindow_refresh_pixmap(&wibox->sw);
|
||||||
|
|
||||||
wibox->need_update = false;
|
wibox->need_update = false;
|
||||||
|
|
38
widget.c
38
widget.c
|
@ -144,22 +144,13 @@ luaA_table2widgets(lua_State *L, widget_node_array_t *widgets)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Render a list of widgets.
|
/** Render a list of widgets.
|
||||||
* \param wnode The list of widgets.
|
|
||||||
* \param ctx The draw context where to render.
|
|
||||||
* \param rotate_px The rotate pixmap: where to rotate and render the final
|
|
||||||
* pixmap when the object oritation is not east.
|
|
||||||
* \param screen The logical screen used to render.
|
|
||||||
* \param orientation The object orientation.
|
|
||||||
* \param x The x coordinates of the object.
|
|
||||||
* \param y The y coordinates of the object.
|
|
||||||
* \param wibox The wibox.
|
* \param wibox The wibox.
|
||||||
* \todo Remove GC.
|
* \todo Remove GC.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t gc, xcb_pixmap_t rotate_px,
|
widget_render(wibox_t *wibox)
|
||||||
int screen, orientation_t orientation,
|
|
||||||
int x, int y, wibox_t *wibox)
|
|
||||||
{
|
{
|
||||||
|
draw_context_t *ctx = &wibox->sw.ctx;
|
||||||
int left = 0, right = 0;
|
int left = 0, right = 0;
|
||||||
area_t rectangle = { 0, 0, 0, 0 };
|
area_t rectangle = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
@ -168,6 +159,7 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
|
|
||||||
if(ctx->bg.alpha != 0xffff)
|
if(ctx->bg.alpha != 0xffff)
|
||||||
{
|
{
|
||||||
|
int x = wibox->sw.geometry.x, y = wibox->sw.geometry.y;
|
||||||
xcb_get_property_reply_t *prop_r;
|
xcb_get_property_reply_t *prop_r;
|
||||||
char *data;
|
char *data;
|
||||||
xcb_pixmap_t rootpix;
|
xcb_pixmap_t rootpix;
|
||||||
|
@ -180,7 +172,7 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
if(prop_r->value_len
|
if(prop_r->value_len
|
||||||
&& (data = xcb_get_property_value(prop_r))
|
&& (data = xcb_get_property_value(prop_r))
|
||||||
&& (rootpix = *(xcb_pixmap_t *) data))
|
&& (rootpix = *(xcb_pixmap_t *) data))
|
||||||
switch(orientation)
|
switch(wibox->sw.orientation)
|
||||||
{
|
{
|
||||||
case North:
|
case North:
|
||||||
draw_rotate(ctx,
|
draw_rotate(ctx,
|
||||||
|
@ -202,7 +194,7 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
break;
|
break;
|
||||||
case East:
|
case East:
|
||||||
xcb_copy_area(globalconf.connection, rootpix,
|
xcb_copy_area(globalconf.connection, rootpix,
|
||||||
rotate_px, gc,
|
wibox->sw.pixmap, wibox->sw.gc,
|
||||||
x, y,
|
x, y,
|
||||||
0, 0,
|
0, 0,
|
||||||
ctx->width, ctx->height);
|
ctx->width, ctx->height);
|
||||||
|
@ -212,12 +204,14 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget_node_array_t *widgets = &wibox->widgets;
|
||||||
|
|
||||||
/* compute geometry */
|
/* compute geometry */
|
||||||
for(int i = 0; i < widgets->len; i++)
|
for(int i = 0; i < widgets->len; i++)
|
||||||
if(widgets->tab[i].widget->align == AlignLeft && widgets->tab[i].widget->isvisible)
|
if(widgets->tab[i].widget->align == AlignLeft && widgets->tab[i].widget->isvisible)
|
||||||
{
|
{
|
||||||
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
||||||
screen, ctx->height,
|
wibox->screen, ctx->height,
|
||||||
ctx->width - (left + right));
|
ctx->width - (left + right));
|
||||||
widgets->tab[i].geometry.x = left;
|
widgets->tab[i].geometry.x = left;
|
||||||
left += widgets->tab[i].geometry.width;
|
left += widgets->tab[i].geometry.width;
|
||||||
|
@ -227,7 +221,7 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
if(widgets->tab[i].widget->align == AlignRight && widgets->tab[i].widget->isvisible)
|
if(widgets->tab[i].widget->align == AlignRight && widgets->tab[i].widget->isvisible)
|
||||||
{
|
{
|
||||||
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
||||||
screen, ctx->height,
|
wibox->screen, ctx->height,
|
||||||
ctx->width - (left + right));
|
ctx->width - (left + right));
|
||||||
right += widgets->tab[i].geometry.width;
|
right += widgets->tab[i].geometry.width;
|
||||||
widgets->tab[i].geometry.x = ctx->width - right;
|
widgets->tab[i].geometry.x = ctx->width - right;
|
||||||
|
@ -247,7 +241,7 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
flex++;
|
flex++;
|
||||||
else
|
else
|
||||||
fake_left += widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
fake_left += widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
||||||
screen, ctx->height,
|
wibox->screen, ctx->height,
|
||||||
ctx->width - (fake_left + right)).width;
|
ctx->width - (fake_left + right)).width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,13 +259,13 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
if(flex_rendered == flex - 1)
|
if(flex_rendered == flex - 1)
|
||||||
width += (ctx->width - (right + fake_left)) % flex;
|
width += (ctx->width - (right + fake_left)) % flex;
|
||||||
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
||||||
screen, ctx->height,
|
wibox->screen, ctx->height,
|
||||||
width);
|
width);
|
||||||
flex_rendered++;
|
flex_rendered++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
widgets->tab[i].geometry = widgets->tab[i].widget->geometry(widgets->tab[i].widget,
|
||||||
screen, ctx->height,
|
wibox->screen, ctx->height,
|
||||||
ctx->width - (left + right));
|
ctx->width - (left + right));
|
||||||
widgets->tab[i].geometry.x = left;
|
widgets->tab[i].geometry.x = left;
|
||||||
left += widgets->tab[i].geometry.width;
|
left += widgets->tab[i].geometry.width;
|
||||||
|
@ -286,19 +280,19 @@ widget_render(widget_node_array_t *widgets, draw_context_t *ctx, xcb_gcontext_t
|
||||||
widgets->tab[i].geometry.y = 0;
|
widgets->tab[i].geometry.y = 0;
|
||||||
widgets->tab[i].widget->draw(widgets->tab[i].widget,
|
widgets->tab[i].widget->draw(widgets->tab[i].widget,
|
||||||
ctx, widgets->tab[i].geometry,
|
ctx, widgets->tab[i].geometry,
|
||||||
screen, wibox);
|
wibox->screen, wibox);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(orientation)
|
switch(wibox->sw.orientation)
|
||||||
{
|
{
|
||||||
case South:
|
case South:
|
||||||
draw_rotate(ctx, ctx->pixmap, rotate_px,
|
draw_rotate(ctx, ctx->pixmap, wibox->sw.pixmap,
|
||||||
ctx->width, ctx->height,
|
ctx->width, ctx->height,
|
||||||
ctx->height, ctx->width,
|
ctx->height, ctx->width,
|
||||||
M_PI_2, ctx->height, 0);
|
M_PI_2, ctx->height, 0);
|
||||||
break;
|
break;
|
||||||
case North:
|
case North:
|
||||||
draw_rotate(ctx, ctx->pixmap, rotate_px,
|
draw_rotate(ctx, ctx->pixmap, wibox->sw.pixmap,
|
||||||
ctx->width, ctx->height,
|
ctx->width, ctx->height,
|
||||||
ctx->height, ctx->width,
|
ctx->height, ctx->width,
|
||||||
- M_PI_2, 0, ctx->width);
|
- M_PI_2, 0, ctx->width);
|
||||||
|
|
2
widget.h
2
widget.h
|
@ -38,7 +38,7 @@ DO_RCNT(widget_t, widget, widget_delete)
|
||||||
|
|
||||||
int widget_calculate_offset(int, int, int, int);
|
int widget_calculate_offset(int, int, int, int);
|
||||||
widget_t *widget_getbycoords(position_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
|
widget_t *widget_getbycoords(position_t, widget_node_array_t *, int, int, int16_t *, int16_t *);
|
||||||
void widget_render(widget_node_array_t *, draw_context_t *, xcb_gcontext_t, xcb_drawable_t, int, orientation_t, int, int, wibox_t *);
|
void widget_render(wibox_t *);
|
||||||
|
|
||||||
int luaA_widget_userdata_new(lua_State *, widget_t *);
|
int luaA_widget_userdata_new(lua_State *, widget_t *);
|
||||||
void luaA_table2widgets(lua_State *, widget_node_array_t *);
|
void luaA_table2widgets(lua_State *, widget_node_array_t *);
|
||||||
|
|
Loading…
Reference in a new issue