From 95af4dc743c104ff49a07076ff2fa27e4a968f56 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 11 Jun 2007 03:54:25 +0000 Subject: [PATCH] don't -1 task widths, so we don't have to redraw the background window all the time. only redraw the background when it's size changes add PADDING to the edges of the text --- gui.c | 37 ++++++++++++++++++++++--------------- gui.h | 2 +- rspanel.c | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/gui.c b/gui.c index 3d1f9be..bb0e513 100644 --- a/gui.c +++ b/gui.c @@ -48,10 +48,10 @@ void gui_init(screen *sc) gcv.graphics_exposures = False; sc->fore_gc = XCreateGC(sc->dd, sc->root, GCGraphicsExposures, &gcv); - gui_load_theme(sc); + gui_load_theme(sc, NULL); } -void gui_load_theme(screen *sc) +void gui_load_theme(screen *sc, taskbar *tb) { RrFont *font; RrAppearance *with; @@ -83,8 +83,6 @@ void gui_load_theme(screen *sc) a_icon = RrAppearanceNew(sc->rr, 1); USE(a_icon); SURF(grad) = RR_SURFACE_PARENTREL; - SURF(parentx) = PADDING; - SURF(parenty) = PADDING; a_icon->texture[0].type = RR_TEXTURE_RGBA; /* this is the appearance for the background of the panel */ @@ -135,6 +133,8 @@ void gui_load_theme(screen *sc) TEXT(ellipsize) = RR_ELLIPSIZE_END; XFree(name); + + if (tb) tb->draww = tb->drawh = 0; /* make sure the taskbar redraws */ } void gui_create_taskbar(screen *sc, taskbar *tb) @@ -244,7 +244,8 @@ void gui_draw_task(screen *sc, taskbar *tb, task *tk, int redraw) d->height = i->height; d->alpha = tk->iconified ? 0x70 : tk->shaded ? 0xB0 : 0xff; d->data = i->data; - } + } else + icon_space = PADDING; a->surface.parent = b; a->surface.parentx = icon_space; @@ -252,7 +253,7 @@ void gui_draw_task(screen *sc, taskbar *tb, task *tk, int redraw) b->surface.parentx = tk->pos_x; RrPaintPixmap(b, tk->width, tb->drawh); - RrPaintPixmap(a, tk->width-icon_space, tb->drawh); + RrPaintPixmap(a, tk->width-icon_space-PADDING, tb->drawh); if (i) { RrPaintPixmap(a_icon, ICON_SIZE, ICON_SIZE); @@ -263,7 +264,7 @@ void gui_draw_task(screen *sc, taskbar *tb, task *tk, int redraw) } XCopyArea(sc->dd, a->pixmap, b->pixmap, sc->fore_gc, 0, 0, - tk->width-icon_space, tb->drawh, + tk->width-icon_space-PADDING, tb->drawh, icon_space, 0); XCopyArea(sc->dd, b->pixmap, tb->bg, sc->fore_gc, 0, 0, tk->width, tb->drawh, tk->pos_x, 0); @@ -284,6 +285,7 @@ void gui_draw_taskbar(screen *sc, taskbar *tb) task *tk; int x, width, taskw; int num_tasks = 0; + int ow, oh; #ifdef PAGER pager_draw(); @@ -291,6 +293,9 @@ void gui_draw_taskbar(screen *sc, taskbar *tb) pager_size = TEXTPAD; #endif + ow = tb->draww; + oh = tb->drawh; + tb->draww = tb->w - sc->theme->obwidth * 2; tb->drawh = tb->h - sc->theme->obwidth; XMoveResizeWindow(sc->dd, tb->bgwin, 0, @@ -299,14 +304,16 @@ void gui_draw_taskbar(screen *sc, taskbar *tb) x = pager_size + 2; width = tb->draww - (pager_size + GRILL_WIDTH); -#warning only rerender if width changed! - if (tb->bg) XFreePixmap(sc->dd, tb->bg); - tb->bg = XCreatePixmap(sc->dd, sc->root, tb->draww, tb->drawh, - RrDepth(sc->rr)); - XFreePixmap(sc->dd, RrPaintPixmap(background, tb->draww, tb->drawh)); - XCopyArea(sc->dd, background->pixmap, tb->bg, sc->fore_gc, 0, 0, - tb->draww, tb->drawh, 0, 0); + /* only re-render if the size has changed */ + if (tb->draww != ow || tb->drawh != oh) { + if (tb->bg) XFreePixmap(sc->dd, tb->bg); + tb->bg = XCreatePixmap(sc->dd, sc->root, tb->draww, tb->drawh, + RrDepth(sc->rr)); + XFreePixmap(sc->dd, RrPaintPixmap(background, tb->draww, tb->drawh)); + XCopyArea(sc->dd, background->pixmap, tb->bg, sc->fore_gc, 0, 0, + tb->draww, tb->drawh, 0, 0); + } /* find the number of visible tasks */ for (tk = tb->task_list; tk; tk = tk->next) { @@ -326,7 +333,7 @@ void gui_draw_taskbar(screen *sc, taskbar *tb) if (!task_shown(tk)) continue; tk->pos_x = x; - tk->width = taskw - 1; + tk->width = taskw; gui_draw_task(sc, tb, tk, FALSE); set_icon_geometry(sc, tb, tk); x += taskw; diff --git a/gui.h b/gui.h index 66e7cdd..d4a6ef6 100644 --- a/gui.h +++ b/gui.h @@ -9,7 +9,7 @@ struct task; #include void gui_init(struct screen *sc); -void gui_load_theme(struct screen *sc); +void gui_load_theme(struct screen *sc, struct taskbar *tb); void gui_create_taskbar(struct screen *sc, struct taskbar *tb); diff --git a/rspanel.c b/rspanel.c index 36c5d30..1880f84 100644 --- a/rspanel.c +++ b/rspanel.c @@ -506,7 +506,7 @@ static void handle_propertynotify(Window win, Atom at) } if (at == sc.atoms[_OB_THEME]) { - gui_load_theme(&sc); + gui_load_theme(&sc, &tb); gui_draw_taskbar(&sc, &tb); } return; -- 2.39.2