comparison config/dwm/dwm.c @ 2:a2c891f7b914

Occasional commit 2
author Yasuri <yasuri@charliesmp.net>
date Sat, 03 Oct 2026 18:53:08 -0500
parents face7f4d84f7
children
comparison
equal deleted inserted replaced
1:f78c8a98f113 2:a2c891f7b914
142 const char *title; 142 const char *title;
143 unsigned int tags; 143 unsigned int tags;
144 int isfloating; 144 int isfloating;
145 int monitor; 145 int monitor;
146 } Rule; 146 } Rule;
147
148 typedef struct {
149 int x, y, w, h;
150 } DwmLogo;
147 151
148 /* function declarations */ 152 /* function declarations */
149 static void applyrules(Client *c); 153 static void applyrules(Client *c);
150 static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); 154 static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
151 static void arrange(Monitor *m); 155 static void arrange(Monitor *m);
243 static char stext[256]; 247 static char stext[256];
244 static int screen; 248 static int screen;
245 static int sw, sh; /* X display screen geometry width, height */ 249 static int sw, sh; /* X display screen geometry width, height */
246 static int bh; /* bar height */ 250 static int bh; /* bar height */
247 static int lrpad; /* sum of left and right padding for text */ 251 static int lrpad; /* sum of left and right padding for text */
252 static int dwmlogowdth = 54; /* dwm logo width */
248 static int (*xerrorxlib)(Display *, XErrorEvent *); 253 static int (*xerrorxlib)(Display *, XErrorEvent *);
249 static unsigned int numlockmask = 0; 254 static unsigned int numlockmask = 0;
250 static void (*handler[LASTEvent]) (XEvent *) = { 255 static void (*handler[LASTEvent]) (XEvent *) = {
251 [ButtonPress] = buttonpress, 256 [ButtonPress] = buttonpress,
252 [ClientMessage] = clientmessage, 257 [ClientMessage] = clientmessage,
435 selmon = m; 440 selmon = m;
436 focus(NULL); 441 focus(NULL);
437 } 442 }
438 if (ev->window == selmon->barwin) { 443 if (ev->window == selmon->barwin) {
439 i = x = 0; 444 i = x = 0;
445 x = dwmlogowdth; /* dwm logo width */
440 do 446 do
441 x += TEXTW(tags[i]); 447 x += TEXTW(tags[i]);
442 while (ev->x >= x && ++i < LENGTH(tags)); 448 while (ev->x >= x && ++i < LENGTH(tags));
443 if (i < LENGTH(tags)) { 449 if (i < LENGTH(tags)) {
444 click = ClkTagBar; 450 click = ClkTagBar;
705 711
706 void 712 void
707 drawbar(Monitor *m) 713 drawbar(Monitor *m)
708 { 714 {
709 int x, w, tw = 0; 715 int x, w, tw = 0;
716 int stroke = 4, letterHeight = bh - 4;
710 int boxs = drw->fonts->h / 9; 717 int boxs = drw->fonts->h / 9;
711 int boxw = drw->fonts->h / 6 + 2; 718 int boxw = drw->fonts->h / 6 + 2;
712 unsigned int i, occ = 0, urg = 0; 719 unsigned int i, occ = 0, urg = 0;
713 Client *c; 720 Client *c;
714 721
725 for (c = m->clients; c; c = c->next) { 732 for (c = m->clients; c; c = c->next) {
726 occ |= c->tags; 733 occ |= c->tags;
727 if (c->isurgent) 734 if (c->isurgent)
728 urg |= c->tags; 735 urg |= c->tags;
729 } 736 }
730 x = 0; 737
738 /* use colored scheme for visibility */
739 drw_setscheme(drw, scheme[SchemeNorm]);
740
741 /* draw dark background for logo */
742 drw_rect(drw, 0, 0, dwmlogowdth, bh, 1, 1);
743
744 /* draw dwm logo */
745 const DwmLogo dwmLogo[] = {
746 { 0, 9, stroke, letterHeight / 2 }, /* d: left vertical */
747 { 0, 15, 35, stroke }, /* d: bottom horizontal */
748 { 13, 1, stroke, letterHeight }, /* d: right vertical */
749 { 0, 7, 15, stroke }, /* d: top horizontal */
750 { 22, 7, stroke, letterHeight / 2 }, /* w: center vertical */
751 { 31, 7, stroke, letterHeight / 2 }, /* w: right vertical */
752 { 31, 7, 22, stroke }, /* m: top horizontal */
753 { 40, 11, stroke, letterHeight / 2 }, /* m: center vertical */
754 { 49, 11, stroke, letterHeight / 2 } /* m: right vertical */
755 };
756
757 for (int i = 0; i < LENGTH(dwmLogo); i++) {
758 drw_rect(drw, dwmLogo[i].x, dwmLogo[i].y, dwmLogo[i].w, dwmLogo[i].h, 1, 0);
759 }
760
761 /* start drawing tags after logo */
762 x = dwmlogowdth;
731 for (i = 0; i < LENGTH(tags); i++) { 763 for (i = 0; i < LENGTH(tags); i++) {
732 w = TEXTW(tags[i]); 764 w = TEXTW(tags[i]);
733 drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); 765 drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
734 drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); 766 drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
735 if (occ & 1 << i)
736 drw_rect(drw, x + boxs, boxs, boxw, boxw,
737 m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
738 urg & 1 << i);
739 x += w; 767 x += w;
740 } 768 }
741 w = TEXTW(m->ltsymbol); 769 w = TEXTW(m->ltsymbol);
742 drw_setscheme(drw, scheme[SchemeNorm]); 770 drw_setscheme(drw, scheme[SchemeNorm]);
743 x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); 771 x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);