[hackers] [dwm] applied Martin Hurton's drawtext() patch || Anselm R Garbe

From: <hg_AT_suckless.org>
Date: Mon, 18 Aug 2008 08:55:40 +0000 (UTC)

changeset: 1328:0fac6d3067d7
tag: tip
user: Anselm R Garbe <garbeam_AT_gmail.com>
date: Mon Aug 18 09:55:36 2008 +0100
files: dwm.c
description:
applied Martin Hurton's drawtext() patch

diff -r 920833e10274 -r 0fac6d3067d7 dwm.c
--- a/dwm.c Mon Aug 18 09:49:44 2008 +0100
+++ b/dwm.c Mon Aug 18 09:55:36 2008 +0100
@@ -577,15 +577,14 @@
         if(!text)
                 return;
         olen = strlen(text);
- len = MIN(olen, sizeof buf);
- memcpy(buf, text, len);
         h = dc.font.ascent + dc.font.descent;
         y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
         x = dc.x + (h / 2);
         /* shorten text if necessary */
- for(; len && (i = textnw(buf, len)) > dc.w - h; len--);
+ for(len = MIN(olen, sizeof buf); len && (i = textnw(buf, len)) > dc.w - h; len--);
         if(!len)
                 return;
+ memcpy(buf, text, len);
         if(len < olen)
                 for(i = len; i && i > len - 3; buf[--i] = '.');
         XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]);
Received on Mon Aug 18 2008 - 08:55:40 UTC

This archive was generated by hypermail 2.2.0 : Mon Aug 18 2008 - 09:00:08 UTC