Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-extrabar-6.2-20210209.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-extrabar-6.2-20210209.diff (5639B)
---
1 commit e8111727686dc5d8194ff95af70c3e4abcc2da54
2 Author: Finn Rayment <[email protected]>
3 Date: Tue Feb 9 16:33:51 2021 +0100
4
5 [PATCH] Updated extra bar support
6
7 diff --git a/config.def.h b/config.def.h
8 index 1c0b587..91593ee 100644
9 --- a/config.def.h
10 +++ b/config.def.h
11 @@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* borde…
12 static const unsigned int snap = 32; /* snap pixel */
13 static const int showbar = 1; /* 0 means no bar */
14 static const int topbar = 1; /* 0 means bottom bar */
15 +static const int extrabarright = 0; /* 1 means extra bar te…
16 +static const char statussep = ';'; /* separator between st…
17 static const char *fonts[] = { "monospace:size=10" };
18 static const char dmenufont[] = "monospace:size=10";
19 static const char col_gray1[] = "#222222";
20 diff --git a/dwm.c b/dwm.c
21 index 4465af1..3db6761 100644
22 --- a/dwm.c
23 +++ b/dwm.c
24 @@ -117,6 +117,7 @@ struct Monitor {
25 int nmaster;
26 int num;
27 int by; /* bar geometry */
28 + int eby; /* extra bar geometry */
29 int mx, my, mw, mh; /* screen size */
30 int wx, wy, ww, wh; /* window area */
31 unsigned int seltags;
32 @@ -129,6 +130,7 @@ struct Monitor {
33 Client *stack;
34 Monitor *next;
35 Window barwin;
36 + Window extrabarwin;
37 const Layout *lt[2];
38 };
39
40 @@ -237,6 +239,7 @@ static void zoom(const Arg *arg);
41 /* variables */
42 static const char broken[] = "broken";
43 static char stext[256];
44 +static char estext[256];
45 static int screen;
46 static int sw, sh; /* X display screen geometry width, height…
47 static int bh, blw = 0; /* bar geometry */
48 @@ -505,7 +508,9 @@ cleanupmon(Monitor *mon)
49 m->next = mon->next;
50 }
51 XUnmapWindow(dpy, mon->barwin);
52 + XUnmapWindow(dpy, mon->extrabarwin);
53 XDestroyWindow(dpy, mon->barwin);
54 + XDestroyWindow(dpy, mon->extrabarwin);
55 free(mon);
56 }
57
58 @@ -568,6 +573,7 @@ configurenotify(XEvent *e)
59 if (c->isfullscreen)
60 resizeclient(c, m->mx, …
61 XMoveResizeWindow(dpy, m->barwin, m->wx…
62 + XMoveResizeWindow(dpy, m->extrabarwin, …
63 }
64 focus(NULL);
65 arrange(NULL);
66 @@ -740,6 +746,19 @@ drawbar(Monitor *m)
67 }
68 }
69 drw_map(drw, m->barwin, 0, 0, m->ww, bh);
70 +
71 + if (m == selmon) { /* extra status is only drawn on selected mo…
72 + drw_setscheme(drw, scheme[SchemeNorm]);
73 + /* clear default bar draw buffer by drawing a blank rec…
74 + drw_rect(drw, 0, 0, m->ww, bh, 1, 1);
75 + if (extrabarright) {
76 + sw = TEXTW(estext) - lrpad + 2; /* 2px right pa…
77 + drw_text(drw, m->ww - sw, 0, sw, bh, 0, estext,…
78 + } else {
79 + drw_text(drw, 0, 0, mons->ww, bh, 0, estext, 0);
80 + }
81 + drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
82 + }
83 }
84
85 void
86 @@ -1702,6 +1721,7 @@ togglebar(const Arg *arg)
87 selmon->showbar = !selmon->showbar;
88 updatebarpos(selmon);
89 XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, …
90 + XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon-…
91 arrange(selmon);
92 }
93
94 @@ -1809,14 +1829,22 @@ updatebars(void)
95 };
96 XClassHint ch = {"dwm", "dwm"};
97 for (m = mons; m; m = m->next) {
98 - if (m->barwin)
99 - continue;
100 - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->w…
101 - CopyFromParent, DefaultVisual(dpy, scre…
102 - CWOverrideRedirect|CWBackPixmap|CWEvent…
103 - XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor…
104 - XMapRaised(dpy, m->barwin);
105 - XSetClassHint(dpy, m->barwin, &ch);
106 + if (!m->barwin) {
107 + m->barwin = XCreateWindow(dpy, root, m->wx, m->…
108 + CopyFromParent, DefaultVisual(d…
109 + CWOverrideRedirect|CWBackPixmap…
110 + XDefineCursor(dpy, m->barwin, cursor[CurNormal]…
111 + XMapRaised(dpy, m->barwin);
112 + XSetClassHint(dpy, m->barwin, &ch);
113 + }
114 + if (!m->extrabarwin) {
115 + m->extrabarwin = XCreateWindow(dpy, root, m->wx…
116 + CopyFromParent, DefaultVisual(d…
117 + CWOverrideRedirect|CWBackPixmap…
118 + XDefineCursor(dpy, m->extrabarwin, cursor[CurNo…
119 + XMapRaised(dpy, m->extrabarwin);
120 + XSetClassHint(dpy, m->extrabarwin, &ch);
121 + }
122 }
123 }
124
125 @@ -1825,12 +1853,15 @@ updatebarpos(Monitor *m)
126 {
127 m->wy = m->my;
128 m->wh = m->mh;
129 + m->wh -= bh * m->showbar * 2;
130 + m->wy = m->showbar ? m->wy + bh : m->wy;
131 if (m->showbar) {
132 - m->wh -= bh;
133 - m->by = m->topbar ? m->wy : m->wy + m->wh;
134 - m->wy = m->topbar ? m->wy + bh : m->wy;
135 - } else
136 + m->by = m->topbar ? m->wy - bh : m->wy + m->wh;
137 + m->eby = m->topbar ? m->wy + m->wh : m->wy - bh;
138 + } else {
139 m->by = -bh;
140 + m->eby = -bh;
141 + }
142 }
143
144 void
145 @@ -1987,8 +2018,20 @@ updatesizehints(Client *c)
146 void
147 updatestatus(void)
148 {
149 - if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
150 + char text[512];
151 + if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
152 strcpy(stext, "dwm-"VERSION);
153 + estext[0] = '\0';
154 + } else {
155 + char *e = strchr(text, statussep);
156 + if (e) {
157 + *e = '\0'; e++;
158 + strncpy(estext, e, sizeof(estext) - 1);
159 + } else {
160 + estext[0] = '\0';
161 + }
162 + strncpy(stext, text, sizeof(stext) - 1);
163 + }
164 drawbar(selmon);
165 }
166
167 @@ -2067,7 +2110,7 @@ wintomon(Window w)
168 if (w == root && getrootptr(&x, &y))
169 return recttomon(x, y, 1, 1);
170 for (m = mons; m; m = m->next)
171 - if (w == m->barwin)
172 + if (w == m->barwin || w == m->extrabarwin)
173 return m;
174 if ((c = wintoclient(w)))
175 return c->mon;
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.