t* dwm + patches URI git clone git://git.codevoid.de/dwm-sdk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 36c40f76fe330f42ae76847ab4420fa3a86014f7 DIR parent 0bca97ea298e173a01dfebd0209e1a6dd7b0bef7 URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Sat, 5 Oct 2019 11:27:10 +0200 Add floating window color Diffstat: M config.def.h | 9 +++++---- M config.h | 212 +++++++++++++++---------------- M config.mk | 6 +++--- M drw.h | 2 +- M dwm.c | 29 ++++++++++++++++++++++++++--- M maximize.c | 10 ++++++++++ 6 files changed, 149 insertions(+), 119 deletions(-) --- DIR diff --git a/config.def.h b/config.def.h t@@ -12,10 +12,11 @@ static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_cyan[] = "#005577"; -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +static const char col_blue[] = "#00FF00"; +static const char *colors[][4] = { + /* fg bg border float */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan, col_blue }, }; /* tagging */ DIR diff --git a/config.h b/config.h t@@ -10,55 +10,59 @@ static const char selbgcolor[] = "#181818"; // top bar selection bg static const char selfgcolor[] = "#eeeeee"; // top bar selection fg static const char normbordercolor[] = "#242424"; // window border bg static const char selbordercolor[] = "#990000"; // window border fg -static const unsigned int borderpx = 1; // border pixel of windows -static const unsigned int gappx = 10; // gap pixel between windows -static const unsigned int snap = 8; // snap pixel -static const unsigned int systraypinning = 1; // 0: systray follows mouse, >0: pin systray to monitor X +static const char normfloatbordercolor[] = "#00FF00"; // float window border bg +static const char selfloatbordercolor[] = "#00FF00"; // float window border fg +static const unsigned int borderpx = 1; // window border size px +static const unsigned int gappx = 10; // window gap size px +static const unsigned int snap = 8; // snap distance px +static const unsigned int systraypinning = 1; // 0: tray follows mouse + // >0: pin tray to mon X static const unsigned int systrayspacing = 2; // systray spacing -static const int systraypinningfailfirst = 1; // 1 first monitor, 0 last monitor -static const int showsystray = 1; // 0 means no systray -static const int showbar = 1; // False means no bar -static const int topbar = 1; // False means bottom bar -static const int extrabar = 0; // False means no extra bar - -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, - [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, +static const int systraypinningfailfirst = 1; // 1 first screen, 0 last +static const int showsystray = 1; // 0 = no systray +static const int showbar = 1; // 0 = no bar +static const int topbar = 1; // 0 = bottom bar +static const int extrabar = 0; // 0 = no extra bar + +static const char *colors[][4] = { + [SchemeNorm] = { + normfgcolor, normbgcolor, normbordercolor, normfloatbordercolor + }, + [SchemeSel] = { + /* fg bg border floatborder */ + selfgcolor, selbgcolor, selbordercolor, selfloatbordercolor + }, }; /* dmenu options */ -#define DMENUOPTS "-fn", FONT , "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor +#define DMENUOPTS "-fn", FONT, "-nb", normbgcolor, "-nf", normfgcolor, \ + "-sb", selbgcolor, "-sf", selfgcolor /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +/* rules */ static const Rule rules[] = { - - // WM_CLASS(STRING) = "Pidgin", "Pidgin" - // WM_ICON_NAME(STRING) = "Buddy List" - // _NET_WM_ICON_NAME(UTF8_STRING) = "Buddy List" - - /* class instance title tags mask isfloating monitor neverfocus */ - { "TelegramDesktop", NULL, NULL, 0, True, -1, 0}, - { "mpv", NULL, NULL, 0, True, -1, 0}, - { "st-osd", NULL, NULL, 0, True, -1, 0}, - { "Gimp", NULL, NULL, 0, True, -1, 0}, - { "Pqiv", NULL, NULL, 0, True, -1, 1}, - { "Pidgin", NULL, NULL, 0, True, -1, 0}, - { "Seafile Client", NULL, NULL, 0, True, -1, 0}, - { "QSyncthingTray", NULL, NULL, 0, True, -1, 0}, + /* class instance title tags mask isfloating mon neverfocus */ + { "TelegramDesktop", NULL, NULL, 0, True, -1, 0}, + { "mpv", NULL, NULL, 0, True, -1, 0}, + { "st-osd", NULL, NULL, 0, True, -1, 0}, + { "Gimp", NULL, NULL, 0, True, -1, 0}, + { "Pqiv", NULL, NULL, 0, True, -1, 1}, + { "Pidgin", NULL, NULL, 0, True, -1, 0}, + { "Seafile Client", NULL, NULL, 0, True, -1, 0}, + { "QSyncthingTray", NULL, NULL, 0, True, -1, 0}, }; /* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const int nmaster = 1; /* number of clients in master area */ -static const int resizehints = 0; /* True means respect size hints in tiled resizals */ +static const float mfact = 0.55; // factor of master area size [0.05..0.95] +static const int nmaster = 1; // number of clients in master area +static const int resizehints = 0; // 1 = respect size hints in tiles static const Layout layouts[] = { /* symbol arrange function */ - { "[T]", tile }, /* first entry is default */ - { "[F]", NULL }, /* no layout function means floating behavior */ + { "[T]", tile }, // first entry is default + { "[F]", NULL }, // no layout function means floating behavior }; /* key definitions */ t@@ -69,14 +73,13 @@ static const Layout layouts[] = { { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } -static const char scratchpadname[] = "scratchpad"; /* commands */ static char dmenumon[2] = "0"; +static const char scratchpadname[] = "scratchpad"; static const char *dmenucmd[] = { "dmenu_run", DMENUOPTS, NULL }; +/* custom commands */ #ifdef __linux__ // @ WORK static const char *scratchpadcmd[] = { "st", "-f", "FiraCode-9", "-t", scratchpadname, "-g", "120x24", "-e", "mksh", NULL }; t@@ -86,8 +89,8 @@ static const char *notescmd[] = { "st", "-e", "vim", "/N/notes.txt", NULL } #else // @ HOME static const char *termcmd[] = { "st", NULL }; -static const char *smalltermcmd[] = { "st","-f", "FiraCode-9", NULL }; -static const char *scratchpadcmd[] = { "st", "-f", "FiraCode-9", "-t", scratchpadname, "-g", "160x28", NULL }; +static const char *smalltermcmd[] = { "st","-f", "peep-10", NULL }; +static const char *scratchpadcmd[] = { "st", "-f", "peep-10", "-t", scratchpadname, "-g", "160x28", NULL }; static const char *notescmd[] = { "st", "-e", "vim", "~/work/notes.txt", NULL }; #endif static const char *browsercmd[] = { ".dwm/browser", DMENUOPTS, NULL }; t@@ -101,77 +104,70 @@ static const char *unMute[] = { "mixerctl", "outputs.spkr_mute=off", NULL #include "maximize.c" static Key keys[] = { - /* modifier key function argument */ - - { 0, 0x1008ff13,spawn, {.v = updateStatus } }, - { 0, 0x1008ff11,spawn, {.v = updateStatus } }, - { 0, 0x1008ff12,spawn, {.v = unMute } }, - - { MODKEY, XK_d, spawn, {.v = dmenucmd } }, - { MODKEY, XK_Return, spawn, {.v = termcmd } }, - { MODKEY|ShiftMask, XK_Return, spawn, {.v = smalltermcmd } }, - - { MODKEY|ShiftMask, XK_f, spawn, {.v = browsercmd } }, - { MODKEY|ShiftMask, XK_p, spawn, {.v = passmenucmd } }, - { MODKEY, XK_p, spawn, {.v = preview } }, - { MODKEY, XK_y, spawn, {.v = youtube } }, - { MODKEY|ShiftMask, XK_Print, spawn, {.v = sshot } }, - { MODKEY|ShiftMask, XK_o, spawn, {.v = notescmd } }, - - { MODKEY, XK_minus, togglescratch, {.v = scratchpadcmd } }, - - { MODKEY, XK_b, togglebar, {0} }, - //{ MODKEY, XK_b, toggleextrabar, {0} }, - - { MODKEY, XK_Down, focusstack, {.i = +1 } }, - { MODKEY, XK_Up, focusstack, {.i = -1 } }, - { MODKEY|ShiftMask, XK_Left, incnmaster, {.i = +1 } }, - { MODKEY|ShiftMask, XK_Right, incnmaster, {.i = -1 } }, - - { MODKEY, XK_m, zoom, {0} }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_q, killclient, {0} }, - //{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - //{ MODKEY, XK_space, setlayout, {.v = &layouts[1]} }, - //{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_f, togglemaximize, {0} }, - { MODKEY, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - { MODKEY, XK_Left, viewtoleft, {0} }, - { MODKEY, XK_Right, viewtoright, {0} }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_End, quit, {0} }, + /* modifier key function argument */ + { 0, 0x1008ff13, spawn, {.v = updateStatus } }, + { 0, 0x1008ff11, spawn, {.v = updateStatus } }, + { 0, 0x1008ff12, spawn, {.v = unMute } }, + { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = smalltermcmd } }, + { MODKEY|ShiftMask, XK_f, spawn, {.v = browsercmd } }, + { MODKEY|ShiftMask, XK_p, spawn, {.v = passmenucmd } }, + { MODKEY, XK_p, spawn, {.v = preview } }, + { MODKEY, XK_y, spawn, {.v = youtube } }, + { MODKEY|ShiftMask, XK_Print, spawn, {.v = sshot } }, + { MODKEY|ShiftMask, XK_o, spawn, {.v = notescmd } }, + { MODKEY, XK_minus, togglescratch, {.v = scratchpadcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + //{ MODKEY, XK_b, toggleextrabar, {0} }, + { MODKEY, XK_Down, focusstack, {.i = +1 } }, + { MODKEY, XK_Up, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_Left, incnmaster, {.i = +1 } }, + { MODKEY|ShiftMask, XK_Right, incnmaster, {.i = -1 } }, + { MODKEY, XK_m, zoom, {0} }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_q, killclient, {0} }, + //{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + //{ MODKEY, XK_m, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_f, togglemaximize, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + //{ MODKEY|ShiftMask, XK_Left, viewtoleft, {0} }, + //{ MODKEY|ShiftMask, XK_Right, viewtoright, {0} }, + { MODKEY|ShiftMask, XK_End, quit, {0} }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + }; -/* button definitions */ -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +/* button definitions; click can be: + * ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin */ static Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; DIR diff --git a/config.mk b/config.mk t@@ -11,14 +11,14 @@ X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib # Xinerama, comment if you don't want it -XINERAMALIBS = -lXinerama -XINERAMAFLAGS = -DXINERAMA +#XINERAMALIBS = -lXinerama +#XINERAMAFLAGS = -DXINERAMA # freetype FREETYPELIBS = -lfontconfig -lXft FREETYPEINC = /usr/include/freetype2 # OpenBSD (uncomment) -#FREETYPEINC = ${X11INC}/freetype2 +FREETYPEINC = ${X11INC}/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} DIR diff --git a/drw.h b/drw.h t@@ -12,7 +12,7 @@ typedef struct Fnt { struct Fnt *next; } Fnt; -enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */ +enum { ColFg, ColBg, ColBorder, ColFloat }; /* Clr scheme index */ typedef XftColor Clr; typedef struct { DIR diff --git a/dwm.c b/dwm.c t@@ -944,10 +944,13 @@ focus(Client *c) detachstack(c); attachstack(c); grabbuttons(c, 1); - if(c->ismax) + if(c->ismax) { XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBg].pixel); - else + } else if(c->isfloating) { + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColFloat].pixel); + } else { XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + } setfocus(c); } else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); t@@ -1229,7 +1232,13 @@ manage(Window w, XWindowAttributes *wa) wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); + if(c->ismax) { + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBg].pixel); + } else if(c->isfloating) { + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColFloat].pixel); + } else { + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + } configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); updatesizehints(c); t@@ -1240,6 +1249,13 @@ manage(Window w, XWindowAttributes *wa) c->isfloating = c->oldstate = trans != None || c->isfixed; if (c->isfloating) XRaiseWindow(dpy, c->win); + if(c->ismax) { + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBg].pixel); + } else if(c->isfloating) { + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColFloat].pixel); + } else { + XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + } attach(c); attachstack(c); XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, t@@ -1988,6 +2004,13 @@ togglefloating(const Arg *arg) if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; + if(selmon->sel->ismax) { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeNorm][ColBg].pixel); + } else if(selmon->sel->isfloating) { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColFloat].pixel); + } else { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColBorder].pixel); + } if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h, 0); DIR diff --git a/maximize.c b/maximize.c t@@ -47,6 +47,11 @@ restore() { togglefloating(NULL); selmon->sel->ismax = False; } + if(selmon->sel->isfloating) { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColFloat].pixel); + } else { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColBorder].pixel); + } drawbar(selmon); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } t@@ -54,4 +59,9 @@ restore() { void togglemaximize(const Arg *arg) { maximize(selmon->wx, selmon->wy, selmon->ww - 2 * borderpx, selmon->wh - 2 * borderpx); + if(selmon->sel->isfloating) { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColFloat].pixel); + } else { + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel][ColBorder].pixel); + } }