From 30b4bd4ed1510654dbb0f6748977029f4a7a54ac Mon Sep 17 00:00:00 2001 From: gotmor Date: Mon, 4 Feb 2008 19:05:18 +0000 Subject: renamed find_icon to search_icon_cache insert_icon to cache_icon reverted to old pixmap handling, i.e. removed opm and the pointers git-svn-id: http://dzen.googlecode.com/svn/trunk@215 f2baff5b-bf2c-0410-a398-912abdc3d8b2 --- draw.c | 101 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 50 insertions(+), 51 deletions(-) (limited to 'draw.c') diff --git a/draw.c b/draw.c index 02aad95..135c643 100644 --- a/draw.c +++ b/draw.c @@ -305,7 +305,7 @@ get_pos_vals(char *s, int *d, int *a) { } static int -find_icon(const char* name) { +search_icon_cache(const char* name) { int i; for(i=0; i < MAX_ICON_CACHE; i++) @@ -316,7 +316,7 @@ find_icon(const char* name) { } static void -insert_icon(const char* name, Pixmap pm, int w, int h) { +cache_icon(const char* name, Pixmap pm, int w, int h) { int i; if(icon_cnt >= MAX_ICON_CACHE) @@ -357,8 +357,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { long lastfg = dzen.norm[ColFG], lastbg = dzen.norm[ColBG]; Fnt *cur_fnt = NULL; XGCValues gcv; - Drawable *pm, bm; - Drawable opm=0; + Drawable pm=0, bm; #ifdef DZEN_XPM int free_xpm_attrib = 0; Pixmap xpm_pm; @@ -387,14 +386,13 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(lnr != -1) { - opm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.slave_win.width, + pm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.slave_win.width, dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen)); } else { - opm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.title_win.width, + pm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.title_win.width, dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen)); } - pm = &opm; if(!reverse) { XSetForeground(dzen.dpy, dzen.tgc, dzen.norm[ColBG]); @@ -408,7 +406,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { xpms.pixel = dzen.norm[ColFG]; #endif } - XFillRectangle(dzen.dpy, *pm, dzen.tgc, 0, 0, dzen.w, dzen.h); + XFillRectangle(dzen.dpy, pm, dzen.tgc, 0, 0, dzen.w, dzen.h); if(!reverse) { XSetForeground(dzen.dpy, dzen.tgc, dzen.norm[ColFG]); @@ -436,9 +434,9 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { cur_fnt = &dzen.font; if( lnr != -1 && (lnr + dzen.slave_win.first_line_vis >= dzen.slave_win.tcnt)) { - XCopyArea(dzen.dpy, *pm, dzen.slave_win.drawable[lnr], dzen.gc, + XCopyArea(dzen.dpy, pm, dzen.slave_win.drawable[lnr], dzen.gc, 0, 0, px, dzen.line_height, xorig, 0); - XFreePixmap(dzen.dpy, *pm); + XFreePixmap(dzen.dpy, pm); return NULL; } } @@ -455,18 +453,19 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(t != -1 && tval) { switch(t) { case icon: - if( (ip=find_icon(tval)) != -1) { - XCopyArea(dzen.dpy, icons[ip].p, *pm, dzen.tgc, + if( (ip=search_icon_cache(tval)) != -1) { + XCopyArea(dzen.dpy, icons[ip].p, pm, dzen.tgc, 0, 0, icons[ip].w, icons[ip].h, px, set_posy ? py : (dzen.line_height >= (signed)icons[ip].h ? (dzen.line_height - icons[ip].h)/2 : 0)); px += icons[ip].w; } else { - if(XReadBitmapFile(dzen.dpy, *pm, tval, &bm_w, + if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w, &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess && (h/2 + px + (signed)bm_w < dzen.w)) { - setcolor(pm, px, bm_w, lastfg, lastbg, reverse, nobg); - XCopyPlane(dzen.dpy, bm, *pm, dzen.tgc, + setcolor(&pm, px, bm_w, lastfg, lastbg, reverse, nobg); + + XCopyPlane(dzen.dpy, bm, pm, dzen.tgc, 0, 0, bm_w, bm_h, px, set_posy ? py : (dzen.line_height >= (signed)bm_h ? (dzen.line_height - bm_h)/2 : 0), 1); XFreePixmap(dzen.dpy, bm); @@ -474,10 +473,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { } #ifdef DZEN_XPM else if(XpmReadFileToPixmap(dzen.dpy, dzen.title_win.win, tval, &xpm_pm, NULL, &xpma) == XpmSuccess) { - setcolor(pm, px, xpma.width, lastfg, lastbg, reverse, nobg); - insert_icon(tval, xpm_pm, xpma.width, xpma.height); + setcolor(&pm, px, xpma.width, lastfg, lastbg, reverse, nobg); + cache_icon(tval, xpm_pm, xpma.width, xpma.height); - XCopyArea(dzen.dpy, xpm_pm, *pm, dzen.tgc, + XCopyArea(dzen.dpy, xpm_pm, pm, dzen.tgc, 0, 0, xpma.width, xpma.height, px, set_posy ? py : (dzen.line_height >= (signed)xpma.height ? (dzen.line_height - xpma.height)/2 : 0)); px += xpma.width; @@ -498,12 +497,12 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { recty = recty == 0 ? (dzen.line_height - recth)/2 : (dzen.line_height - recth)/2 + recty; px += rectx; - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); //printf("R1: setpy=%d px=%d py=%d rectw=%d recth=%d\n", set_posy, px, // set_posy ? py : ((int)recty<0 ? dzen.line_height + recty : recty), // rectw, recth); - XFillRectangle(dzen.dpy, *pm, dzen.tgc, px, + XFillRectangle(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : ((int)recty < 0 ? dzen.line_height + recty : recty), rectw, recth); @@ -523,8 +522,8 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { px = (rectx == 0) ? px : rectx+px; /* prevent from stairs effect when rounding recty */ if (!((dzen.line_height - recth) % 2)) recty--; - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XDrawRectangle(dzen.dpy, *pm, dzen.tgc, px, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XDrawRectangle(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : ((int)recty<0 ? dzen.line_height + recty : recty), rectw-1, recth); px += rectw; @@ -532,16 +531,16 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { case circle: rectx = get_circle_vals(tval, &rectw, &recth); - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XFillArc(dzen.dpy, *pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XFillArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2, rectw, rectw, 90*64, rectx?recth*64:64*360); px += rectw; break; case circleo: rectx = get_circle_vals(tval, &rectw, &recth); - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XDrawArc(dzen.dpy, *pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XDrawArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2, rectw, rectw, 90*64, rectx?recth*64:64*360); px += rectw; break; @@ -639,12 +638,12 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(!nobg) - setcolor(pm, px, tw, lastfg, lastbg, reverse, nobg); + setcolor(&pm, px, tw, lastfg, lastbg, reverse, nobg); if(cur_fnt->set) - XmbDrawString(dzen.dpy, *pm, cur_fnt->set, + XmbDrawString(dzen.dpy, pm, cur_fnt->set, dzen.tgc, px, py + cur_fnt->ascent, lbuf, strlen(lbuf)); else - XDrawString(dzen.dpy, *pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf)); + XDrawString(dzen.dpy, pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf)); px += tw; } @@ -668,18 +667,18 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(t != -1 && tval) { switch(t) { case icon: - if( (ip=find_icon(tval)) != -1) { - XCopyArea(dzen.dpy, icons[ip].p, *pm, dzen.tgc, + if( (ip=search_icon_cache(tval)) != -1) { + XCopyArea(dzen.dpy, icons[ip].p, pm, dzen.tgc, 0, 0, icons[ip].w, icons[ip].h, px, set_posy ? py : (dzen.line_height >= (signed)icons[ip].h ? (dzen.line_height - icons[ip].h)/2 : 0)); px += icons[ip].w; } else { - if(XReadBitmapFile(dzen.dpy, *pm, tval, &bm_w, + if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w, &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess && (h/2 + px + (signed)bm_w < dzen.w)) { - setcolor(pm, px, bm_w, lastfg, lastbg, reverse, nobg); - XCopyPlane(dzen.dpy, bm, *pm, dzen.tgc, + setcolor(&pm, px, bm_w, lastfg, lastbg, reverse, nobg); + XCopyPlane(dzen.dpy, bm, pm, dzen.tgc, 0, 0, bm_w, bm_h, px, set_posy ? py : (dzen.line_height >= (signed)bm_h ? (dzen.line_height - bm_h)/2 : 0), 1); XFreePixmap(dzen.dpy, bm); @@ -687,10 +686,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { } #ifdef DZEN_XPM else if(XpmReadFileToPixmap(dzen.dpy, dzen.title_win.win, tval, &xpm_pm, NULL, &xpma) == XpmSuccess) { - setcolor(pm, px, xpma.width, lastfg, lastbg, reverse, nobg); - insert_icon(tval, xpm_pm, xpma.width, xpma.height); + setcolor(&pm, px, xpma.width, lastfg, lastbg, reverse, nobg); + cache_icon(tval, xpm_pm, xpma.width, xpma.height); - XCopyArea(dzen.dpy, xpm_pm, *pm, dzen.tgc, + XCopyArea(dzen.dpy, xpm_pm, pm, dzen.tgc, 0, 0, xpma.width, xpma.height, px, set_posy ? py : (dzen.line_height >= (signed)xpma.height ? (dzen.line_height - xpma.height)/2 : 0)); px += xpma.width; @@ -711,8 +710,8 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { (dzen.line_height - recth)/2 + recty; px += rectx; - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XFillRectangle(dzen.dpy, *pm, dzen.tgc, px, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XFillRectangle(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : ((int)recty < 0 ? dzen.line_height + recty : recty), rectw, recth); @@ -732,8 +731,8 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { px = (rectx == 0) ? px : rectx+px; /* prevent from stairs effect when rounding recty */ if (!((dzen.line_height - recth) % 2)) recty--; - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XDrawRectangle(dzen.dpy, *pm, dzen.tgc, px, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XDrawRectangle(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : ((int)recty<0 ? dzen.line_height + recty : recty), rectw-1, recth); px += rectw; @@ -741,16 +740,16 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { case circle: rectx = get_circle_vals(tval, &rectw, &recth); - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XFillArc(dzen.dpy, *pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XFillArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2, rectw, rectw, 90*64, rectx?recth*64:64*360); px += rectw; break; case circleo: rectx = get_circle_vals(tval, &rectw, &recth); - setcolor(pm, px, rectw, lastfg, lastbg, reverse, nobg); - XDrawArc(dzen.dpy, *pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2, + setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg); + XDrawArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2, rectw, rectw, 90*64, rectx?recth*64:64*360); px += rectw; break; @@ -849,12 +848,12 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(!nobg) - setcolor(pm, px, tw, lastfg, lastbg, reverse, nobg); + setcolor(&pm, px, tw, lastfg, lastbg, reverse, nobg); if(cur_fnt->set) - XmbDrawString(dzen.dpy, *pm, cur_fnt->set, + XmbDrawString(dzen.dpy, pm, cur_fnt->set, dzen.tgc, px, py + cur_fnt->ascent, lbuf, strlen(lbuf)); else - XDrawString(dzen.dpy, *pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf)); + XDrawString(dzen.dpy, pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf)); px += tw; /* expand/shrink dynamically */ @@ -889,14 +888,14 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(lnr != -1) { - XCopyArea(dzen.dpy, *pm, dzen.slave_win.drawable[lnr], dzen.gc, + XCopyArea(dzen.dpy, pm, dzen.slave_win.drawable[lnr], dzen.gc, 0, 0, dzen.w, dzen.line_height, xorig, 0); } else { - XCopyArea(dzen.dpy, *pm, dzen.title_win.drawable, dzen.gc, + XCopyArea(dzen.dpy, pm, dzen.title_win.drawable, dzen.gc, 0, 0, dzen.w, dzen.line_height, xorig, 0); } - XFreePixmap(dzen.dpy, opm); + XFreePixmap(dzen.dpy, pm); /* reset font to default */ if(font_was_set) -- cgit v1.2.3-54-g00ecf