[hackers] [dmenu] cleaning up || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Sun, 2 May 2010 22:19:16 +0000 (UTC)

changeset: 299:e2717c2c0934
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Sun May 02 23:17:02 2010 +0100
files: dmenu.c
description:
cleaning up

diff -r 14136e6599d4 -r e2717c2c0934 dmenu.c
--- a/dmenu.c Wed Apr 14 17:35:19 2010 +0000
+++ b/dmenu.c Sun May 02 23:17:02 2010 +0100
@@ -212,12 +212,12 @@
         dc.h = mh;
         drawtext(NULL, dc.norm);
         /* print prompt? */
- if(promptw) {
+ if(prompt) {
                 dc.w = promptw;
                 drawtext(prompt, dc.sel);
+ dc.x += dc.w;
         }
- dc.x += promptw;
- dc.w = mw - promptw;
+ dc.w = mw - dc.x;
         /* print command */
         if(cmdw && item && lines == 0)
                 dc.w = cmdw;
@@ -241,14 +241,13 @@
         dc.w = spaceitem;
         drawtext(curr->left ? "<" : NULL, dc.norm);
         dc.x += dc.w;
- /* determine maximum items */
         for(i = curr; i != next; i=i->right) {
                 dc.w = MIN(textw(i->text), mw / 3);
                 drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
                 dc.x += dc.w;
         }
- dc.x = mw - spaceitem;
         dc.w = spaceitem;
+ dc.x = mw - dc.w;
         drawtext(next ? ">" : NULL, dc.norm);
 }
 
@@ -259,7 +258,6 @@
         dc.x = 0;
         dc.w = mw;
         dc.y += dc.font.height + 2;
- /* determine maximum items */
         for(i = curr; i != next; i=i->right) {
                 drawtext(i->text, (sel == i) ? dc.sel : dc.norm);
                 dc.y += dc.font.height + 2;
@@ -340,13 +338,11 @@
         if(missing)
                 XFreeStringList(missing);
         if(dc.font.set) {
- XFontSetExtents *font_extents;
                 XFontStruct **xfonts;
                 char **font_names;
                 dc.font.ascent = dc.font.descent = 0;
- font_extents = XExtentsOfFontSet(dc.font.set);
                 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
- for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
+ for(i = 0; i < n; i++) {
                         dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent);
                         dc.font.descent = MAX(dc.font.descent, (*xfonts)->descent);
                         xfonts++;
Received on Sun May 02 2010 - 22:19:16 UTC

This archive was generated by hypermail 2.2.0 : Sun May 02 2010 - 22:24:04 UTC