Spawn and read from info script without blocking
This commit is contained in:
59
window.c
59
window.c
@ -414,31 +414,28 @@ void win_draw_bar(win_t *win)
|
||||
XSetForeground(e->dpy, gc, win->bar.fgcol);
|
||||
XSetBackground(e->dpy, gc, win->bar.bgcol);
|
||||
|
||||
if (win->bar.r != NULL) {
|
||||
len = strlen(win->bar.r);
|
||||
if (len > 0) {
|
||||
if ((tw = win_textwidth(win->bar.r, len, true)) > w)
|
||||
return;
|
||||
x = win->w - tw + H_TEXT_PAD;
|
||||
w -= tw;
|
||||
if (font.set)
|
||||
XmbDrawString(e->dpy, win->pm, font.set, gc, x, y, win->bar.r, len);
|
||||
else
|
||||
XDrawString(e->dpy, win->pm, gc, x, y, win->bar.r, len);
|
||||
}
|
||||
if ((len = strlen(win->bar.r)) > 0) {
|
||||
if ((tw = win_textwidth(win->bar.r, len, true)) > w)
|
||||
return;
|
||||
x = win->w - tw + H_TEXT_PAD;
|
||||
w -= tw;
|
||||
if (font.set)
|
||||
XmbDrawString(e->dpy, win->pm, font.set, gc, x, y, win->bar.r, len);
|
||||
else
|
||||
XDrawString(e->dpy, win->pm, gc, x, y, win->bar.r, len);
|
||||
}
|
||||
if (win->bar.l != NULL) {
|
||||
olen = len = strlen(win->bar.l);
|
||||
if ((len = strlen(win->bar.l)) > 0) {
|
||||
olen = len;
|
||||
while (len > 0 && (tw = win_textwidth(win->bar.l, len, true)) > w)
|
||||
len--;
|
||||
if (len > 0) {
|
||||
if (len != olen) {
|
||||
w = strlen(dots);
|
||||
if (len <= w)
|
||||
return;
|
||||
memcpy(rest, win->bar.l + len - w, w);
|
||||
memcpy(win->bar.l + len - w, dots, w);
|
||||
}
|
||||
if (len != olen) {
|
||||
w = strlen(dots);
|
||||
if (len <= w)
|
||||
return;
|
||||
memcpy(rest, win->bar.l + len - w, w);
|
||||
memcpy(win->bar.l + len - w, dots, w);
|
||||
}
|
||||
x = H_TEXT_PAD;
|
||||
if (font.set)
|
||||
XmbDrawString(e->dpy, win->pm, font.set, gc, x, y, win->bar.l, len);
|
||||
@ -480,6 +477,18 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h,
|
||||
XDrawRectangle(win->env.dpy, pm, gc, x, y, w, h);
|
||||
}
|
||||
|
||||
void win_update_bar(win_t *win)
|
||||
{
|
||||
if (win == NULL || win->xwin == None || win->pm == None)
|
||||
return;
|
||||
|
||||
if (win->bar.h > 0) {
|
||||
win_draw_bar(win);
|
||||
XCopyArea(win->env.dpy, win->pm, win->xwin, gc,
|
||||
0, win->h, win->w, win->bar.h, 0, win->h);
|
||||
}
|
||||
}
|
||||
|
||||
int win_textwidth(const char *text, unsigned int len, bool with_padding)
|
||||
{
|
||||
XRectangle r;
|
||||
@ -514,14 +523,6 @@ void win_set_title(win_t *win, const char *title)
|
||||
PropModeReplace, (unsigned char *) title, strlen(title));
|
||||
}
|
||||
|
||||
void win_set_bar_info(win_t *win, char *linfo, char *rinfo)
|
||||
{
|
||||
if (win != NULL) {
|
||||
win->bar.l = linfo;
|
||||
win->bar.r = rinfo;
|
||||
}
|
||||
}
|
||||
|
||||
void win_set_cursor(win_t *win, cursor_t cursor)
|
||||
{
|
||||
if (win == NULL || win->xwin == None)
|
||||
|
Reference in New Issue
Block a user