aboutsummaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert Münnich <be.muennich@gmail.com>2013-02-11 23:05:26 +0100
committerBert Münnich <be.muennich@gmail.com>2013-03-19 21:13:44 +0100
commitf3298400e6704844aeb1d3e0951e84b4236d2302 (patch)
treee2d85c993d65966555e2fbdb5c3ea37a1aa42e5e /window.c
parent9ee34477f81dc9630e902e8059e56fa665ad007b (diff)
downloadnsxiv-f3298400e6704844aeb1d3e0951e84b4236d2302.tar.zst
Spawn and read from info script without blocking
Diffstat (limited to 'window.c')
-rw-r--r--window.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/window.c b/window.c
index 0b1ce65..a51499e 100644
--- a/window.c
+++ b/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)