]> git.corax.cc Git - dwm/commitdiff
Make Pango markup and top-bar non-configurable
authorMatthias Kruk <m@m10k.eu>
Thu, 29 Apr 2021 21:23:42 +0000 (06:23 +0900)
committerMatthias Kruk <m@m10k.eu>
Thu, 29 Apr 2021 21:23:42 +0000 (06:23 +0900)
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.

config.def.h
dwm.c

index b8b628a6e5a97beff5c951b9a82e64bfb94184e5..96a3cc502f30eae939f8b7ec31bf9fdcb136f294 100755 (executable)
@@ -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 bdcebfb2d59f67315af26711ead4784d56da9039..0203875258f28d3d6b4b78056838d0d824a0c97f 100755 (executable)
--- 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;
 }