From: Matthias Kruk Date: Sat, 13 Mar 2021 04:24:59 +0000 (+0900) Subject: Remove code to toggle systray and bar visibility X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=98dddfa312d8b3624f86fdaf26227096a057ae83;p=dwm Remove code to toggle systray and bar visibility There are functions to hide/unhide the bar and the systray, however they are not bound to any keys and I do not need them. This commit removes these functions and all related variables/fields. --- diff --git a/config.def.h b/config.def.h index 840f77d..3be605b 100755 --- a/config.def.h +++ b/config.def.h @@ -11,8 +11,6 @@ static const char selfgcolor[] = "#0048bf"; /* default: eeeeee */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const unsigned int systrayspacing = 1; /* systray spacing */ -static const Bool showsystray = True; /* False means no systray */ -static const Bool showbar = True; /* False means no bar */ static const Bool topbar = True; /* False means bottom bar */ static const Bool statusmarkup = True; /* True means use pango markup in status message */ diff --git a/dwm.c b/dwm.c index 63ffdbc..9632c0c 100755 --- a/dwm.c +++ b/dwm.c @@ -223,7 +223,6 @@ struct monitor { unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; - Bool showbar; Bool topbar; struct client *clients; struct client *sel; @@ -703,13 +702,14 @@ void cleanup(void) XFreeCursor(dpy, cursor[CurNormal]); XFreeCursor(dpy, cursor[CurResize]); XFreeCursor(dpy, cursor[CurMove]); - while(mons) + while(mons) { cleanupmon(mons); - if(showsystray) { - XUnmapWindow(dpy, systray->win); - XDestroyWindow(dpy, systray->win); - free(systray); } + + XUnmapWindow(dpy, systray->win); + XDestroyWindow(dpy, systray->win); + free(systray); + XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); } @@ -748,7 +748,7 @@ void clientmessage(XEvent *e) XClientMessageEvent *cme = &e->xclient; struct client *c = wintoclient(cme->window); - if(showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) { + if(cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) { /* add systray icons */ if(cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) { if(!(c = (struct client*)calloc(1, sizeof(*c)))) @@ -942,7 +942,6 @@ struct monitor *createmon(void) m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; m->nmaster = nmaster; - m->showbar = showbar; m->topbar = topbar; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; @@ -1054,11 +1053,7 @@ void drawbar(struct monitor *m) x = dc.geom.x; dc.geom.w = TEXTW(stext); - dc.geom.x = m->win_geom.w - dc.geom.w; - - if(showsystray && m == selmon) { - dc.geom.x -= getsystraywidth(); - } + dc.geom.x = m->win_geom.w - dc.geom.w - getsystraywidth(); if(dc.geom.x < x) { dc.geom.x = x; @@ -1381,10 +1376,8 @@ unsigned int getsystraywidth(void) width = 0; - if(showsystray) { - for(client = systray->icons; client; client = client->next) { - width += client->geom.w + systrayspacing; - } + for(client = systray->icons; client; client = client->next) { + width += client->geom.w + systrayspacing; } return(width ? width + systrayspacing : 1); @@ -1921,7 +1914,7 @@ void removesystrayicon(struct client *client) { struct client **cur; - if(!showsystray || !client) { + if(!client) { return; } @@ -1945,11 +1938,9 @@ void resize(struct client *c, int x, int y, int w, int h, Bool interact) void resizebarwin(struct monitor *m) { - unsigned int w = m->win_geom.w; + unsigned int w; - if(showsystray && m == selmon) { - w -= getsystraywidth(); - } + w = m->win_geom.w - getsystraywidth(); XMoveResizeWindow(dpy, m->barwin, m->win_geom.x, m->by, w, bh); @@ -2594,35 +2585,6 @@ static void bookstack(struct monitor *m) return; } -#ifndef M10K -void togglebar(const union arg *arg) -{ - selmon->showbar = !selmon->showbar; - updatebarpos(selmon); - resizebarwin(selmon); - - if(showsystray) { - XWindowChanges wc; - - if(!selmon->showbar) { - wc.y = -bh; - } else if(selmon->showbar) { - wc.y = 0; - - if(!selmon->topbar) { - wc.y = selmon->geom.h - bh; - } - } - - XConfigureWindow(dpy, systray->win, CWY, &wc); - } - - arrange(selmon); - - return; -} -#endif /* ! M10K */ - void togglefloating(const union arg *arg) { if(!selmon->sel) { @@ -2749,11 +2711,7 @@ void updatebars(void) }; for(m = mons; m; m = m->next) { - w = m->win_geom.w; - - if(showsystray && m == selmon) { - w -= getsystraywidth(); - } + w = m->win_geom.w - getsystraywidth(); m->barwin = XCreateWindow(dpy, root, m->win_geom.x, m->by, w, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), @@ -2770,14 +2728,9 @@ void updatebarpos(struct monitor *m) { m->win_geom.y = m->geom.y; m->win_geom.h = m->geom.h; - - if(m->showbar) { - m->win_geom.h -= bh; - m->by = m->topbar ? m->win_geom.y : m->win_geom.y + m->win_geom.h; - m->win_geom.y = m->topbar ? m->win_geom.y + bh : m->win_geom.y; - } else { - m->by = -bh; - } + m->win_geom.h -= bh; + m->by = m->topbar ? m->win_geom.y : m->win_geom.y + m->win_geom.h; + m->win_geom.y = m->topbar ? m->win_geom.y + bh : m->win_geom.y; return; } @@ -3021,7 +2974,7 @@ void updatesystrayiconstate(struct client *i, XPropertyEvent *ev) long flags; int code = 0; - if(!showsystray || !i || ev->atom != xatom[XembedInfo] || + if(!i || ev->atom != xatom[XembedInfo] || !(flags = getatomprop(i, xatom[XembedInfo]))) { return; } @@ -3056,10 +3009,6 @@ void updatesystray(void) x = selmon->geom.x + selmon->geom.w; w = 1; - if(!showsystray) { - return; - } - if(!systray) { /* init systray */ if(!(systray = (struct systray*)calloc(1, sizeof(*systray)))) { @@ -3212,15 +3161,17 @@ struct monitor *wintomon(Window w) struct client *wintosystrayicon(Window w) { - struct client *i = NULL; + struct client *client; - if(!showsystray || !w) { - return(i); + if(w) { + for(client = systray->icons; client; client = client->next) { + if(client->win == w) { + return(client); + } + } } - for(i = systray->icons; i && i->win != w; i = i->next); - - return(i); + return(NULL); } /* There's no way to check accesses to destroyed windows, thus those cases are @@ -3287,7 +3238,7 @@ int main(int argc, char *argv[]) } if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) { - fputs("warning: no locale support\n", stderr); + fprintf(stderr, "warning: no locale support\n"); } dpy = XOpenDisplay(NULL); @@ -3306,5 +3257,5 @@ int main(int argc, char *argv[]) cleanup(); XCloseDisplay(dpy); - return EXIT_SUCCESS; + return(EXIT_SUCCESS); }