From: Matthias Kruk Date: Thu, 29 Apr 2021 21:23:42 +0000 (+0900) Subject: Make Pango markup and top-bar non-configurable X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=21ad1a05502911eaccac74e5bd9710c138e04967;p=dwm Make Pango markup and top-bar non-configurable It's possible to deactivate Pango markup and/or move the bar from the top to the bottom. Both are features that aren't necessary, so this commit removes them. --- diff --git a/config.def.h b/config.def.h index b8b628a..96a3cc5 100755 --- a/config.def.h +++ b/config.def.h @@ -23,15 +23,14 @@ static struct color_set theme[PalLast] = { } }; -static const char dmenu_normal_bg[] = "#ffffff"; -static const char dmenu_normal_fg[] = "#000000"; -static const char dmenu_sel_bg[] = "#bb2323"; -static const char dmenu_sel_fg[] = "#ffffff"; - -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ -static const Bool topbar = True; /* False means bottom bar */ -static const Bool statusmarkup = True; /* True means use pango markup in status message */ +static const char dmenu_normal_bg[] = "#ffffff"; +static const char dmenu_normal_fg[] = "#000000"; +static const char dmenu_sel_bg[] = "#bb2323"; +static const char dmenu_sel_fg[] = "#ffffff"; + +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int bar_padding = 4; /* vertical padding of the bar */ /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }; diff --git a/dwm.c b/dwm.c index bdcebfb..0203875 100755 --- a/dwm.c +++ b/dwm.c @@ -232,7 +232,6 @@ struct monitor { unsigned int tagset[2]; struct workspace *workspace; struct workspace *previous_workspace; - Bool topbar; struct monitor *next; Window barwin; const struct layout *lt[2]; @@ -309,7 +308,6 @@ static void configurenotify(XEvent *e); static void configurerequest(XEvent *e); static struct monitor *createmon(void); static void destroynotify(XEvent *e); -static void detach(struct client *c); static void die(const char *errstr, ...); static struct monitor *dirtomon(int dir); static void drawbar(struct monitor *m); @@ -391,7 +389,6 @@ static void quit(const union arg *arg); static void resizemouse(const union arg *arg); static void setlayout(const union arg *arg); - static const char broken[] = "broken"; static char stext[512]; static int screen; @@ -997,7 +994,6 @@ struct monitor *createmon(void) m->tagset[0] = 1; m->tagset[1] = 1; - m->topbar = topbar; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; @@ -1062,12 +1058,6 @@ static struct workspace* workspace_get_current(void) return(selmon->workspace); } -static void detach(struct client *client) -{ - workspace_remove_client(client->workspace, client); - return; -} - void die(const char *errstr, ...) { va_list ap; @@ -1085,8 +1075,7 @@ struct monitor *dirtomon(int dir) struct monitor *m = NULL; if(dir > 0) { - if(!(m = selmon->next)) - m = mons; + m = selmon->next ? selmon->next : mons; } else if(selmon == mons) { for(m = mons; m->next; m = m->next); } else { @@ -1241,20 +1230,10 @@ void drawtext(const char *text, int pal, Bool invert) for(i = len; i && i > len - 3; buf[--i] = '.'); } - /* FIXME: Remove statusmarkup */ - if(text == stext && statusmarkup) { /* FIXME: stext? */ - pango_layout_set_markup(dc.font.layout, buf, len); - } else { - pango_layout_set_text(dc.font.layout, buf, len); - } - + pango_layout_set_markup(dc.font.layout, buf, len); pango_xft_render_layout(dc.draw, &dc.palette[pal].xcolor[invert ? ColBG : ColFG], dc.font.layout, x * PANGO_SCALE, y * PANGO_SCALE); - - if(text == stext && statusmarkup) { - /* clear markup attributes */ - pango_layout_set_attributes(dc.font.layout, NULL); - } + pango_layout_set_attributes(dc.font.layout, NULL); return; } @@ -1684,7 +1663,7 @@ void manage(Window w, XWindowAttributes *wa) client_update_title(c); if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { - c->workspace->viewer = t->workspace->viewer; + c->workspace = t->workspace; } else { client_apply_rules(c); } @@ -2522,7 +2501,7 @@ static void setup(void) initfont(font); screen_width = DisplayWidth(dpy, screen); screen_height = DisplayHeight(dpy, screen); - bar_height = dc.geom.h = dc.font.height + 2; + bar_height = dc.geom.h = dc.font.height + 2 * bar_padding; updategeom(); /* init atoms */ @@ -2704,18 +2683,9 @@ static int textnw(const char *text, unsigned int len) { PangoRectangle r; - if(text == stext && statusmarkup) { - pango_layout_set_markup(dc.font.layout, text, len); - } else { - pango_layout_set_text(dc.font.layout, text, len); - } - + pango_layout_set_markup(dc.font.layout, text, len); pango_layout_get_extents(dc.font.layout, 0, &r); - - if(text == stext && statusmarkup) { - /* clear markup attributes */ - pango_layout_set_attributes(dc.font.layout, NULL); - } + pango_layout_set_attributes(dc.font.layout, NULL); return(r.width / PANGO_SCALE); } @@ -2869,7 +2839,7 @@ void unmanage(struct client *client, Bool destroyed) monitor = client->workspace->viewer; /* The server grab construct avoids race conditions. */ - detach(client); + workspace_remove_client(client->workspace, client); if(!destroyed) { wc.border_width = client->border.oldw; @@ -2938,8 +2908,8 @@ void updatebarpos(struct monitor *monitor) monitor->win_geom.y = monitor->geom.y; monitor->win_geom.h = monitor->geom.h; monitor->win_geom.h -= bar_height; - monitor->by = monitor->topbar ? monitor->win_geom.y : monitor->win_geom.y + monitor->win_geom.h; - monitor->win_geom.y = monitor->topbar ? monitor->win_geom.y + bar_height : monitor->win_geom.y; + monitor->by = monitor->win_geom.y; + monitor->win_geom.y = monitor->win_geom.y + bar_height; return; }