dwm-systray_left-20210216-66ca60e.diff (4807B)
1 From 66ca60e5561caedc7b1c4a648cb79d9347c9f3a3 Mon Sep 17 00:00:00 2001 2 From: Hritik Vijay <hr1t1k@pm.me> 3 Date: Tue, 16 Feb 2021 17:25:59 +0530 4 Subject: [PATCH] Move systray to the left of status text 5 6 This patch works on the top of systray patch by Igor Gevka and moves the 7 systray to the left of status text. More like Windows XP style. 8 --- 9 dwm.c | 34 ++++++++-------------------------- 10 1 file changed, 8 insertions(+), 26 deletions(-) 11 12 diff --git a/dwm.c b/dwm.c 13 index c34815d..a1a6ba0 100644 14 --- a/dwm.c 15 +++ b/dwm.c 16 @@ -220,7 +220,6 @@ static void quit(const Arg *arg); 17 static Monitor *recttomon(int x, int y, int w, int h); 18 static void removesystrayicon(Client *i); 19 static void resize(Client *c, int x, int y, int w, int h, int interact); 20 -static void resizebarwin(Monitor *m); 21 static void resizeclient(Client *c, int x, int y, int w, int h); 22 static void resizemouse(const Arg *arg); 23 static void resizerequest(XEvent *e); 24 @@ -646,7 +645,6 @@ clientmessage(XEvent *e) 25 sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION); 26 sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION); 27 XSync(dpy, False); 28 - resizebarwin(selmon); 29 updatesystray(); 30 setclientstate(c, NormalState); 31 } 32 @@ -704,7 +702,6 @@ configurenotify(XEvent *e) 33 for (c = m->clients; c; c = c->next) 34 if (c->isfullscreen) 35 resizeclient(c, m->mx, m->my, m->mw, m->mh); 36 - resizebarwin(m); 37 } 38 focus(NULL); 39 arrange(NULL); 40 @@ -806,7 +803,6 @@ destroynotify(XEvent *e) 41 unmanage(c, 1); 42 else if ((c = wintosystrayicon(ev->window))) { 43 removesystrayicon(c); 44 - resizebarwin(selmon); 45 updatesystray(); 46 } 47 } 48 @@ -852,23 +848,19 @@ dirtomon(int dir) 49 void 50 drawbar(Monitor *m) 51 { 52 - int x, w, sw = 0, stw = 0; 53 + int x, w, tw = 0; 54 int boxs = drw->fonts->h / 9; 55 int boxw = drw->fonts->h / 6 + 2; 56 unsigned int i, occ = 0, urg = 0; 57 Client *c; 58 59 - if(showsystray && m == systraytomon(m)) 60 - stw = getsystraywidth(); 61 - 62 /* draw status first so it can be overdrawn by tags later */ 63 if (m == selmon) { /* status is only drawn on selected monitor */ 64 drw_setscheme(drw, scheme[SchemeNorm]); 65 - sw = TEXTW(stext) - lrpad / 2 + 2; /* 2px right padding */ 66 - drw_text(drw, m->ww - sw - stw, 0, sw, bh, lrpad / 2 - 2, stext, 0); 67 + tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ 68 + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); 69 } 70 71 - resizebarwin(m); 72 for (c = m->clients; c; c = c->next) { 73 occ |= c->tags; 74 if (c->isurgent) 75 @@ -889,7 +881,7 @@ drawbar(Monitor *m) 76 drw_setscheme(drw, scheme[SchemeNorm]); 77 x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); 78 79 - if ((w = m->ww - sw - stw - x) > bh) { 80 + if ((w = m->ww - tw - x) > bh) { 81 if (m->sel) { 82 drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); 83 drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); 84 @@ -900,7 +892,7 @@ drawbar(Monitor *m) 85 drw_rect(drw, x, 0, w, bh, 1, 1); 86 } 87 } 88 - drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh); 89 + drw_map(drw, m->barwin, 0, 0, m->ww , bh); 90 } 91 92 void 93 @@ -1296,7 +1288,6 @@ maprequest(XEvent *e) 94 Client *i; 95 if ((i = wintosystrayicon(ev->window))) { 96 sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION); 97 - resizebarwin(selmon); 98 updatesystray(); 99 } 100 101 @@ -1428,7 +1419,6 @@ propertynotify(XEvent *e) 102 } 103 else 104 updatesystrayiconstate(c, ev); 105 - resizebarwin(selmon); 106 updatesystray(); 107 } 108 if ((ev->window == root) && (ev->atom == XA_WM_NAME)) 109 @@ -1512,14 +1502,6 @@ resize(Client *c, int x, int y, int w, int h, int interact) 110 resizeclient(c, x, y, w, h); 111 } 112 113 -void 114 -resizebarwin(Monitor *m) { 115 - unsigned int w = m->ww; 116 - if (showsystray && m == systraytomon(m)) 117 - w -= getsystraywidth(); 118 - XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh); 119 -} 120 - 121 void 122 resizeclient(Client *c, int x, int y, int w, int h) 123 { 124 @@ -1598,7 +1580,6 @@ resizerequest(XEvent *e) 125 126 if ((i = wintosystrayicon(ev->window))) { 127 updatesystrayicongeom(i, ev->width, ev->height); 128 - resizebarwin(selmon); 129 updatesystray(); 130 } 131 } 132 @@ -1997,7 +1978,6 @@ togglebar(const Arg *arg) 133 { 134 selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; 135 updatebarpos(selmon); 136 - resizebarwin(selmon); 137 if (showsystray) { 138 XWindowChanges wc; 139 if (!selmon->showbar) 140 @@ -2414,7 +2394,9 @@ updatesystray(void) 141 XWindowChanges wc; 142 Client *i; 143 Monitor *m = systraytomon(NULL); 144 - unsigned int x = m->mx + m->mw; 145 + unsigned int sw = TEXTW(stext) - lrpad + systrayspacing; 146 + unsigned int x = m->mx + m->mw - sw; 147 + 148 unsigned int w = 1; 149 150 if (!showsystray) 151 -- 152 2.30.1 153