diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 15:17:31 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-02-19 15:17:31 +0100 |
| commit | f8415019d4edc1cd4f310adb256e6656e85bfe75 (patch) | |
| tree | 2813e15f6dbd4a3c1326a3d2c08ab2bcea3c61af | |
| parent | renamed view.c into screen.c (diff) | |
| download | dwm-f8415019d4edc1cd4f310adb256e6656e85bfe75.tar.gz dwm-f8415019d4edc1cd4f310adb256e6656e85bfe75.zip | |
draw.c is useless (belongs to main.c now)
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | client.c | 12 | ||||
| -rw-r--r-- | draw.c | 175 | ||||
| -rw-r--r-- | dwm.h | 11 | ||||
| -rw-r--r-- | event.c | 8 | ||||
| -rw-r--r-- | main.c | 165 |
6 files changed, 178 insertions, 195 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | include config.mk | 4 | include config.mk |
| 5 | 5 | ||
| 6 | SRC = client.c draw.c event.c main.c screen.c util.c | 6 | SRC = client.c event.c main.c screen.c util.c |
| 7 | OBJ = ${SRC:.c=.o} | 7 | OBJ = ${SRC:.c=.o} |
| 8 | 8 | ||
| 9 | all: options dwm | 9 | all: options dwm |
| @@ -200,16 +200,6 @@ focusprev(Arg *arg) { | |||
| 200 | } | 200 | } |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | Client * | ||
| 204 | getclient(Window w) { | ||
| 205 | Client *c; | ||
| 206 | |||
| 207 | for(c = clients; c; c = c->next) | ||
| 208 | if(c->win == w) | ||
| 209 | return c; | ||
| 210 | return NULL; | ||
| 211 | } | ||
| 212 | |||
| 213 | void | 203 | void |
| 214 | killclient(Arg *arg) { | 204 | killclient(Arg *arg) { |
| 215 | if(!sel) | 205 | if(!sel) |
| @@ -259,7 +249,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 259 | XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); | 249 | XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); |
| 260 | configure(c); /* propagates border_width, if size doesn't change */ | 250 | configure(c); /* propagates border_width, if size doesn't change */ |
| 261 | updatetitle(c); | 251 | updatetitle(c); |
| 262 | t = getclient(trans); | 252 | for(t = clients; t && t->win != c->win; t = t->next); |
| 263 | settags(c, t); | 253 | settags(c, t); |
| 264 | if(!c->isfloat) | 254 | if(!c->isfloat) |
| 265 | c->isfloat = (t != 0) || c->isfixed; | 255 | c->isfloat = (t != 0) || c->isfixed; |
| @@ -1,175 +0,0 @@ | |||
| 1 | /* (C)opyright MMIV-MMVII Anselm R. Garbe <garbeam at gmail dot com> | ||
| 2 | * See LICENSE file for license details. | ||
| 3 | */ | ||
| 4 | #include "dwm.h" | ||
| 5 | #include <stdio.h> | ||
| 6 | #include <string.h> | ||
| 7 | |||
| 8 | /* static */ | ||
| 9 | |||
| 10 | static Bool | ||
| 11 | isoccupied(unsigned int t) | ||
| 12 | { | ||
| 13 | Client *c; | ||
| 14 | for(c = clients; c; c = c->next) | ||
| 15 | if(c->tags[t]) | ||
| 16 | return True; | ||
| 17 | return False; | ||
| 18 | } | ||
| 19 | |||
| 20 | static unsigned int | ||
| 21 | textnw(const char *text, unsigned int len) { | ||
| 22 | XRectangle r; | ||
| 23 | |||
| 24 | if(dc.font.set) { | ||
| 25 | XmbTextExtents(dc.font.set, text, len, NULL, &r); | ||
| 26 | return r.width; | ||
| 27 | } | ||
| 28 | return XTextWidth(dc.font.xfont, text, len); | ||
| 29 | } | ||
| 30 | |||
| 31 | static void | ||
| 32 | drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool emptysquare) { | ||
| 33 | int x, y, w, h; | ||
| 34 | static char buf[256]; | ||
| 35 | unsigned int len, olen; | ||
| 36 | XGCValues gcv; | ||
| 37 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | ||
| 38 | |||
| 39 | XSetForeground(dpy, dc.gc, col[ColBG]); | ||
| 40 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | ||
| 41 | if(!text) | ||
| 42 | return; | ||
| 43 | w = 0; | ||
| 44 | olen = len = strlen(text); | ||
| 45 | if(len >= sizeof buf) | ||
| 46 | len = sizeof buf - 1; | ||
| 47 | memcpy(buf, text, len); | ||
| 48 | buf[len] = 0; | ||
| 49 | h = dc.font.ascent + dc.font.descent; | ||
| 50 | y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; | ||
| 51 | x = dc.x + (h / 2); | ||
| 52 | /* shorten text if necessary */ | ||
| 53 | while(len && (w = textnw(buf, len)) > dc.w - h) | ||
| 54 | buf[--len] = 0; | ||
| 55 | if(len < olen) { | ||
| 56 | if(len > 1) | ||
| 57 | buf[len - 1] = '.'; | ||
| 58 | if(len > 2) | ||
| 59 | buf[len - 2] = '.'; | ||
| 60 | if(len > 3) | ||
| 61 | buf[len - 3] = '.'; | ||
| 62 | } | ||
| 63 | if(w > dc.w) | ||
| 64 | return; /* too long */ | ||
| 65 | gcv.foreground = col[ColFG]; | ||
| 66 | if(dc.font.set) { | ||
| 67 | XChangeGC(dpy, dc.gc, GCForeground, &gcv); | ||
| 68 | XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); | ||
| 69 | } | ||
| 70 | else { | ||
| 71 | gcv.font = dc.font.xfont->fid; | ||
| 72 | XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); | ||
| 73 | XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); | ||
| 74 | } | ||
| 75 | x = (h + 2) / 4; | ||
| 76 | r.x = dc.x + 1; | ||
| 77 | r.y = dc.y + 1; | ||
| 78 | if(filledsquare) { | ||
| 79 | r.width = r.height = x + 1; | ||
| 80 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | ||
| 81 | } | ||
| 82 | else if(emptysquare) { | ||
| 83 | r.width = r.height = x; | ||
| 84 | XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1); | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | /* extern */ | ||
| 89 | |||
| 90 | void | ||
| 91 | drawstatus(void) { | ||
| 92 | int i, x; | ||
| 93 | |||
| 94 | dc.x = dc.y = 0; | ||
| 95 | for(i = 0; i < ntags; i++) { | ||
| 96 | dc.w = textw(tags[i]); | ||
| 97 | if(seltag[i]) | ||
| 98 | drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i)); | ||
| 99 | else | ||
| 100 | drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i)); | ||
| 101 | dc.x += dc.w; | ||
| 102 | } | ||
| 103 | dc.w = bmw; | ||
| 104 | drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False); | ||
| 105 | x = dc.x + dc.w; | ||
| 106 | dc.w = textw(stext); | ||
| 107 | dc.x = sw - dc.w; | ||
| 108 | if(dc.x < x) { | ||
| 109 | dc.x = x; | ||
| 110 | dc.w = sw - x; | ||
| 111 | } | ||
| 112 | drawtext(stext, dc.norm, False, False); | ||
| 113 | if((dc.w = dc.x - x) > bh) { | ||
| 114 | dc.x = x; | ||
| 115 | drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False); | ||
| 116 | } | ||
| 117 | XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); | ||
| 118 | XSync(dpy, False); | ||
| 119 | } | ||
| 120 | |||
| 121 | unsigned long | ||
| 122 | getcolor(const char *colstr) { | ||
| 123 | Colormap cmap = DefaultColormap(dpy, screen); | ||
| 124 | XColor color; | ||
| 125 | |||
| 126 | if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) | ||
| 127 | eprint("error, cannot allocate color '%s'\n", colstr); | ||
| 128 | return color.pixel; | ||
| 129 | } | ||
| 130 | |||
| 131 | void | ||
| 132 | setfont(const char *fontstr) { | ||
| 133 | char *def, **missing; | ||
| 134 | int i, n; | ||
| 135 | |||
| 136 | missing = NULL; | ||
| 137 | if(dc.font.set) | ||
| 138 | XFreeFontSet(dpy, dc.font.set); | ||
| 139 | dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); | ||
| 140 | if(missing) { | ||
| 141 | while(n--) | ||
| 142 | fprintf(stderr, "missing fontset: %s\n", missing[n]); | ||
| 143 | XFreeStringList(missing); | ||
| 144 | } | ||
| 145 | if(dc.font.set) { | ||
| 146 | XFontSetExtents *font_extents; | ||
| 147 | XFontStruct **xfonts; | ||
| 148 | char **font_names; | ||
| 149 | dc.font.ascent = dc.font.descent = 0; | ||
| 150 | font_extents = XExtentsOfFontSet(dc.font.set); | ||
| 151 | n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); | ||
| 152 | for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { | ||
| 153 | if(dc.font.ascent < (*xfonts)->ascent) | ||
| 154 | dc.font.ascent = (*xfonts)->ascent; | ||
| 155 | if(dc.font.descent < (*xfonts)->descent) | ||
| 156 | dc.font.descent = (*xfonts)->descent; | ||
| 157 | xfonts++; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | else { | ||
| 161 | if(dc.font.xfont) | ||
| 162 | XFreeFont(dpy, dc.font.xfont); | ||
| 163 | dc.font.xfont = NULL; | ||
| 164 | if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))) | ||
| 165 | eprint("error, cannot load font: '%s'\n", fontstr); | ||
| 166 | dc.font.ascent = dc.font.xfont->ascent; | ||
| 167 | dc.font.descent = dc.font.xfont->descent; | ||
| 168 | } | ||
| 169 | dc.font.height = dc.font.ascent + dc.font.descent; | ||
| 170 | } | ||
| 171 | |||
| 172 | unsigned int | ||
| 173 | textw(const char *text) { | ||
| 174 | return textnw(text, strlen(text)) + dc.font.height; | ||
| 175 | } | ||
| @@ -103,28 +103,23 @@ extern void configure(Client *c); /* send synthetic configure event */ | |||
| 103 | extern void focus(Client *c); /* focus c, c may be NULL */ | 103 | extern void focus(Client *c); /* focus c, c may be NULL */ |
| 104 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ | 104 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
| 105 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | 105 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ |
| 106 | extern Client *getclient(Window w); /* return client of w */ | ||
| 107 | extern void killclient(Arg *arg); /* kill c nicely */ | 106 | extern void killclient(Arg *arg); /* kill c nicely */ |
| 108 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ | 107 | extern void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
| 109 | Client *nexttiled(Client *c); /* returns tiled successor of c */ | 108 | Client *nexttiled(Client *c); /* returns tiled successor of c */ |
| 110 | extern void resize(Client *c, int x, int y, | 109 | extern void resize(Client *c, int x, int y, |
| 111 | int w, int h, Bool sizehints); /* resize c*/ | 110 | int w, int h, Bool sizehints); /* resize with given coordinates c*/ |
| 112 | extern void updatesizehints(Client *c); /* update the size hint variables of c */ | 111 | extern void updatesizehints(Client *c); /* update the size hint variables of c */ |
| 113 | extern void updatetitle(Client *c); /* update the name of c */ | 112 | extern void updatetitle(Client *c); /* update the name of c */ |
| 114 | extern void unmanage(Client *c); /* destroy c */ | 113 | extern void unmanage(Client *c); /* destroy c */ |
| 115 | extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */ | 114 | extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */ |
| 116 | 115 | ||
| 117 | /* draw.c */ | ||
| 118 | extern void drawstatus(void); /* draw the bar */ | ||
| 119 | extern unsigned long getcolor(const char *colstr); /* return color of colstr */ | ||
| 120 | extern void setfont(const char *fontstr); /* set the font for DC */ | ||
| 121 | extern unsigned int textw(const char *text); /* return the width of text in px*/ | ||
| 122 | |||
| 123 | /* event.c */ | 116 | /* event.c */ |
| 124 | extern void grabkeys(void); /* grab all keys defined in config.h */ | 117 | extern void grabkeys(void); /* grab all keys defined in config.h */ |
| 125 | extern void procevent(void); /* process pending X events */ | 118 | extern void procevent(void); /* process pending X events */ |
| 126 | 119 | ||
| 127 | /* main.c */ | 120 | /* main.c */ |
| 121 | extern void drawstatus(void); /* draw the bar */ | ||
| 122 | extern unsigned int textw(const char *text); /* return the width of text in px*/ | ||
| 128 | extern void quit(Arg *arg); /* quit dwm nicely */ | 123 | extern void quit(Arg *arg); /* quit dwm nicely */ |
| 129 | extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ | 124 | extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ |
| 130 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ | 125 | extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ |
| @@ -20,6 +20,14 @@ KEYS | |||
| 20 | #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) | 20 | #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) |
| 21 | #define MOUSEMASK (BUTTONMASK | PointerMotionMask) | 21 | #define MOUSEMASK (BUTTONMASK | PointerMotionMask) |
| 22 | 22 | ||
| 23 | static Client * | ||
| 24 | getclient(Window w) { | ||
| 25 | Client *c; | ||
| 26 | |||
| 27 | for(c = clients; c && c->win != w; c = c->next); | ||
| 28 | return c; | ||
| 29 | } | ||
| 30 | |||
| 23 | static void | 31 | static void |
| 24 | movemouse(Client *c) { | 32 | movemouse(Client *c) { |
| 25 | int x1, y1, ocx, ocy, di, nx, ny; | 33 | int x1, y1, ocx, ocy, di, nx, ny; |
| @@ -61,6 +61,94 @@ cleanup(void) { | |||
| 61 | free(seltag); | 61 | free(seltag); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static unsigned int | ||
| 65 | textnw(const char *text, unsigned int len) { | ||
| 66 | XRectangle r; | ||
| 67 | |||
| 68 | if(dc.font.set) { | ||
| 69 | XmbTextExtents(dc.font.set, text, len, NULL, &r); | ||
| 70 | return r.width; | ||
| 71 | } | ||
| 72 | return XTextWidth(dc.font.xfont, text, len); | ||
| 73 | } | ||
| 74 | |||
| 75 | static void | ||
| 76 | drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool emptysquare) { | ||
| 77 | int x, y, w, h; | ||
| 78 | static char buf[256]; | ||
| 79 | unsigned int len, olen; | ||
| 80 | XGCValues gcv; | ||
| 81 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | ||
| 82 | |||
| 83 | XSetForeground(dpy, dc.gc, col[ColBG]); | ||
| 84 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | ||
| 85 | if(!text) | ||
| 86 | return; | ||
| 87 | w = 0; | ||
| 88 | olen = len = strlen(text); | ||
| 89 | if(len >= sizeof buf) | ||
| 90 | len = sizeof buf - 1; | ||
| 91 | memcpy(buf, text, len); | ||
| 92 | buf[len] = 0; | ||
| 93 | h = dc.font.ascent + dc.font.descent; | ||
| 94 | y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; | ||
| 95 | x = dc.x + (h / 2); | ||
| 96 | /* shorten text if necessary */ | ||
| 97 | while(len && (w = textnw(buf, len)) > dc.w - h) | ||
| 98 | buf[--len] = 0; | ||
| 99 | if(len < olen) { | ||
| 100 | if(len > 1) | ||
| 101 | buf[len - 1] = '.'; | ||
| 102 | if(len > 2) | ||
| 103 | buf[len - 2] = '.'; | ||
| 104 | if(len > 3) | ||
| 105 | buf[len - 3] = '.'; | ||
| 106 | } | ||
| 107 | if(w > dc.w) | ||
| 108 | return; /* too long */ | ||
| 109 | gcv.foreground = col[ColFG]; | ||
| 110 | if(dc.font.set) { | ||
| 111 | XChangeGC(dpy, dc.gc, GCForeground, &gcv); | ||
| 112 | XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); | ||
| 113 | } | ||
| 114 | else { | ||
| 115 | gcv.font = dc.font.xfont->fid; | ||
| 116 | XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); | ||
| 117 | XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); | ||
| 118 | } | ||
| 119 | x = (h + 2) / 4; | ||
| 120 | r.x = dc.x + 1; | ||
| 121 | r.y = dc.y + 1; | ||
| 122 | if(filledsquare) { | ||
| 123 | r.width = r.height = x + 1; | ||
| 124 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | ||
| 125 | } | ||
| 126 | else if(emptysquare) { | ||
| 127 | r.width = r.height = x; | ||
| 128 | XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | static unsigned long | ||
| 133 | getcolor(const char *colstr) { | ||
| 134 | Colormap cmap = DefaultColormap(dpy, screen); | ||
| 135 | XColor color; | ||
| 136 | |||
| 137 | if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) | ||
| 138 | eprint("error, cannot allocate color '%s'\n", colstr); | ||
| 139 | return color.pixel; | ||
| 140 | } | ||
| 141 | |||
| 142 | static Bool | ||
| 143 | isoccupied(unsigned int t) { | ||
| 144 | Client *c; | ||
| 145 | |||
| 146 | for(c = clients; c; c = c->next) | ||
| 147 | if(c->tags[t]) | ||
| 148 | return True; | ||
| 149 | return False; | ||
| 150 | } | ||
| 151 | |||
| 64 | static void | 152 | static void |
| 65 | scan(void) { | 153 | scan(void) { |
| 66 | unsigned int i, num; | 154 | unsigned int i, num; |
| @@ -82,6 +170,47 @@ scan(void) { | |||
| 82 | } | 170 | } |
| 83 | 171 | ||
| 84 | static void | 172 | static void |
| 173 | setfont(const char *fontstr) { | ||
| 174 | char *def, **missing; | ||
| 175 | int i, n; | ||
| 176 | |||
| 177 | missing = NULL; | ||
| 178 | if(dc.font.set) | ||
| 179 | XFreeFontSet(dpy, dc.font.set); | ||
| 180 | dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); | ||
| 181 | if(missing) { | ||
| 182 | while(n--) | ||
| 183 | fprintf(stderr, "missing fontset: %s\n", missing[n]); | ||
| 184 | XFreeStringList(missing); | ||
| 185 | } | ||
| 186 | if(dc.font.set) { | ||
| 187 | XFontSetExtents *font_extents; | ||
| 188 | XFontStruct **xfonts; | ||
| 189 | char **font_names; | ||
| 190 | dc.font.ascent = dc.font.descent = 0; | ||
| 191 | font_extents = XExtentsOfFontSet(dc.font.set); | ||
| 192 | n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); | ||
| 193 | for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { | ||
| 194 | if(dc.font.ascent < (*xfonts)->ascent) | ||
| 195 | dc.font.ascent = (*xfonts)->ascent; | ||
| 196 | if(dc.font.descent < (*xfonts)->descent) | ||
| 197 | dc.font.descent = (*xfonts)->descent; | ||
| 198 | xfonts++; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | else { | ||
| 202 | if(dc.font.xfont) | ||
| 203 | XFreeFont(dpy, dc.font.xfont); | ||
| 204 | dc.font.xfont = NULL; | ||
| 205 | if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))) | ||
| 206 | eprint("error, cannot load font: '%s'\n", fontstr); | ||
| 207 | dc.font.ascent = dc.font.xfont->ascent; | ||
| 208 | dc.font.descent = dc.font.xfont->descent; | ||
| 209 | } | ||
| 210 | dc.font.height = dc.font.ascent + dc.font.descent; | ||
| 211 | } | ||
| 212 | |||
| 213 | static void | ||
| 85 | setup(void) { | 214 | setup(void) { |
| 86 | int i, j; | 215 | int i, j; |
| 87 | unsigned int mask; | 216 | unsigned int mask; |
| @@ -171,6 +300,37 @@ xerrorstart(Display *dsply, XErrorEvent *ee) { | |||
| 171 | /* extern */ | 300 | /* extern */ |
| 172 | 301 | ||
| 173 | void | 302 | void |
| 303 | drawstatus(void) { | ||
| 304 | int i, x; | ||
| 305 | |||
| 306 | dc.x = dc.y = 0; | ||
| 307 | for(i = 0; i < ntags; i++) { | ||
| 308 | dc.w = textw(tags[i]); | ||
| 309 | if(seltag[i]) | ||
| 310 | drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i)); | ||
| 311 | else | ||
| 312 | drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i)); | ||
| 313 | dc.x += dc.w; | ||
| 314 | } | ||
| 315 | dc.w = bmw; | ||
| 316 | drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False); | ||
| 317 | x = dc.x + dc.w; | ||
| 318 | dc.w = textw(stext); | ||
| 319 | dc.x = sw - dc.w; | ||
| 320 | if(dc.x < x) { | ||
| 321 | dc.x = x; | ||
| 322 | dc.w = sw - x; | ||
| 323 | } | ||
| 324 | drawtext(stext, dc.norm, False, False); | ||
| 325 | if((dc.w = dc.x - x) > bh) { | ||
| 326 | dc.x = x; | ||
| 327 | drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False); | ||
| 328 | } | ||
| 329 | XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); | ||
| 330 | XSync(dpy, False); | ||
| 331 | } | ||
| 332 | |||
| 333 | void | ||
| 174 | sendevent(Window w, Atom a, long value) { | 334 | sendevent(Window w, Atom a, long value) { |
| 175 | XEvent e; | 335 | XEvent e; |
| 176 | 336 | ||
| @@ -184,6 +344,11 @@ sendevent(Window w, Atom a, long value) { | |||
| 184 | XSync(dpy, False); | 344 | XSync(dpy, False); |
| 185 | } | 345 | } |
| 186 | 346 | ||
| 347 | unsigned int | ||
| 348 | textw(const char *text) { | ||
| 349 | return textnw(text, strlen(text)) + dc.font.height; | ||
| 350 | } | ||
| 351 | |||
| 187 | void | 352 | void |
| 188 | quit(Arg *arg) { | 353 | quit(Arg *arg) { |
| 189 | readin = running = False; | 354 | readin = running = False; |
