stop being stupid, use only one Drawable
This commit is contained in:
parent
9e1994d879
commit
7ad43fe713
16
draw.c
16
draw.c
|
@ -35,7 +35,7 @@ extern AwesomeConf globalconf;
|
||||||
* \return draw context ref
|
* \return draw context ref
|
||||||
*/
|
*/
|
||||||
DrawCtx *
|
DrawCtx *
|
||||||
draw_get_context(int phys_screen, int width, int height)
|
draw_get_context(int phys_screen, int width, int height, Drawable dw)
|
||||||
{
|
{
|
||||||
DrawCtx *d = p_new(DrawCtx, 1);
|
DrawCtx *d = p_new(DrawCtx, 1);
|
||||||
|
|
||||||
|
@ -44,23 +44,11 @@ draw_get_context(int phys_screen, int width, int height)
|
||||||
d->height = height;
|
d->height = height;
|
||||||
d->depth = DefaultDepth(globalconf.display, phys_screen);
|
d->depth = DefaultDepth(globalconf.display, phys_screen);
|
||||||
d->visual = DefaultVisual(globalconf.display, phys_screen);
|
d->visual = DefaultVisual(globalconf.display, phys_screen);
|
||||||
d->drawable = XCreatePixmap(globalconf.display,
|
d->drawable = dw;
|
||||||
RootWindow(globalconf.display, phys_screen),
|
|
||||||
width, height, d->depth);
|
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Free a draw context and its drawable
|
|
||||||
* \param ctx the draw context to free
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
draw_free_context(DrawCtx *ctx)
|
|
||||||
{
|
|
||||||
XFreePixmap(globalconf.display, ctx->drawable);
|
|
||||||
p_delete(&ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Draw text into a draw context
|
/** Draw text into a draw context
|
||||||
* \param x x coord
|
* \param x x coord
|
||||||
* \param y y coord
|
* \param y y coord
|
||||||
|
|
3
draw.h
3
draw.h
|
@ -52,8 +52,7 @@ typedef struct
|
||||||
int depth;
|
int depth;
|
||||||
} DrawCtx;
|
} DrawCtx;
|
||||||
|
|
||||||
DrawCtx *draw_get_context(int, int, int);
|
DrawCtx *draw_get_context(int, int, int, Drawable);
|
||||||
void draw_free_context(DrawCtx *);
|
|
||||||
void draw_text(DrawCtx *, Area, Alignment, int, XftFont *, const char *, XColor fg, XColor bg);
|
void draw_text(DrawCtx *, Area, Alignment, int, XftFont *, const char *, XColor fg, XColor bg);
|
||||||
void draw_rectangle(DrawCtx *, Area, Bool, XColor);
|
void draw_rectangle(DrawCtx *, Area, Bool, XColor);
|
||||||
void draw_graph(DrawCtx *, int, int, int, int *, int, XColor);
|
void draw_graph(DrawCtx *, int, int, int, int *, int, XColor);
|
||||||
|
|
25
statusbar.c
25
statusbar.c
|
@ -76,16 +76,16 @@ statusbar_draw(Statusbar *statusbar)
|
||||||
Widget *widget, *last_drawn = NULL;
|
Widget *widget, *last_drawn = NULL;
|
||||||
int left = 0, right = 0;
|
int left = 0, right = 0;
|
||||||
Area rectangle = { 0, 0, 0, 0 };
|
Area rectangle = { 0, 0, 0, 0 };
|
||||||
|
Drawable d;
|
||||||
|
|
||||||
/* don't waste our time */
|
/* don't waste our time */
|
||||||
if(statusbar->position == Off)
|
if(statusbar->position == Off)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XFreePixmap(globalconf.display, statusbar->sw->drawable);
|
|
||||||
|
|
||||||
DrawCtx *ctx = draw_get_context(phys_screen,
|
DrawCtx *ctx = draw_get_context(phys_screen,
|
||||||
statusbar->width,
|
statusbar->width,
|
||||||
statusbar->height);
|
statusbar->height,
|
||||||
|
statusbar->sw->drawable);
|
||||||
|
|
||||||
rectangle.width = statusbar->width;
|
rectangle.width = statusbar->width;
|
||||||
rectangle.height = statusbar->height;
|
rectangle.height = statusbar->height;
|
||||||
|
@ -119,22 +119,23 @@ statusbar_draw(Statusbar *statusbar)
|
||||||
switch(statusbar->position)
|
switch(statusbar->position)
|
||||||
{
|
{
|
||||||
case Right:
|
case Right:
|
||||||
statusbar->sw->drawable = draw_rotate(ctx, phys_screen, M_PI_2,
|
d = draw_rotate(ctx, phys_screen, M_PI_2,
|
||||||
statusbar->height, 0);
|
statusbar->height, 0);
|
||||||
draw_free_context(ctx);
|
XFreePixmap(globalconf.display, statusbar->sw->drawable);
|
||||||
|
statusbar->sw->drawable = d;
|
||||||
break;
|
break;
|
||||||
case Left:
|
case Left:
|
||||||
statusbar->sw->drawable = draw_rotate(ctx, phys_screen, - M_PI_2,
|
d = draw_rotate(ctx, phys_screen, - M_PI_2,
|
||||||
0, statusbar->width);
|
0, statusbar->width);
|
||||||
draw_free_context(ctx);
|
XFreePixmap(globalconf.display, statusbar->sw->drawable);
|
||||||
|
statusbar->sw->drawable = d;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusbar->sw->drawable = ctx->drawable;
|
|
||||||
/* just delete the struct, don't delete the drawable */
|
|
||||||
p_delete(&ctx);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_delete(&ctx);
|
||||||
|
|
||||||
statusbar_display(statusbar);
|
statusbar_display(statusbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue