Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-extrabar-6.2-20190810.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-extrabar-6.2-20190810.diff (5680B)
---
1 From 042ea1c2dc84afa9cb35d4bf2e49da05f46a6fef Mon Sep 17 00:00:00 2001
2 From: Chip Senkbeil <[email protected]>
3 Date: Sat, 10 Aug 2019 15:22:34 -0500
4 Subject: [PATCH] Added extra bar support
5
6 ---
7 config.def.h | 2 +-
8 dwm.c | 64 ++++++++++++++++++++++++++++++++++++++++------------
9 2 files changed, 51 insertions(+), 15 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 1c0b587..8126ef2 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* borde…
16 static const unsigned int snap = 32; /* snap pixel */
17 static const int showbar = 1; /* 0 means no bar */
18 static const int topbar = 1; /* 0 means bottom bar */
19 +static const char statussep = ';'; /* separator between st…
20 static const char *fonts[] = { "monospace:size=10" };
21 static const char dmenufont[] = "monospace:size=10";
22 static const char col_gray1[] = "#222222";
23 @@ -112,4 +113,3 @@ static Button buttons[] = {
24 { ClkTagBar, MODKEY, Button1, tag, …
25 { ClkTagBar, MODKEY, Button3, togglet…
26 };
27 -
28 diff --git a/dwm.c b/dwm.c
29 index 4465af1..c1117ec 100644
30 --- a/dwm.c
31 +++ b/dwm.c
32 @@ -117,6 +117,7 @@ struct Monitor {
33 int nmaster;
34 int num;
35 int by; /* bar geometry */
36 + int eby; /* extra bar geometry */
37 int mx, my, mw, mh; /* screen size */
38 int wx, wy, ww, wh; /* window area */
39 unsigned int seltags;
40 @@ -129,6 +130,7 @@ struct Monitor {
41 Client *stack;
42 Monitor *next;
43 Window barwin;
44 + Window extrabarwin;
45 const Layout *lt[2];
46 };
47
48 @@ -237,6 +239,7 @@ static void zoom(const Arg *arg);
49 /* variables */
50 static const char broken[] = "broken";
51 static char stext[256];
52 +static char estext[256];
53 static int screen;
54 static int sw, sh; /* X display screen geometry width, height…
55 static int bh, blw = 0; /* bar geometry */
56 @@ -505,7 +508,9 @@ cleanupmon(Monitor *mon)
57 m->next = mon->next;
58 }
59 XUnmapWindow(dpy, mon->barwin);
60 + XUnmapWindow(dpy, mon->extrabarwin);
61 XDestroyWindow(dpy, mon->barwin);
62 + XDestroyWindow(dpy, mon->extrabarwin);
63 free(mon);
64 }
65
66 @@ -568,6 +573,7 @@ configurenotify(XEvent *e)
67 if (c->isfullscreen)
68 resizeclient(c, m->mx, …
69 XMoveResizeWindow(dpy, m->barwin, m->wx…
70 + XMoveResizeWindow(dpy, m->extrabarwin, …
71 }
72 focus(NULL);
73 arrange(NULL);
74 @@ -740,6 +746,12 @@ drawbar(Monitor *m)
75 }
76 }
77 drw_map(drw, m->barwin, 0, 0, m->ww, bh);
78 +
79 + if (m == selmon) { /* extra status is only drawn on selected mo…
80 + drw_setscheme(drw, scheme[SchemeNorm]);
81 + drw_text(drw, 0, 0, mons->ww, bh, 0, estext, 0);
82 + drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
83 + }
84 }
85
86 void
87 @@ -1702,6 +1714,7 @@ togglebar(const Arg *arg)
88 selmon->showbar = !selmon->showbar;
89 updatebarpos(selmon);
90 XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, …
91 + XMoveResizeWindow(dpy, selmon->extrabarwin, selmon->wx, selmon-…
92 arrange(selmon);
93 }
94
95 @@ -1809,14 +1822,22 @@ updatebars(void)
96 };
97 XClassHint ch = {"dwm", "dwm"};
98 for (m = mons; m; m = m->next) {
99 - if (m->barwin)
100 - continue;
101 - m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->w…
102 - CopyFromParent, DefaultVisual(dpy, scre…
103 - CWOverrideRedirect|CWBackPixmap|CWEvent…
104 - XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor…
105 - XMapRaised(dpy, m->barwin);
106 - XSetClassHint(dpy, m->barwin, &ch);
107 + if (!m->barwin) {
108 + m->barwin = XCreateWindow(dpy, root, m->wx, m->…
109 + CopyFromParent, DefaultVisual(d…
110 + CWOverrideRedirect|CWBackPixmap…
111 + XDefineCursor(dpy, m->barwin, cursor[CurNormal]…
112 + XMapRaised(dpy, m->barwin);
113 + XSetClassHint(dpy, m->barwin, &ch);
114 + }
115 + if (!m->extrabarwin) {
116 + m->extrabarwin = XCreateWindow(dpy, root, m->wx…
117 + CopyFromParent, DefaultVisual(d…
118 + CWOverrideRedirect|CWBackPixmap…
119 + XDefineCursor(dpy, m->extrabarwin, cursor[CurNo…
120 + XMapRaised(dpy, m->extrabarwin);
121 + XSetClassHint(dpy, m->extrabarwin, &ch);
122 + }
123 }
124 }
125
126 @@ -1825,12 +1846,15 @@ updatebarpos(Monitor *m)
127 {
128 m->wy = m->my;
129 m->wh = m->mh;
130 + m->wh -= bh * m->showbar * 2;
131 + m->wy = m->showbar ? m->wy + bh : m->wy;
132 if (m->showbar) {
133 - m->wh -= bh;
134 - m->by = m->topbar ? m->wy : m->wy + m->wh;
135 - m->wy = m->topbar ? m->wy + bh : m->wy;
136 - } else
137 + m->by = m->topbar ? m->wy - bh : m->wy + m->wh;
138 + m->eby = m->topbar ? m->wy + m->wh : m->wy - bh;
139 + } else {
140 m->by = -bh;
141 + m->eby = -bh;
142 + }
143 }
144
145 void
146 @@ -1987,8 +2011,20 @@ updatesizehints(Client *c)
147 void
148 updatestatus(void)
149 {
150 - if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
151 + char text[512];
152 + if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
153 strcpy(stext, "dwm-"VERSION);
154 + estext[0] = '\0';
155 + } else {
156 + char *e = strchr(text, statussep);
157 + if (e) {
158 + *e = '\0'; e++;
159 + strncpy(estext, e, sizeof(estext) - 1);
160 + } else {
161 + estext[0] = '\0';
162 + }
163 + strncpy(stext, text, sizeof(stext) - 1);
164 + }
165 drawbar(selmon);
166 }
167
168 @@ -2067,7 +2103,7 @@ wintomon(Window w)
169 if (w == root && getrootptr(&x, &y))
170 return recttomon(x, y, 1, 1);
171 for (m = mons; m; m = m->next)
172 - if (w == m->barwin)
173 + if (w == m->barwin || w == m->extrabarwin)
174 return m;
175 if ((c = wintoclient(w)))
176 return c->mon;
177 --
178 2.22.0
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.