split the display part of statusbar_draw(), move it to new statusbar_display(), and call it for expose events
This commit is contained in:
parent
1021f86e24
commit
0df27e0f6a
13
draw.c
13
draw.c
|
@ -30,7 +30,7 @@
|
|||
extern AwesomeConf globalconf;
|
||||
|
||||
DrawCtx *
|
||||
draw_get_context(Drawable drawable, int phys_screen, int width, int height)
|
||||
draw_get_context(int phys_screen, int width, int height)
|
||||
{
|
||||
DrawCtx *d = p_new(DrawCtx, 1);
|
||||
|
||||
|
@ -39,11 +39,20 @@ draw_get_context(Drawable drawable, int phys_screen, int width, int height)
|
|||
d->height = height;
|
||||
d->depth = DefaultDepth(globalconf.display, phys_screen);
|
||||
d->visual = DefaultVisual(globalconf.display, phys_screen);
|
||||
d->drawable = drawable;
|
||||
d->drawable = XCreatePixmap(globalconf.display,
|
||||
RootWindow(globalconf.display, phys_screen),
|
||||
width, height, d->depth);
|
||||
|
||||
return d;
|
||||
};
|
||||
|
||||
void
|
||||
draw_free_context(DrawCtx *ctx)
|
||||
{
|
||||
XFreePixmap(globalconf.display, ctx->drawable);
|
||||
p_delete(&ctx);
|
||||
}
|
||||
|
||||
void
|
||||
draw_text(DrawCtx *ctx, int x, int y, int w, int h, XftFont *font, const char *text, XColor fg, XColor bg)
|
||||
{
|
||||
|
|
3
draw.h
3
draw.h
|
@ -41,7 +41,8 @@ typedef struct
|
|||
int depth;
|
||||
} DrawCtx;
|
||||
|
||||
DrawCtx *draw_get_context(Drawable, int, int, int);
|
||||
DrawCtx *draw_get_context(int, int, int);
|
||||
void draw_free_context(DrawCtx *);
|
||||
void draw_text(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg, XColor bg);
|
||||
void draw_rectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
||||
void draw_circle(DrawCtx *, int, int, int, Bool, XColor);
|
||||
|
|
2
event.c
2
event.c
|
@ -251,7 +251,7 @@ handle_event_expose(XEvent *e)
|
|||
if(!ev->count)
|
||||
for(screen = 0; screen < get_screen_count(); screen++)
|
||||
if(globalconf.screens[screen].statusbar->window == ev->window)
|
||||
statusbar_draw(screen);
|
||||
statusbar_display(screen);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
39
statusbar.c
39
statusbar.c
|
@ -45,7 +45,7 @@ statusbar_draw(int screen)
|
|||
if(vscreen.statusbar->position == BarOff)
|
||||
return;
|
||||
|
||||
DrawCtx *ctx = draw_get_context(vscreen.statusbar->drawable, phys_screen,
|
||||
DrawCtx *ctx = draw_get_context(phys_screen,
|
||||
vscreen.statusbar->width,
|
||||
vscreen.statusbar->height);
|
||||
draw_rectangle(ctx,
|
||||
|
@ -72,8 +72,8 @@ statusbar_draw(int screen)
|
|||
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)
|
||||
|
@ -88,21 +88,40 @@ statusbar_draw(int screen)
|
|||
- M_PI_2,
|
||||
0,
|
||||
vscreen.statusbar->width);
|
||||
XCopyArea(globalconf.display, d,
|
||||
|
||||
vscreen.statusbar->drawable = d;
|
||||
draw_free_context(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
vscreen.statusbar->drawable = ctx->drawable;
|
||||
/* just delete the struct, don't delete the drawable */
|
||||
p_delete(&ctx);
|
||||
}
|
||||
|
||||
|
||||
statusbar_display(screen);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
statusbar_display(int screen)
|
||||
{
|
||||
VirtScreen vscreen = globalconf.screens[screen];
|
||||
int phys_screen = get_phys_screen(screen);
|
||||
|
||||
if(vscreen.statusbar->position == BarRight
|
||||
|| vscreen.statusbar->position == BarLeft)
|
||||
XCopyArea(globalconf.display, vscreen.statusbar->drawable,
|
||||
vscreen.statusbar->window,
|
||||
DefaultGC(globalconf.display, phys_screen), 0, 0,
|
||||
vscreen.statusbar->height,
|
||||
vscreen.statusbar->width, 0, 0);
|
||||
XFreePixmap(globalconf.display, d);
|
||||
}
|
||||
else
|
||||
XCopyArea(globalconf.display, ctx->drawable,
|
||||
XCopyArea(globalconf.display, vscreen.statusbar->drawable,
|
||||
vscreen.statusbar->window,
|
||||
DefaultGC(globalconf.display, phys_screen), 0, 0,
|
||||
vscreen.statusbar->width, vscreen.statusbar->height, 0, 0);
|
||||
|
||||
p_delete(&ctx);
|
||||
XSync(globalconf.display, False);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
void statusbar_init(int);
|
||||
void statusbar_draw(int);
|
||||
void statusbar_display(int);
|
||||
int statusbar_get_position_from_str(const char *);
|
||||
void statusbar_update_position(int);
|
||||
|
||||
|
|
Loading…
Reference in New Issue