JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
proceeded with cleaning up, sorting functions, etc
[dwm.git] / draw.c
diff --git a/draw.c b/draw.c
index 4c47c1a..9743ec1 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -2,13 +2,34 @@
  * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
  * See LICENSE file for license details.
  */
+#include "dwm.h"
 
 #include <stdio.h>
 #include <string.h>
-
 #include <X11/Xlocale.h>
 
-#include "dwm.h"
+/* static functions */
+
+static void
+drawborder(void)
+{
+       XPoint points[5];
+       XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+       XSetForeground(dpy, dc.gc, dc.border);
+       points[0].x = dc.x;
+       points[0].y = dc.y;
+       points[1].x = dc.w - 1;
+       points[1].y = 0;
+       points[2].x = 0;
+       points[2].y = dc.h - 1;
+       points[3].x = -(dc.w - 1);
+       points[3].y = 0;
+       points[4].x = 0;
+       points[4].y = -(dc.h - 1);
+       XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
+}
+
+/* extern functions */
 
 void
 drawall()
@@ -53,59 +74,6 @@ drawstatus()
 }
 
 void
-drawtitle(Client *c)
-{
-       int i;
-       Bool istile = arrange == dotile;
-
-       if(c == sel) {
-               drawstatus();
-               XUnmapWindow(dpy, c->title);
-               XSetWindowBorder(dpy, c->win, dc.fg);
-               return;
-       }
-
-       XSetWindowBorder(dpy, c->win, dc.bg);
-       XMapWindow(dpy, c->title);
-
-       dc.x = dc.y = 0;
-
-       dc.w = 0;
-       for(i = 0; i < TLast; i++) {
-               if(c->tags[i]) {
-                       dc.x += dc.w;
-                       dc.w = textw(c->tags[i]);
-                       drawtext(c->tags[i], !istile, True);
-               }
-       }
-       dc.x += dc.w;
-       dc.w = textw(c->name);
-       drawtext(c->name, !istile, True);
-       XCopyArea(dpy, dc.drawable, c->title, dc.gc,
-                       0, 0, c->tw, c->th, 0, 0);
-       XFlush(dpy);
-}
-
-static void
-drawborder(void)
-{
-       XPoint points[5];
-       XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
-       XSetForeground(dpy, dc.gc, dc.border);
-       points[0].x = dc.x;
-       points[0].y = dc.y;
-       points[1].x = dc.w - 1;
-       points[1].y = 0;
-       points[2].x = 0;
-       points[2].y = dc.h - 1;
-       points[3].x = -(dc.w - 1);
-       points[3].y = 0;
-       points[4].x = 0;
-       points[4].y = -(dc.h - 1);
-       XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
-}
-
-void
 drawtext(const char *text, Bool invert, Bool border)
 {
        int x, y, w, h;
@@ -155,6 +123,40 @@ drawtext(const char *text, Bool invert, Bool border)
        }
 }
 
+void
+drawtitle(Client *c)
+{
+       int i;
+       Bool istile = arrange == dotile;
+
+       if(c == sel) {
+               drawstatus();
+               XUnmapWindow(dpy, c->title);
+               XSetWindowBorder(dpy, c->win, dc.fg);
+               return;
+       }
+
+       XSetWindowBorder(dpy, c->win, dc.bg);
+       XMapWindow(dpy, c->title);
+
+       dc.x = dc.y = 0;
+
+       dc.w = 0;
+       for(i = 0; i < TLast; i++) {
+               if(c->tags[i]) {
+                       dc.x += dc.w;
+                       dc.w = textw(c->tags[i]);
+                       drawtext(c->tags[i], !istile, True);
+               }
+       }
+       dc.x += dc.w;
+       dc.w = textw(c->name);
+       drawtext(c->name, !istile, True);
+       XCopyArea(dpy, dc.drawable, c->title, dc.gc,
+                       0, 0, c->tw, c->th, 0, 0);
+       XFlush(dpy);
+}
+
 unsigned long
 getcolor(const char *colstr)
 {
@@ -165,23 +167,6 @@ getcolor(const char *colstr)
        return color.pixel;
 }
 
-unsigned int
-textnw(char *text, unsigned int len)
-{
-       XRectangle r;
-       if(dc.font.set) {
-               XmbTextExtents(dc.font.set, text, len, NULL, &r);
-               return r.width;
-       }
-       return XTextWidth(dc.font.xfont, text, len);
-}
-
-unsigned int
-textw(char *text)
-{
-       return textnw(text, strlen(text)) + dc.font.height;
-}
-
 void
 setfont(const char *fontstr)
 {
@@ -232,3 +217,20 @@ setfont(const char *fontstr)
        }
        dc.font.height = dc.font.ascent + dc.font.descent;
 }
+
+unsigned int
+textnw(char *text, unsigned int len)
+{
+       XRectangle r;
+       if(dc.font.set) {
+               XmbTextExtents(dc.font.set, text, len, NULL, &r);
+               return r.width;
+       }
+       return XTextWidth(dc.font.xfont, text, len);
+}
+
+unsigned int
+textw(char *text)
+{
+       return textnw(text, strlen(text)) + dc.font.height;
+}