-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdwm-jgrar-patch-set-20180106-db22360.patch
755 lines (695 loc) · 24.3 KB
/
dwm-jgrar-patch-set-20180106-db22360.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
From 98a70eb42d638075edc142b85df767c34fd5feb0 Mon Sep 17 00:00:00 2001
From: Jonathen Russell <jgr006@gmail.com>
Date: Sat, 6 Jan 2018 22:27:56 +1000
Subject: [PATCH 1/6] Apply fancybar patch
---
dwm.c | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/dwm.c b/dwm.c
index ec6a27c..821922a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -696,10 +696,10 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
- int x, w, sw = 0;
+ int x, w, sw = 0, tw, mw, ew = 0;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
- unsigned int i, occ = 0, urg = 0;
+ unsigned int i, occ = 0, urg = 0, n = 0;
Client *c;
/* draw status first so it can be overdrawn by tags later */
@@ -710,6 +710,8 @@ drawbar(Monitor *m)
}
for (c = m->clients; c; c = c->next) {
+ if (ISVISIBLE(c))
+ n++;
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
@@ -730,15 +732,39 @@ drawbar(Monitor *m)
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
if ((w = m->ww - sw - x) > bh) {
- if (m->sel) {
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
- if (m->sel->isfloating)
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
- } else {
- drw_setscheme(drw, scheme[SchemeNorm]);
- drw_rect(drw, x, 0, w, bh, 1, 1);
+ if (n > 0) {
+ tw = TEXTW(m->sel->name);
+ mw = (tw >= w || n == 1) ? 0 : (w - tw) / (n - 1);
+
+ i = 0;
+ for (c = m->clients; c; c = c->next) {
+ if (!ISVISIBLE(c) || c == m->sel)
+ continue;
+ tw = TEXTW(c->name);
+ if(tw < mw)
+ ew += (mw - tw);
+ else
+ i++;
+ }
+ if (i > 0)
+ mw += ew / i;
+
+ for (c = m->clients; c; c = c->next) {
+ if (!ISVISIBLE(c))
+ continue;
+ tw = MIN(m->sel == c ? w : mw, TEXTW(c->name));
+
+ drw_setscheme(drw, scheme[m->sel == c ? SchemeSel : SchemeNorm]);
+ if (tw > 0) /* trap special handling of 0 in drw_text */
+ drw_text(drw, x, 0, tw, bh, lrpad / 2, c->name, 0);
+ if (c->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
+ x += tw;
+ w -= tw;
+ }
}
+ drw_setscheme(drw, scheme[SchemeNorm]);
+ drw_rect(drw, x, 0, w, bh, 1, 1);
}
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
}
--
2.15.1
From 011d11fb9acfd83d11f988cd05cdd5bd028c2599 Mon Sep 17 00:00:00 2001
From: Jonathen Russell <jgr006@gmail.com>
Date: Sat, 6 Jan 2018 22:44:33 +1000
Subject: [PATCH 2/6] Apply alpha patch
---
config.def.h | 1 +
config.mk | 2 +-
drw.c | 53 ++++++++++++++++++++++++++++++++++++++-------------
drw.h | 11 ++++++++---
dwm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
5 files changed, 106 insertions(+), 23 deletions(-)
diff --git a/config.def.h b/config.def.h
index a9ac303..6fb9c28 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,6 +1,7 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
+static const unsigned short alpha = 0x90; /* background color alpha */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
diff --git a/config.mk b/config.mk
index 80dc936..2c62e89 100644
--- a/config.mk
+++ b/config.mk
@@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender
# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
diff --git a/drw.c b/drw.c
index c638323..dca8f9e 100644
--- a/drw.c
+++ b/drw.c
@@ -61,7 +61,8 @@ utf8decode(const char *c, long *u, size_t clen)
}
Drw *
-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h,
+ Visual *visual, unsigned int depth, Colormap cmap)
{
Drw *drw = ecalloc(1, sizeof(Drw));
@@ -70,8 +71,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
drw->root = root;
drw->w = w;
drw->h = h;
- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
- drw->gc = XCreateGC(dpy, root, 0, NULL);
+ drw->visual = visual;
+ drw->depth = depth;
+ drw->cmap = cmap;
+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
return drw;
@@ -87,7 +91,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
drw->h = h;
if (drw->drawable)
XFreePixmap(drw->dpy, drw->drawable);
- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
}
void
@@ -180,21 +184,43 @@ drw_fontset_free(Fnt *font)
}
void
-drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
+drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned short alpha)
{
if (!drw || !dest || !clrname)
return;
- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
- DefaultColormap(drw->dpy, drw->screen),
- clrname, dest))
+ if (alpha < OPAQUE) {
+ XColor c;
+ XRenderPictFormat *fmt;
+
+ if ((drw->visual->class == TrueColor)
+ && (fmt = XRenderFindVisualFormat(drw->dpy, drw->visual))) {
+
+ if (!XParseColor(drw->dpy, drw->cmap, clrname, &c))
+ die("error, cannot parse color '%s'", clrname);
+ else {
+ dest->color.red = c.red * alpha / 0xffff;
+ dest->color.green = c.green * alpha / 0xffff;
+ dest->color.blue = c.blue * alpha / 0xffff;
+ dest->color.alpha = alpha;
+
+ dest->pixel =
+ ((dest->color.red * (fmt->direct.redMask + 1) >> 8) << fmt->direct.red )
+ | ((dest->color.green * (fmt->direct.greenMask + 1) >> 8) << fmt->direct.green)
+ | ((dest->color.blue * (fmt->direct.blueMask + 1) >> 8) << fmt->direct.blue )
+ | ((dest->color.alpha * (fmt->direct.alphaMask + 1) >> 8) << fmt->direct.alpha);
+ return;
+ }
+ }
+ }
+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap, clrname, dest))
die("error, cannot allocate color '%s'", clrname);
}
/* Wrapper to create color schemes. The caller has to call free(3) on the
* returned color scheme when done using it. */
Clr *
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
+drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount, unsigned short alpha)
{
size_t i;
Clr *ret;
@@ -204,7 +230,9 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
return NULL;
for (i = 0; i < clrcount; i++)
- drw_clr_create(drw, &ret[i], clrnames[i]);
+ drw_clr_create(drw, &ret[i], clrnames[i],
+ (i == ColBg)? alpha: OPAQUE);
+
return ret;
}
@@ -260,9 +288,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
} else {
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
- d = XftDrawCreate(drw->dpy, drw->drawable,
- DefaultVisual(drw->dpy, drw->screen),
- DefaultColormap(drw->dpy, drw->screen));
+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual,
+ drw->cmap);
x += lpad;
w -= lpad;
}
diff --git a/drw.h b/drw.h
index 4c67419..bb8d85d 100644
--- a/drw.h
+++ b/drw.h
@@ -12,6 +12,7 @@ typedef struct Fnt {
struct Fnt *next;
} Fnt;
+#define OPAQUE 0xff
enum { ColFg, ColBg }; /* Clr scheme index */
typedef XftColor Clr;
@@ -20,6 +21,9 @@ typedef struct {
Display *dpy;
int screen;
Window root;
+ Visual *visual;
+ unsigned int depth;
+ Colormap cmap;
Drawable drawable;
GC gc;
Clr *scheme;
@@ -27,7 +31,8 @@ typedef struct {
} Drw;
/* Drawable abstraction */
-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h,
+ Visual *visual, unsigned int depth, Colormap cmap);
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
void drw_free(Drw *drw);
@@ -38,8 +43,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
/* Colorscheme abstraction */
-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned short alpha);
+Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount, unsigned short alpha);
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
diff --git a/dwm.c b/dwm.c
index 821922a..786595f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -269,6 +269,10 @@ static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
+static unsigned int depth;
+static Visual *visual;
+static Colormap cmap;
+
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -1568,7 +1572,52 @@ setup(void)
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
root = RootWindow(dpy, screen);
- drw = drw_create(dpy, screen, root, sw, sh);
+
+ if (alpha < OPAQUE) {
+ XVisualInfo *vis;
+ XRenderPictFormat *fmt;
+ int nvi;
+ int i;
+
+ depth = 32;
+ XVisualInfo tpl = {
+ .screen = screen,
+ .depth = depth,
+ .class = TrueColor
+ };
+
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
+ vis = XGetVisualInfo(dpy, masks, &tpl, &nvi);
+
+ visual = NULL;
+
+ for (i = 0; i < nvi; i++) {
+ fmt = XRenderFindVisualFormat(dpy, vis[i].visual);
+ if (fmt->type == PictTypeDirect
+ && fmt->direct.alphaMask) {
+ visual = vis[i].visual;
+ depth = vis[i].depth;
+ cmap = XCreateColormap(dpy, root, visual, None);
+ break;
+ }
+ }
+
+ XFree(vis);
+ if (!visual)
+ fprintf(stderr, "Couldn't find ARGB visual.\n");
+ }
+
+ if (!depth)
+ depth = DefaultDepth(dpy, screen);
+
+ if (!visual)
+ visual = DefaultVisual(dpy, screen);
+
+ if (!cmap)
+ cmap = DefaultColormap(dpy, screen);
+
+ drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap);
+
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
die("no fonts could be loaded.");
lrpad = drw->fonts->h;
@@ -1596,7 +1645,7 @@ setup(void)
/* init appearance */
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
for (i = 0; i < LENGTH(colors); i++)
- scheme[i] = drw_scm_create(drw, colors[i], 3);
+ scheme[i] = drw_scm_create(drw, colors[i], 3, alpha);
/* init bars */
updatebars();
updatestatus();
@@ -1831,16 +1880,17 @@ updatebars(void)
Monitor *m;
XSetWindowAttributes wa = {
.override_redirect = True,
- .background_pixmap = ParentRelative,
+ .colormap = cmap,
.event_mask = ButtonPressMask|ExposureMask
};
XClassHint ch = {"dwm", "dwm"};
for (m = mons; m; m = m->next) {
if (m->barwin)
continue;
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
- CopyFromParent, DefaultVisual(dpy, screen),
- CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0,
+ drw->depth, CopyFromParent, drw->visual,
+ CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &wa
+ );
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
XMapRaised(dpy, m->barwin);
XSetClassHint(dpy, m->barwin, &ch);
--
2.15.1
From a7318b090ef55b5b74e64b75ecf0c51ea5797d0b Mon Sep 17 00:00:00 2001
From: Jonathen Russell <jgr006@gmail.com>
Date: Sat, 6 Jan 2018 23:07:01 +1000
Subject: [PATCH 3/6] Apply statuscolors patch
---
config.def.h | 2 ++
drw.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
drw.h | 2 ++
dwm.c | 12 ++++++------
4 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 6fb9c28..14f9526 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,10 +13,12 @@ static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577";
+static const char col_red[] = "#ee4444";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ [SchemeUrg] = { col_gray4, col_red, col_red },
};
/* tagging */
diff --git a/drw.c b/drw.c
index dca8f9e..d05a732 100644
--- a/drw.c
+++ b/drw.c
@@ -250,6 +250,52 @@ drw_setscheme(Drw *drw, Clr *scm)
drw->scheme = scm;
}
+int
+drw_get_width(Drw *drw, int numcolors, const char *text)
+{
+ int i;
+ Fnt *curfont = drw->fonts;
+ int w = drw_text(drw, 0, 0, 0, 0, 0, text, 0);
+ unsigned int ew;
+
+ drw_font_getexts(curfont, "\x01", 1, &ew, NULL);
+
+ for (i = 0; i < strlen(text); i++) {
+ if (text[i] > 0 && text[i] <= numcolors) {
+ /* we found a color code
+ * drw_text counted it as a normal character and added one character's width
+ * we aren't going to render this character, so we remove one character's width */
+ w -= ew;
+
+ }
+ }
+ return w;
+}
+
+void
+drw_colored_text(Drw *drw, Clr **scheme, int numcolors, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, char *text)
+{
+ if (!drw || !drw->fonts || !drw->scheme)
+ return;
+
+ char *buf = text, *ptr = buf, c = 1;
+ int i;
+
+ while (*ptr) {
+ for (i = 0; *ptr < 0 || *ptr > numcolors; i++, ptr++);
+ if (!*ptr)
+ break;
+ c = *ptr;
+ *ptr = 0;
+ if (i)
+ x = drw_text(drw, x, y, w, h, lpad, buf, 0);
+ *ptr = c;
+ drw_setscheme(drw, scheme[c-1]);
+ buf = ++ptr;
+ }
+ drw_text(drw, x, y, w, h, lpad, buf, 0);
+}
+
void
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
{
@@ -388,7 +434,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
if (d)
XftDrawDestroy(d);
- return x + (render ? w : 0);
+ return x;
}
void
diff --git a/drw.h b/drw.h
index bb8d85d..f1b0dd1 100644
--- a/drw.h
+++ b/drw.h
@@ -55,6 +55,8 @@ void drw_setfontset(Drw *drw, Fnt *set);
void drw_setscheme(Drw *drw, Clr *scm);
/* Drawing functions */
+int drw_get_width(Drw *drw, int numcolors, const char *text);
+void drw_colored_text(Drw *drw, Clr **scheme, int numcolors, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, char *text);
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
diff --git a/dwm.c b/dwm.c
index 786595f..b4774d0 100644
--- a/dwm.c
+++ b/dwm.c
@@ -60,7 +60,7 @@
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -709,8 +709,8 @@ drawbar(Monitor *m)
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]);
- sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
+ sw = drw_get_width(drw, LENGTH(colors), stext);
+ drw_colored_text(drw, scheme, LENGTH(colors), m->ww - sw, 0, sw, bh, 0, stext);
}
for (c = m->clients; c; c = c->next) {
@@ -723,12 +723,12 @@ drawbar(Monitor *m)
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+ drw_setscheme(drw, scheme[(m->tagset[m->seltags] & 1 << i) ? SchemeSel : (urg & 1 << i ? SchemeUrg : SchemeNorm)]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], 0);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
- urg & 1 << i);
+ 0);
x += w;
}
w = blw = TEXTW(m->ltsymbol);
--
2.15.1
From 0f66d1dfe435b292a0df1634337e5281e0113d3a Mon Sep 17 00:00:00 2001
From: Jonathen Russell <jgr006@gmail.com>
Date: Sat, 6 Jan 2018 23:10:10 +1000
Subject: [PATCH 4/6] Apply useless gap patch
---
config.def.h | 1 +
dwm.c | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/config.def.h b/config.def.h
index 14f9526..02bfca5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,6 +3,7 @@
/* appearance */
static const unsigned short alpha = 0x90; /* background color alpha */
static const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int gappx = 16; /* border gap pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
diff --git a/dwm.c b/dwm.c
index b4774d0..3b40942 100644
--- a/dwm.c
+++ b/dwm.c
@@ -52,8 +52,8 @@
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
-#define WIDTH(X) ((X)->w + 2 * (X)->bw)
-#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
+#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
#define ColBorder 2
@@ -1307,11 +1307,19 @@ void
resizeclient(Client *c, int x, int y, int w, int h)
{
XWindowChanges wc;
+ unsigned int gapoffset, gapincr;
- c->oldx = c->x; c->x = wc.x = x;
- c->oldy = c->y; c->y = wc.y = y;
- c->oldw = c->w; c->w = wc.width = w;
- c->oldh = c->h; c->h = wc.height = h;
+ if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) {
+ gapoffset = gapincr = 0;
+ } else {
+ gapoffset = gappx;
+ gapincr = 2 * gappx;
+ }
+
+ c->oldx = c->x; c->x = wc.x = x + gapoffset;
+ c->oldy = c->y; c->y = wc.y = y + gapoffset;
+ c->oldw = c->w; c->w = wc.width = w - gapincr;
+ c->oldh = c->h; c->h = wc.height = h - gapincr;
wc.border_width = c->bw;
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
--
2.15.1
From 6fd3ca5352e26a4c27f115156b73f302d8671b69 Mon Sep 17 00:00:00 2001
From: Jonathen Russell <jgr006@gmail.com>
Date: Sat, 6 Jan 2018 23:13:43 +1000
Subject: [PATCH 5/6] Apply save floats patch
---
dwm.c | 42 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/dwm.c b/dwm.c
index 3b40942..680bf4a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -89,6 +89,7 @@ struct Client {
char name[256];
float mina, maxa;
int x, y, w, h;
+ int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
int oldx, oldy, oldw, oldh;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
@@ -1087,6 +1088,10 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
if (!c->isfloating)
@@ -1539,10 +1544,33 @@ setfullscreen(Client *c, int fullscreen)
void
setlayout(const Arg *arg)
{
+ Monitor *m;
+ Client *c;
+
+ unsigned int fromlt = selmon->sellt;
+
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if (arg && arg->v)
selmon->lt[selmon->sellt] = (Layout *)arg->v;
+
+ /* switch from floating */
+ if (selmon->lt[fromlt]->arrange == NULL)
+ /*save last known float dimensions*/
+ for (m = mons; m; m = m->next)
+ for (c = m->clients; c; c = c->next) {
+ c->sfx = c->x;
+ c->sfy = c->y;
+ c->sfw = c->w;
+ c->sfh = c->h;
+ }
+ /* switch to floating */
+ else if (selmon->lt[selmon->sellt]->arrange == NULL)
+ /*restore last known float dimensions*/
+ for (m = mons; m; m = m->next)
+ for (c = m->clients; c; c = c->next)
+ resize(c, c->sfx, c->sfy, c->sfw, c->sfh, 0);
+
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if (selmon->sel)
arrange(selmon);
@@ -1797,9 +1825,17 @@ togglefloating(const Arg *arg)
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
- if (selmon->sel->isfloating)
- resize(selmon->sel, selmon->sel->x, selmon->sel->y,
- selmon->sel->w, selmon->sel->h, 0);
+ if (selmon->sel->isfloating) {
+ /*restore last known float dimensions*/
+ resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
+ selmon->sel->sfw, selmon->sel->sfh, 0);
+ } else {
+ /*save last known float dimensions*/
+ selmon->sel->sfx = selmon->sel->x;
+ selmon->sel->sfy = selmon->sel->y;
+ selmon->sel->sfw = selmon->sel->w;
+ selmon->sel->sfh = selmon->sel->h;
+ }
arrange(selmon);
}
--
2.15.1
From 20e039099a38a3aeaa38ce62e8b758658e58bca8 Mon Sep 17 00:00:00 2001
From: Jonathen Russell <jgr006@gmail.com>
Date: Sat, 6 Jan 2018 23:18:01 +1000
Subject: [PATCH 6/6] Apply config.def.h patch
---
config.def.h | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/config.def.h b/config.def.h
index 02bfca5..6c10d38 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,27 +3,26 @@
/* appearance */
static const unsigned short alpha = 0x90; /* background color alpha */
static const unsigned int borderpx = 1; /* border pixel of windows */
-static const unsigned int gappx = 16; /* border gap pixel of windows */
-static const unsigned int snap = 32; /* snap pixel */
+static const unsigned int gappx = 8; /* border gap pixel of windows */
+static const unsigned int snap = 16; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
-static const char *fonts[] = { "monospace:size=10" };
-static const char dmenufont[] = "monospace:size=10";
-static const char col_gray1[] = "#222222";
-static const char col_gray2[] = "#444444";
-static const char col_gray3[] = "#bbbbbb";
-static const char col_gray4[] = "#eeeeee";
-static const char col_cyan[] = "#005577";
-static const char col_red[] = "#ee4444";
+static const char *fonts[] = { "Inconsolata:size=10:antialias=true" };
+static const char dmenufont[] = "Inconsolata:size=10:antialias=true";
+static const char col_bg[] = "#202020";
+static const char col_border[] = "#696969";
+static const char col_norm[] = "#606060";
+static const char col_sel[] = "#aaaaaa";
+static const char col_urg[] = "#ce5c00";
static const char *colors[][3] = {
/* fg bg border */
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
- [SchemeUrg] = { col_gray4, col_red, col_red },
+ [SchemeNorm] = { col_norm, col_bg, col_border },
+ [SchemeSel] = { col_sel, col_bg, col_border },
+ [SchemeUrg] = { col_urg, col_bg, col_border },
};
/* tagging */
-static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const char *tags[] = { "I", "II", "III", "IV", "V" };
static const Rule rules[] = {
/* xprop(1):
@@ -60,7 +59,7 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", "#202020", "-nf", "#606060", "-sb", "#202020", "-sf", "#aaaaaa", NULL };
static const char *termcmd[] = { "st", NULL };
static Key keys[] = {
--
2.15.1