Compare commits
No commits in common. "master" and "6.3" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +0,0 @@
|
||||||
/compile_commands.json
|
|
||||||
/build
|
|
||||||
/.cache
|
|
1
LICENSE
1
LICENSE
|
@ -17,7 +17,6 @@ MIT/X Consortium License
|
||||||
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
||||||
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
||||||
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
||||||
© 2020-2022 Chris Down <chris@chrisdown.name>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
|
43
Makefile
43
Makefile
|
@ -4,35 +4,48 @@
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = drw.c dwm.c util.c
|
SRC = drw.c dwm.c util.c
|
||||||
OBJ = $(patsubst %.c,build/obj/%.c.o,$(SRC))
|
OBJ = ${SRC:.c=.o}
|
||||||
|
|
||||||
all: build/dwm compile_commands.json
|
all: options dwm
|
||||||
|
|
||||||
build/obj/%.c.o: %.c
|
options:
|
||||||
mkdir -p $(dir $@)
|
@echo dwm build options:
|
||||||
${CC} -c ${CFLAGS} -o $@ $<
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
|
@echo "CC = ${CC}"
|
||||||
|
|
||||||
build/dwm: ${OBJ}
|
.c.o:
|
||||||
|
${CC} -c ${CFLAGS} $<
|
||||||
|
|
||||||
|
${OBJ}: config.h config.mk
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
cp config.def.h $@
|
||||||
|
|
||||||
|
dwm: ${OBJ}
|
||||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
||||||
|
|
||||||
|
dist: clean
|
||||||
|
mkdir -p dwm-${VERSION}
|
||||||
|
cp -R LICENSE Makefile README config.def.h config.mk\
|
||||||
|
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
|
||||||
|
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
||||||
|
gzip dwm-${VERSION}.tar
|
||||||
|
rm -rf dwm-${VERSION}
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
cp -f build/dwm ${DESTDIR}${PREFIX}/bin
|
cp -f dwm ${DESTDIR}${PREFIX}/bin
|
||||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
cp dwm.desktop /usr/share/xsessions/dwm.desktop
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f ${DESTDIR}${PREFIX}/bin/dwm \
|
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
||||||
${DESTDIR}${MANPREFIX}/man1/dwm.1 \
|
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
/usr/share/xsessions/dwm.desktop
|
|
||||||
|
|
||||||
compile_commands.json:
|
.PHONY: all options clean dist install uninstall
|
||||||
compiledb -n make
|
|
||||||
|
|
||||||
.PHONY: all clean dist install uninstall
|
|
||||||
|
|
116
config.def.h
Normal file
116
config.def.h
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
/* appearance */
|
||||||
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
|
static const char col_gray1[] = "#222222";
|
||||||
|
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 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* tagging */
|
||||||
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
|
static const Rule rules[] = {
|
||||||
|
/* xprop(1):
|
||||||
|
* WM_CLASS(STRING) = instance, class
|
||||||
|
* WM_NAME(STRING) = title
|
||||||
|
*/
|
||||||
|
/* class instance title tags mask isfloating monitor */
|
||||||
|
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||||
|
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 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 = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
|
||||||
|
static const Layout layouts[] = {
|
||||||
|
/* symbol arrange function */
|
||||||
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
|
{ "[M]", monocle },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* key definitions */
|
||||||
|
#define MODKEY Mod1Mask
|
||||||
|
#define TAGKEYS(KEY,TAG) \
|
||||||
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
|
{ 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 } }
|
||||||
|
|
||||||
|
/* commands */
|
||||||
|
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||||
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
|
static Key keys[] = {
|
||||||
|
/* modifier key function argument */
|
||||||
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XK_space, setlayout, {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 } },
|
||||||
|
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_q, quit, {0} },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* button definitions */
|
||||||
|
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 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} },
|
||||||
|
};
|
||||||
|
|
162
config.h
162
config.h
|
@ -1,162 +0,0 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
#ifndef _H_DWM_CONF
|
|
||||||
#define _H_DWM_CONF
|
|
||||||
|
|
||||||
#include "dwm.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* appearance */
|
|
||||||
const unsigned int borderpx = 1; /* border pixel of windows */
|
|
||||||
const int startwithgaps[] = { 1 }; /* 1 means gaps are used by default, this can be customized for each tag */
|
|
||||||
const unsigned int gappx[] = { 10 }; /* default gap between windows in pixels, this can be customized for each tag */
|
|
||||||
const unsigned int snap = 32; /* snap pixel */
|
|
||||||
const int showbar = 1; /* 0 means no bar */
|
|
||||||
const int topbar = 0; /* 0 means bottom bar */
|
|
||||||
const char *fonts[] = { "monospace:size=10" };
|
|
||||||
const char dmenufont[] = "monospace:size=10";
|
|
||||||
|
|
||||||
const char* THEME_BW[][3] = {
|
|
||||||
[SchemeNorm] = {"#aaaaaa", "#181818", "#181818"},
|
|
||||||
[SchemeSel] = {"#aaaaaa", "#3f3f3f", "#3f3f3f"},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const char* THEME_DEFAULT[][3] = {
|
|
||||||
/* text inactive tag/status bar border */
|
|
||||||
[SchemeNorm] = { "#bbbbbb", "#222222", "#444444" },
|
|
||||||
/* text active tag/middle bar border*/
|
|
||||||
[SchemeSel] = { "#eeeeee", "#005577", "#005577" },
|
|
||||||
};
|
|
||||||
|
|
||||||
#define colors THEME_BW
|
|
||||||
|
|
||||||
/* tagging */
|
|
||||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
||||||
|
|
||||||
const Rule rules[] = {
|
|
||||||
/* xprop(1):
|
|
||||||
* WM_CLASS(STRING) = instance, class
|
|
||||||
* WM_NAME(STRING) = title
|
|
||||||
*/
|
|
||||||
/* class instance title tags mask isfloating monitor */
|
|
||||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
|
||||||
{ "Firefox", NULL, NULL, 1 << 2, 0, -1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* layout(s) */
|
|
||||||
const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
|
||||||
const int nmaster = 1; /* number of clients in master area */
|
|
||||||
const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
|
||||||
const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
|
||||||
|
|
||||||
const Layout layouts[] = {
|
|
||||||
/* symbol arrange function */
|
|
||||||
{ "[T]", tile }, /* first entry is default */
|
|
||||||
{ "[F]", NULL }, /* no layout function means floating behavior */
|
|
||||||
{ "[M]", monocle },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* key definitions */
|
|
||||||
#define MODKEY Mod4Mask
|
|
||||||
#define TAGKEYS(KEY,TAG) \
|
|
||||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
|
||||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
|
||||||
{ 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/bash", "-c", cmd, NULL } }
|
|
||||||
|
|
||||||
const char* upvol[] = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "+5%", NULL };
|
|
||||||
const char* downvol[] = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "-5%", NULL };
|
|
||||||
const char* mutevol[] = { "/usr/bin/pactl", "set-sink-mute", "@DEFAULT_SINK@", "toggle", NULL };
|
|
||||||
const char* light_up[] = { "/usr/bin/light", "-A", "5", NULL };
|
|
||||||
const char* light_down[] = { "/usr/bin/light", "-U", "5", NULL };
|
|
||||||
const char* rofi[] = { "rofi", "-modi", "drun", "-show", "drun", "-config", "~/.config/rofi/rofidmenu.rasi", NULL };
|
|
||||||
|
|
||||||
/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
|
|
||||||
const StatusCmd statuscmds[] = {
|
|
||||||
{ "notify-send Mouse$BUTTON", 1 },
|
|
||||||
};
|
|
||||||
const char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
|
|
||||||
|
|
||||||
const Key keys[] = {
|
|
||||||
/* modifier key function argument */
|
|
||||||
|
|
||||||
{ MODKEY, XK_w, spawn, { .v = (const char*[]){"firefox", NULL} } },
|
|
||||||
{ MODKEY, XK_n, spawn, { .v = (const char*[]){"thunar", NULL} } },
|
|
||||||
{ MODKEY, XK_Return, spawn, { .v = (const char*[]){"alacritty", NULL} } },
|
|
||||||
{ 0, XF86XK_AudioPlay, spawn, { .v = (const char*[]){"firefox", NULL} } },
|
|
||||||
{ 0, XK_Print, spawn, { .v = (const char*[]){"flameshot", "gui", NULL} } },
|
|
||||||
{ 0, XF86XK_AudioStop, spawn, { .v = (const char*[]){"playerctl", "play-pause", NULL} } },
|
|
||||||
{ 0, XF86XK_AudioNext, spawn, { .v = (const char*[]){"playerctl", "next", NULL} } },
|
|
||||||
{ 0, XF86XK_AudioPrev, spawn, { .v = (const char*[]){"playerctl", "previous", NULL} } },
|
|
||||||
{ MODKEY, XK_d, spawn, { .v = rofi } },
|
|
||||||
{ 0, XF86XK_AudioRaiseVolume, spawn, { .v = upvol } },
|
|
||||||
{ 0, XF86XK_AudioLowerVolume, spawn, { .v = downvol } },
|
|
||||||
{ 0, XF86XK_AudioMute, spawn, { .v = mutevol } },
|
|
||||||
{ 0, XF86XK_MonBrightnessUp, spawn, { .v = light_up } },
|
|
||||||
{ 0, XF86XK_MonBrightnessDown, spawn, { .v = light_down} },
|
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
|
||||||
{ MODKEY, XK_f, togglefullscr, {0} },
|
|
||||||
{ MODKEY, XK_Tab, view, {0} }, // Switch windows
|
|
||||||
{ MODKEY, XK_q, killclient, {0} }, // Kill prog
|
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
|
||||||
{ MODKEY, XK_s, setlayout, {.v = &layouts[2]} },
|
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_e, 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)
|
|
||||||
|
|
||||||
// { MODKEY, XK_minus, setgaps, {.i = -5 } },
|
|
||||||
// { MODKEY, XK_equal, setgaps, {.i = +5 } },
|
|
||||||
// { MODKEY|ShiftMask, XK_minus, setgaps, {.i = GAP_RESET } },
|
|
||||||
// { MODKEY|ShiftMask, XK_equal, setgaps, {.i = GAP_TOGGLE} },
|
|
||||||
|
|
||||||
|
|
||||||
// ????????????????????????????//
|
|
||||||
// { 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_b, togglebar, {0} }, // stupid
|
|
||||||
// { MODKEY, XK_Return, zoom, {0} },
|
|
||||||
// { MODKEY, XK_d, incnmaster, {.i = -1 } },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* button definitions */
|
|
||||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
|
||||||
const 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, Button1, spawn, {.v = statuscmd } },
|
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = statuscmd } },
|
|
||||||
{ ClkStatusText, 0, Button3, spawn, {.v = statuscmd } },
|
|
||||||
{ 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} },
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,5 +1,5 @@
|
||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 6.5
|
VERSION = 6.3
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
@ -19,14 +19,13 @@ FREETYPELIBS = -lfontconfig -lXft
|
||||||
FREETYPEINC = /usr/include/freetype2
|
FREETYPEINC = /usr/include/freetype2
|
||||||
# OpenBSD (uncomment)
|
# OpenBSD (uncomment)
|
||||||
#FREETYPEINC = ${X11INC}/freetype2
|
#FREETYPEINC = ${X11INC}/freetype2
|
||||||
#MANPREFIX = ${PREFIX}/man
|
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||||
LDFLAGS = ${LIBS}
|
LDFLAGS = ${LIBS}
|
||||||
|
|
106
drw.c
106
drw.c
|
@ -133,6 +133,19 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||||
die("no font specified.");
|
die("no font specified.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do not allow using color fonts. This is a workaround for a BadLength
|
||||||
|
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
||||||
|
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||||
|
* https://lists.suckless.org/dev/1701/30932.html
|
||||||
|
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
|
||||||
|
* and lots more all over the internet.
|
||||||
|
*/
|
||||||
|
FcBool iscol;
|
||||||
|
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
|
||||||
|
XftFontClose(drw->dpy, xfont);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
font = ecalloc(1, sizeof(Fnt));
|
font = ecalloc(1, sizeof(Fnt));
|
||||||
font->xfont = xfont;
|
font->xfont = xfont;
|
||||||
font->pattern = pattern;
|
font->pattern = pattern;
|
||||||
|
@ -238,10 +251,12 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
|
||||||
int
|
int
|
||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
{
|
{
|
||||||
int i, ty, ellipsis_x = 0;
|
char buf[1024];
|
||||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
int ty;
|
||||||
|
unsigned int ew;
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
Fnt *usedfont, *curfont, *nextfont;
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
|
size_t i, len;
|
||||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||||
long utf8codepoint = 0;
|
long utf8codepoint = 0;
|
||||||
const char *utf8str;
|
const char *utf8str;
|
||||||
|
@ -249,17 +264,13 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
FcPattern *fcpattern;
|
FcPattern *fcpattern;
|
||||||
FcPattern *match;
|
FcPattern *match;
|
||||||
XftResult result;
|
XftResult result;
|
||||||
int charexists = 0, overflow = 0;
|
int charexists = 0;
|
||||||
/* keep track of a couple codepoints for which we have no match. */
|
|
||||||
enum { nomatches_len = 64 };
|
|
||||||
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
|
||||||
static unsigned int ellipsis_width = 0;
|
|
||||||
|
|
||||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
if (!drw || (render && !drw->scheme) || !text || !drw->fonts)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!render) {
|
if (!render) {
|
||||||
w = invert ? invert : ~invert;
|
w = ~w;
|
||||||
} else {
|
} else {
|
||||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
@ -271,10 +282,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
}
|
}
|
||||||
|
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
if (!ellipsis_width && render)
|
|
||||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ew = ellipsis_len = utf8strlen = 0;
|
utf8strlen = 0;
|
||||||
utf8str = text;
|
utf8str = text;
|
||||||
nextfont = NULL;
|
nextfont = NULL;
|
||||||
while (*text) {
|
while (*text) {
|
||||||
|
@ -282,27 +291,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
if (charexists) {
|
if (charexists) {
|
||||||
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
if (curfont == usedfont) {
|
||||||
if (ew + ellipsis_width <= w) {
|
|
||||||
/* keep track where the ellipsis still fits */
|
|
||||||
ellipsis_x = x + ew;
|
|
||||||
ellipsis_w = w - ew;
|
|
||||||
ellipsis_len = utf8strlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ew + tmpw > w) {
|
|
||||||
overflow = 1;
|
|
||||||
/* called from drw_fontset_getwidth_clamp():
|
|
||||||
* it wants the width AFTER the overflow
|
|
||||||
*/
|
|
||||||
if (!render)
|
|
||||||
x += tmpw;
|
|
||||||
else
|
|
||||||
utf8strlen = ellipsis_len;
|
|
||||||
} else if (curfont == usedfont) {
|
|
||||||
utf8strlen += utf8charlen;
|
utf8strlen += utf8charlen;
|
||||||
text += utf8charlen;
|
text += utf8charlen;
|
||||||
ew += tmpw;
|
|
||||||
} else {
|
} else {
|
||||||
nextfont = curfont;
|
nextfont = curfont;
|
||||||
}
|
}
|
||||||
|
@ -310,25 +301,36 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow || !charexists || nextfont)
|
if (!charexists || nextfont)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (utf8strlen) {
|
if (utf8strlen) {
|
||||||
if (render) {
|
drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
|
||||||
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
/* shorten text if necessary */
|
||||||
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
|
||||||
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
|
||||||
}
|
|
||||||
x += ew;
|
|
||||||
w -= ew;
|
|
||||||
}
|
|
||||||
if (render && overflow)
|
|
||||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
|
||||||
|
|
||||||
if (!*text || overflow) {
|
if (len) {
|
||||||
|
memcpy(buf, utf8str, len);
|
||||||
|
buf[len] = '\0';
|
||||||
|
if (len < utf8strlen)
|
||||||
|
for (i = len; i && i > len - 3; buf[--i] = '.')
|
||||||
|
; /* NOP */
|
||||||
|
|
||||||
|
if (render) {
|
||||||
|
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||||
|
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||||
|
usedfont->xfont, x, ty, (XftChar8 *)buf, len);
|
||||||
|
}
|
||||||
|
x += ew;
|
||||||
|
w -= ew;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*text) {
|
||||||
break;
|
break;
|
||||||
} else if (nextfont) {
|
} else if (nextfont) {
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
|
@ -338,12 +340,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
* character must be drawn. */
|
* character must be drawn. */
|
||||||
charexists = 1;
|
charexists = 1;
|
||||||
|
|
||||||
for (i = 0; i < nomatches_len; ++i) {
|
|
||||||
/* avoid calling XftFontMatch if we know we won't find a match */
|
|
||||||
if (utf8codepoint == nomatches.codepoint[i])
|
|
||||||
goto no_match;
|
|
||||||
}
|
|
||||||
|
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
|
|
||||||
|
@ -355,6 +351,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||||
|
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
||||||
|
|
||||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||||
FcDefaultSubstitute(fcpattern);
|
FcDefaultSubstitute(fcpattern);
|
||||||
|
@ -371,8 +368,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
curfont->next = usedfont;
|
curfont->next = usedfont;
|
||||||
} else {
|
} else {
|
||||||
xfont_free(usedfont);
|
xfont_free(usedfont);
|
||||||
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
|
||||||
no_match:
|
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,15 +397,6 @@ drw_fontset_getwidth(Drw *drw, const char *text)
|
||||||
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
|
||||||
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
|
||||||
{
|
|
||||||
unsigned int tmp = 0;
|
|
||||||
if (drw && drw->fonts && text && n)
|
|
||||||
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
|
||||||
return MIN(n, tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||||
{
|
{
|
||||||
|
|
23
drw.h
23
drw.h
|
@ -1,25 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
#ifndef _H_DRW
|
|
||||||
#define _H_DRW
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <X11/cursorfont.h>
|
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#ifdef XINERAMA
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
|
||||||
#endif /* XINERAMA */
|
|
||||||
#include <X11/Xft/Xft.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
} Cur;
|
} Cur;
|
||||||
|
@ -55,7 +35,6 @@ void drw_free(Drw *drw);
|
||||||
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||||
void drw_fontset_free(Fnt* set);
|
void drw_fontset_free(Fnt* set);
|
||||||
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||||
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
|
||||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
/* Colorscheme abstraction */
|
/* Colorscheme abstraction */
|
||||||
|
@ -76,5 +55,3 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
|
||||||
|
|
||||||
/* Map functions */
|
/* Map functions */
|
||||||
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
3
dwm.1
3
dwm.1
|
@ -116,9 +116,6 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||||
.B Mod1\-Shift\-c
|
.B Mod1\-Shift\-c
|
||||||
Close focused window.
|
Close focused window.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\-Shift\-f
|
|
||||||
Toggle fullscreen for focused window.
|
|
||||||
.TP
|
|
||||||
.B Mod1\-Shift\-space
|
.B Mod1\-Shift\-space
|
||||||
Toggle focused window between tiled and floating state.
|
Toggle focused window between tiled and floating state.
|
||||||
.TP
|
.TP
|
||||||
|
|
666
dwm.c
666
dwm.c
|
@ -43,10 +43,238 @@
|
||||||
|
|
||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "dwm.h"
|
|
||||||
|
|
||||||
|
/* macros */
|
||||||
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||||
|
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||||
|
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||||
|
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||||
|
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||||
|
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||||
|
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||||
|
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
int i;
|
||||||
|
unsigned int ui;
|
||||||
|
float f;
|
||||||
|
const void *v;
|
||||||
|
} Arg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int click;
|
||||||
|
unsigned int mask;
|
||||||
|
unsigned int button;
|
||||||
|
void (*func)(const Arg *arg);
|
||||||
|
const Arg arg;
|
||||||
|
} Button;
|
||||||
|
|
||||||
|
typedef struct Monitor Monitor;
|
||||||
|
typedef struct Client Client;
|
||||||
|
struct Client {
|
||||||
|
char name[256];
|
||||||
|
float mina, maxa;
|
||||||
|
int x, y, w, h;
|
||||||
|
int oldx, oldy, oldw, oldh;
|
||||||
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
|
int bw, oldbw;
|
||||||
|
unsigned int tags;
|
||||||
|
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||||
|
Client *next;
|
||||||
|
Client *snext;
|
||||||
|
Monitor *mon;
|
||||||
|
Window win;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int mod;
|
||||||
|
KeySym keysym;
|
||||||
|
void (*func)(const Arg *);
|
||||||
|
const Arg arg;
|
||||||
|
} Key;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *symbol;
|
||||||
|
void (*arrange)(Monitor *);
|
||||||
|
} Layout;
|
||||||
|
|
||||||
|
struct Monitor {
|
||||||
|
char ltsymbol[16];
|
||||||
|
float mfact;
|
||||||
|
int nmaster;
|
||||||
|
int num;
|
||||||
|
int by; /* bar geometry */
|
||||||
|
int mx, my, mw, mh; /* screen size */
|
||||||
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
unsigned int seltags;
|
||||||
|
unsigned int sellt;
|
||||||
|
unsigned int tagset[2];
|
||||||
|
int showbar;
|
||||||
|
int topbar;
|
||||||
|
Client *clients;
|
||||||
|
Client *sel;
|
||||||
|
Client *stack;
|
||||||
|
Monitor *next;
|
||||||
|
Window barwin;
|
||||||
|
const Layout *lt[2];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *class;
|
||||||
|
const char *instance;
|
||||||
|
const char *title;
|
||||||
|
unsigned int tags;
|
||||||
|
int isfloating;
|
||||||
|
int monitor;
|
||||||
|
} Rule;
|
||||||
|
|
||||||
|
/* function declarations */
|
||||||
|
static void applyrules(Client *c);
|
||||||
|
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||||
|
static void arrange(Monitor *m);
|
||||||
|
static void arrangemon(Monitor *m);
|
||||||
|
static void attach(Client *c);
|
||||||
|
static void attachstack(Client *c);
|
||||||
|
static void buttonpress(XEvent *e);
|
||||||
|
static void checkotherwm(void);
|
||||||
|
static void cleanup(void);
|
||||||
|
static void cleanupmon(Monitor *mon);
|
||||||
|
static void clientmessage(XEvent *e);
|
||||||
|
static void configure(Client *c);
|
||||||
|
static void configurenotify(XEvent *e);
|
||||||
|
static void configurerequest(XEvent *e);
|
||||||
|
static Monitor *createmon(void);
|
||||||
|
static void destroynotify(XEvent *e);
|
||||||
|
static void detach(Client *c);
|
||||||
|
static void detachstack(Client *c);
|
||||||
|
static Monitor *dirtomon(int dir);
|
||||||
|
static void drawbar(Monitor *m);
|
||||||
|
static void drawbars(void);
|
||||||
|
static void enternotify(XEvent *e);
|
||||||
|
static void expose(XEvent *e);
|
||||||
|
static void focus(Client *c);
|
||||||
|
static void focusin(XEvent *e);
|
||||||
|
static void focusmon(const Arg *arg);
|
||||||
|
static void focusstack(const Arg *arg);
|
||||||
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
|
static int getrootptr(int *x, int *y);
|
||||||
|
static long getstate(Window w);
|
||||||
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
|
static void grabbuttons(Client *c, int focused);
|
||||||
|
static void grabkeys(void);
|
||||||
|
static void incnmaster(const Arg *arg);
|
||||||
|
static void keypress(XEvent *e);
|
||||||
|
static void killclient(const Arg *arg);
|
||||||
|
static void manage(Window w, XWindowAttributes *wa);
|
||||||
|
static void mappingnotify(XEvent *e);
|
||||||
|
static void maprequest(XEvent *e);
|
||||||
|
static void monocle(Monitor *m);
|
||||||
|
static void motionnotify(XEvent *e);
|
||||||
|
static void movemouse(const Arg *arg);
|
||||||
|
static Client *nexttiled(Client *c);
|
||||||
|
static void pop(Client *);
|
||||||
|
static void propertynotify(XEvent *e);
|
||||||
|
static void quit(const Arg *arg);
|
||||||
|
static Monitor *recttomon(int x, int y, int w, int h);
|
||||||
|
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||||
|
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
|
static void resizemouse(const Arg *arg);
|
||||||
|
static void restack(Monitor *m);
|
||||||
|
static void run(void);
|
||||||
|
static void scan(void);
|
||||||
|
static int sendevent(Client *c, Atom proto);
|
||||||
|
static void sendmon(Client *c, Monitor *m);
|
||||||
|
static void setclientstate(Client *c, long state);
|
||||||
|
static void setfocus(Client *c);
|
||||||
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
static void setlayout(const Arg *arg);
|
||||||
|
static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
static void seturgent(Client *c, int urg);
|
||||||
|
static void showhide(Client *c);
|
||||||
|
static void sigchld(int unused);
|
||||||
|
static void spawn(const Arg *arg);
|
||||||
|
static void tag(const Arg *arg);
|
||||||
|
static void tagmon(const Arg *arg);
|
||||||
|
static void tile(Monitor *);
|
||||||
|
static void togglebar(const Arg *arg);
|
||||||
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
static void unmanage(Client *c, int destroyed);
|
||||||
|
static void unmapnotify(XEvent *e);
|
||||||
|
static void updatebarpos(Monitor *m);
|
||||||
|
static void updatebars(void);
|
||||||
|
static void updateclientlist(void);
|
||||||
|
static int updategeom(void);
|
||||||
|
static void updatenumlockmask(void);
|
||||||
|
static void updatesizehints(Client *c);
|
||||||
|
static void updatestatus(void);
|
||||||
|
static void updatetitle(Client *c);
|
||||||
|
static void updatewindowtype(Client *c);
|
||||||
|
static void updatewmhints(Client *c);
|
||||||
|
static void view(const Arg *arg);
|
||||||
|
static Client *wintoclient(Window w);
|
||||||
|
static Monitor *wintomon(Window w);
|
||||||
|
static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
static char stext[256];
|
||||||
|
static int screen;
|
||||||
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
|
static int bh, blw = 0; /* bar geometry */
|
||||||
|
static int lrpad; /* sum of left and right padding for text */
|
||||||
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
|
static unsigned int numlockmask = 0;
|
||||||
|
static void (*handler[LASTEvent]) (XEvent *) = {
|
||||||
|
[ButtonPress] = buttonpress,
|
||||||
|
[ClientMessage] = clientmessage,
|
||||||
|
[ConfigureRequest] = configurerequest,
|
||||||
|
[ConfigureNotify] = configurenotify,
|
||||||
|
[DestroyNotify] = destroynotify,
|
||||||
|
[EnterNotify] = enternotify,
|
||||||
|
[Expose] = expose,
|
||||||
|
[FocusIn] = focusin,
|
||||||
|
[KeyPress] = keypress,
|
||||||
|
[MappingNotify] = mappingnotify,
|
||||||
|
[MapRequest] = maprequest,
|
||||||
|
[MotionNotify] = motionnotify,
|
||||||
|
[PropertyNotify] = propertynotify,
|
||||||
|
[UnmapNotify] = unmapnotify
|
||||||
|
};
|
||||||
|
static Atom wmatom[WMLast], netatom[NetLast];
|
||||||
|
static int running = 1;
|
||||||
|
static Cur *cursor[CurLast];
|
||||||
|
static Clr **scheme;
|
||||||
|
static Display *dpy;
|
||||||
|
static Drw *drw;
|
||||||
|
static Monitor *mons, *selmon;
|
||||||
|
static Window root, wmcheckwin;
|
||||||
|
|
||||||
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
|
|
||||||
/* function implementations */
|
/* function implementations */
|
||||||
void
|
void
|
||||||
applyrules(Client *c)
|
applyrules(Client *c)
|
||||||
|
@ -117,8 +345,6 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
|
||||||
if (*w < bh)
|
if (*w < bh)
|
||||||
*w = bh;
|
*w = bh;
|
||||||
if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
|
if (resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) {
|
||||||
if (!c->hintsvalid)
|
|
||||||
updatesizehints(c);
|
|
||||||
/* see last two sentences in ICCCM 4.1.2.3 */
|
/* see last two sentences in ICCCM 4.1.2.3 */
|
||||||
baseismin = c->basew == c->minw && c->baseh == c->minh;
|
baseismin = c->basew == c->minw && c->baseh == c->minh;
|
||||||
if (!baseismin) { /* temporarily remove base dimensions */
|
if (!baseismin) { /* temporarily remove base dimensions */
|
||||||
|
@ -212,29 +438,10 @@ buttonpress(XEvent *e)
|
||||||
if (i < LENGTH(tags)) {
|
if (i < LENGTH(tags)) {
|
||||||
click = ClkTagBar;
|
click = ClkTagBar;
|
||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
} else if (ev->x < x + blw)
|
||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
else if (ev->x > selmon->ww - statusw) {
|
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||||
char *text, *s, ch;
|
|
||||||
*lastbutton = '0' + ev->button;
|
|
||||||
|
|
||||||
x = selmon->ww - statusw;
|
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
|
|
||||||
statuscmdn = 0;
|
|
||||||
for (text = s = stext; *s && x <= ev->x; s++) {
|
|
||||||
if ((unsigned char)(*s) < ' ') {
|
|
||||||
ch = *s;
|
|
||||||
*s = '\0';
|
|
||||||
x += TEXTW(text) - lrpad;
|
|
||||||
*s = ch;
|
|
||||||
text = s + 1;
|
|
||||||
if (x >= ev->x)
|
|
||||||
break;
|
|
||||||
statuscmdn = ch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
} else if ((c = wintoclient(ev->window))) {
|
||||||
|
@ -280,7 +487,6 @@ cleanup(void)
|
||||||
drw_cur_free(drw, cursor[i]);
|
drw_cur_free(drw, cursor[i]);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
free(scheme[i]);
|
free(scheme[i]);
|
||||||
free(scheme);
|
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -426,7 +632,6 @@ Monitor *
|
||||||
createmon(void)
|
createmon(void)
|
||||||
{
|
{
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
m = ecalloc(1, sizeof(Monitor));
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
|
@ -437,26 +642,6 @@ createmon(void)
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
m->pertag = ecalloc(1, sizeof(Pertag));
|
|
||||||
m->pertag->curtag = m->pertag->prevtag = 1;
|
|
||||||
|
|
||||||
for (i = 0; i <= LENGTH(tags); i++) {
|
|
||||||
m->pertag->nmasters[i] = m->nmaster;
|
|
||||||
m->pertag->mfacts[i] = m->mfact;
|
|
||||||
|
|
||||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
|
||||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
|
||||||
m->pertag->sellts[i] = m->sellt;
|
|
||||||
|
|
||||||
m->pertag->showbars[i] = m->showbar;
|
|
||||||
if (i > 0) {
|
|
||||||
m->pertag->drawwithgaps[i] = startwithgaps[(i - 1) % LENGTH(gappx)];
|
|
||||||
m->pertag->gappx[i] = gappx[(i - 1) % LENGTH(gappx)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m->pertag->drawwithgaps[0] = startwithgaps[0];
|
|
||||||
m->pertag->gappx[0] = gappx[0];
|
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,24 +707,9 @@ drawbar(Monitor *m)
|
||||||
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||||
char *text, *s, ch;
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||||
x = 0;
|
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||||
for (text = s = stext; *s; s++) {
|
|
||||||
if ((unsigned char)(*s) < ' ') {
|
|
||||||
ch = *s;
|
|
||||||
*s = '\0';
|
|
||||||
tw = TEXTW(text) - lrpad;
|
|
||||||
drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
|
||||||
x += tw;
|
|
||||||
*s = ch;
|
|
||||||
text = s + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tw = TEXTW(text) - lrpad + 2;
|
|
||||||
drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
|
||||||
tw = statusw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
@ -558,7 +728,7 @@ drawbar(Monitor *m)
|
||||||
urg & 1 << i);
|
urg & 1 << i);
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
w = TEXTW(m->ltsymbol);
|
w = blw = TEXTW(m->ltsymbol);
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||||
|
|
||||||
|
@ -630,12 +800,6 @@ focus(Client *c)
|
||||||
attachstack(c);
|
attachstack(c);
|
||||||
grabbuttons(c, 1);
|
grabbuttons(c, 1);
|
||||||
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
||||||
if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && !c->isfloating) {
|
|
||||||
XWindowChanges wc;
|
|
||||||
wc.sibling = selmon->barwin;
|
|
||||||
wc.stack_mode = Below;
|
|
||||||
XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
|
|
||||||
}
|
|
||||||
setfocus(c);
|
setfocus(c);
|
||||||
} else {
|
} else {
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||||
|
@ -751,11 +915,13 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size)
|
||||||
text[0] = '\0';
|
text[0] = '\0';
|
||||||
if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
|
if (!XGetTextProperty(dpy, w, &name, atom) || !name.nitems)
|
||||||
return 0;
|
return 0;
|
||||||
if (name.encoding == XA_STRING) {
|
if (name.encoding == XA_STRING)
|
||||||
strncpy(text, (char *)name.value, size - 1);
|
strncpy(text, (char *)name.value, size - 1);
|
||||||
} else if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
|
else {
|
||||||
strncpy(text, *list, size - 1);
|
if (XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) {
|
||||||
XFreeStringList(list);
|
strncpy(text, *list, size - 1);
|
||||||
|
XFreeStringList(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
text[size - 1] = '\0';
|
text[size - 1] = '\0';
|
||||||
XFree(name.value);
|
XFree(name.value);
|
||||||
|
@ -788,33 +954,23 @@ grabkeys(void)
|
||||||
{
|
{
|
||||||
updatenumlockmask();
|
updatenumlockmask();
|
||||||
{
|
{
|
||||||
unsigned int i, j, k;
|
unsigned int i, j;
|
||||||
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||||
int start, end, skip;
|
KeyCode code;
|
||||||
KeySym *syms;
|
|
||||||
|
|
||||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
XDisplayKeycodes(dpy, &start, &end);
|
for (i = 0; i < LENGTH(keys); i++)
|
||||||
syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
|
if ((code = XKeysymToKeycode(dpy, keys[i].keysym)))
|
||||||
if (!syms)
|
for (j = 0; j < LENGTH(modifiers); j++)
|
||||||
return;
|
XGrabKey(dpy, code, keys[i].mod | modifiers[j], root,
|
||||||
for (k = start; k <= end; k++)
|
True, GrabModeAsync, GrabModeAsync);
|
||||||
for (i = 0; i < LENGTH(keys); i++)
|
|
||||||
/* skip modifier codes, we do that ourselves */
|
|
||||||
if (keys[i].keysym == syms[(k - start) * skip])
|
|
||||||
for (j = 0; j < LENGTH(modifiers); j++)
|
|
||||||
XGrabKey(dpy, k,
|
|
||||||
keys[i].mod | modifiers[j],
|
|
||||||
root, True,
|
|
||||||
GrabModeAsync, GrabModeAsync);
|
|
||||||
XFree(syms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,12 +1043,14 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
|
||||||
c->x = c->mon->wx + c->mon->ww - WIDTH(c);
|
c->x = c->mon->mx + c->mon->mw - WIDTH(c);
|
||||||
if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh)
|
if (c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
|
||||||
c->y = c->mon->wy + c->mon->wh - HEIGHT(c);
|
c->y = c->mon->my + c->mon->mh - HEIGHT(c);
|
||||||
c->x = MAX(c->x, c->mon->wx);
|
c->x = MAX(c->x, c->mon->mx);
|
||||||
c->y = MAX(c->y, c->mon->wy);
|
/* only fix client y-offset, if the client center might cover the bar */
|
||||||
|
c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
|
||||||
|
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
|
||||||
c->bw = borderpx;
|
c->bw = borderpx;
|
||||||
|
|
||||||
wc.border_width = c->bw;
|
wc.border_width = c->bw;
|
||||||
|
@ -938,7 +1096,9 @@ maprequest(XEvent *e)
|
||||||
static XWindowAttributes wa;
|
static XWindowAttributes wa;
|
||||||
XMapRequestEvent *ev = &e->xmaprequest;
|
XMapRequestEvent *ev = &e->xmaprequest;
|
||||||
|
|
||||||
if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
|
if (!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||||
|
return;
|
||||||
|
if (wa.override_redirect)
|
||||||
return;
|
return;
|
||||||
if (!wintoclient(ev->window))
|
if (!wintoclient(ev->window))
|
||||||
manage(ev->window, &wa);
|
manage(ev->window, &wa);
|
||||||
|
@ -956,10 +1116,7 @@ monocle(Monitor *m)
|
||||||
if (n > 0) /* override layout symbol */
|
if (n > 0) /* override layout symbol */
|
||||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
||||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
||||||
if (selmon->pertag->drawwithgaps[selmon->pertag->curtag])
|
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||||
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
|
||||||
else
|
|
||||||
resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1075,7 +1232,7 @@ propertynotify(XEvent *e)
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
break;
|
break;
|
||||||
case XA_WM_NORMAL_HINTS:
|
case XA_WM_NORMAL_HINTS:
|
||||||
c->hintsvalid = 0;
|
updatesizehints(c);
|
||||||
break;
|
break;
|
||||||
case XA_WM_HINTS:
|
case XA_WM_HINTS:
|
||||||
updatewmhints(c);
|
updatewmhints(c);
|
||||||
|
@ -1129,15 +1286,6 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
c->oldw = c->w; c->w = wc.width = w;
|
c->oldw = c->w; c->w = wc.width = w;
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
c->oldh = c->h; c->h = wc.height = h;
|
||||||
wc.border_width = c->bw;
|
wc.border_width = c->bw;
|
||||||
if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && /* this is the noborderfloatingfix patch, slightly modified so that it will work if, and only if, gaps are disabled. */
|
|
||||||
(((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) /* these two first lines are the only ones changed. if you are manually patching and have noborder installed already, just change these lines; or conversely, just remove this section if the noborder patch is not desired;) */
|
|
||||||
|| &monocle == c->mon->lt[c->mon->sellt]->arrange))
|
|
||||||
&& !c->isfullscreen && !c->isfloating
|
|
||||||
&& NULL != c->mon->lt[c->mon->sellt]->arrange) {
|
|
||||||
c->w = wc.width += c->bw * 2;
|
|
||||||
c->h = wc.height += c->bw * 2;
|
|
||||||
wc.border_width = 0;
|
|
||||||
}
|
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -1236,12 +1384,6 @@ run(void)
|
||||||
handler[ev.type](&ev); /* call handler */
|
handler[ev.type](&ev); /* call handler */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
runAutostart(void) {
|
|
||||||
system("cd ~/.dwm; ./autostart_blocking.sh");
|
|
||||||
system("cd ~/.dwm; ./autostart.sh &");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
scan(void)
|
scan(void)
|
||||||
{
|
{
|
||||||
|
@ -1359,36 +1501,13 @@ setfullscreen(Client *c, int fullscreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
setgaps(const Arg *arg)
|
|
||||||
{
|
|
||||||
switch(arg->i)
|
|
||||||
{
|
|
||||||
case GAP_TOGGLE:
|
|
||||||
selmon->pertag->drawwithgaps[selmon->pertag->curtag] = !selmon->pertag->drawwithgaps[selmon->pertag->curtag];
|
|
||||||
break;
|
|
||||||
case GAP_RESET:
|
|
||||||
if (selmon->pertag->curtag > 0)
|
|
||||||
selmon->pertag->gappx[selmon->pertag->curtag] = gappx[selmon->pertag->curtag - 1 % LENGTH(gappx)];
|
|
||||||
else
|
|
||||||
selmon->pertag->gappx[0] = gappx[0];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (selmon->pertag->gappx[selmon->pertag->curtag] + arg->i < 0)
|
|
||||||
selmon->pertag->gappx[selmon->pertag->curtag] = 0;
|
|
||||||
else
|
|
||||||
selmon->pertag->gappx[selmon->pertag->curtag] += arg->i;
|
|
||||||
}
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setlayout(const Arg *arg)
|
setlayout(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
selmon->sellt ^= 1;
|
||||||
if (arg && arg->v)
|
if (arg && arg->v)
|
||||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
||||||
if (selmon->sel)
|
if (selmon->sel)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
@ -1407,7 +1526,7 @@ setmfact(const Arg *arg)
|
||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
||||||
if (f < 0.05 || f > 0.95)
|
if (f < 0.05 || f > 0.95)
|
||||||
return;
|
return;
|
||||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
selmon->mfact = f;
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1417,16 +1536,9 @@ setup(void)
|
||||||
int i;
|
int i;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
Atom utf8string;
|
Atom utf8string;
|
||||||
struct sigaction sa;
|
|
||||||
|
|
||||||
/* do not transform children into zombies when they terminate */
|
/* clean up any zombies immediately */
|
||||||
sigemptyset(&sa.sa_mask);
|
sigchld(0);
|
||||||
sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART;
|
|
||||||
sa.sa_handler = SIG_IGN;
|
|
||||||
sigaction(SIGCHLD, &sa, NULL);
|
|
||||||
|
|
||||||
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
|
||||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
|
||||||
|
|
||||||
/* init screen */
|
/* init screen */
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
|
@ -1488,6 +1600,7 @@ setup(void)
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
seturgent(Client *c, int urg)
|
seturgent(Client *c, int urg)
|
||||||
{
|
{
|
||||||
|
@ -1519,36 +1632,27 @@ showhide(Client *c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigchld(int unused)
|
||||||
|
{
|
||||||
|
if (signal(SIGCHLD, sigchld) == SIG_ERR)
|
||||||
|
die("can't install SIGCHLD handler:");
|
||||||
|
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
if (arg->v == dmenucmd)
|
||||||
|
dmenumon[0] = '0' + selmon->num;
|
||||||
// if (arg->v == dmenucmd)
|
|
||||||
// dmenumon[0] = '0' + selmon->num;
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (dpy)
|
if (dpy)
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
if (arg->v == statuscmd) {
|
|
||||||
for (int i = 0; i < LENGTH(statuscmds); i++) {
|
|
||||||
if (statuscmdn == statuscmds[i].id) {
|
|
||||||
statuscmd[2] = statuscmds[i].cmd;
|
|
||||||
setenv("BUTTON", lastbutton, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!statuscmd[2])
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
setsid();
|
setsid();
|
||||||
|
|
||||||
sigemptyset(&sa.sa_mask);
|
|
||||||
sa.sa_flags = 0;
|
|
||||||
sa.sa_handler = SIG_DFL;
|
|
||||||
sigaction(SIGCHLD, &sa, NULL);
|
|
||||||
|
|
||||||
execvp(((char **)arg->v)[0], (char **)arg->v);
|
execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||||
die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]);
|
fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
|
||||||
|
perror(" failed");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1579,48 +1683,29 @@ tile(Monitor *m)
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
if (m->pertag->drawwithgaps[m->pertag->curtag]) { /* draw with fullgaps logic */
|
|
||||||
if (n > m->nmaster)
|
if (n > m->nmaster)
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww - m->pertag->gappx[m->pertag->curtag];
|
mw = m->ww;
|
||||||
for (i = 0, my = ty = m->pertag->gappx[m->pertag->curtag], c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->pertag->gappx[m->pertag->curtag];
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
resize(c, m->wx + m->pertag->gappx[m->pertag->curtag], m->wy + my, mw - (2*c->bw) - m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
|
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
if (my + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
|
if (my + HEIGHT(c) < m->wh)
|
||||||
my += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
|
my += HEIGHT(c);
|
||||||
} else {
|
} else {
|
||||||
h = (m->wh - ty) / (n - i) - m->pertag->gappx[m->pertag->curtag];
|
h = (m->wh - ty) / (n - i);
|
||||||
resize(c, m->wx + mw + m->pertag->gappx[m->pertag->curtag], m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
|
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
if (ty + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
|
if (ty + HEIGHT(c) < m->wh)
|
||||||
ty += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
|
ty += HEIGHT(c);
|
||||||
}
|
}
|
||||||
} else { /* draw with singularborders logic */
|
|
||||||
if (n > m->nmaster)
|
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
else
|
|
||||||
mw = m->ww;
|
|
||||||
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
||||||
if (i < m->nmaster) {
|
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
|
||||||
if (n == 1)
|
|
||||||
resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
|
|
||||||
else
|
|
||||||
resize(c, m->wx - c->bw, m->wy + my, mw - c->bw, h - c->bw, False);
|
|
||||||
my += HEIGHT(c) - c->bw;
|
|
||||||
} else {
|
|
||||||
h = (m->wh - ty) / (n - i);
|
|
||||||
resize(c, m->wx + mw - c->bw, m->wy + ty, m->ww - mw, h - c->bw, False);
|
|
||||||
ty += HEIGHT(c) - c->bw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglebar(const Arg *arg)
|
togglebar(const Arg *arg)
|
||||||
{
|
{
|
||||||
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
selmon->showbar = !selmon->showbar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
|
@ -1640,13 +1725,6 @@ togglefloating(const Arg *arg)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
togglefullscr(const Arg *arg)
|
|
||||||
{
|
|
||||||
if(selmon->sel)
|
|
||||||
setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
@ -1666,33 +1744,9 @@ void
|
||||||
toggleview(const Arg *arg)
|
toggleview(const Arg *arg)
|
||||||
{
|
{
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
||||||
int i;
|
|
||||||
|
|
||||||
if (newtagset) {
|
if (newtagset) {
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
|
|
||||||
if (newtagset == ~0) {
|
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
selmon->pertag->curtag = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* test if the user did not select the same tag */
|
|
||||||
if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
for (i = 0; !(newtagset & 1 << i); i++) ;
|
|
||||||
selmon->pertag->curtag = i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* apply settings for this view */
|
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
|
|
||||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
togglebar(NULL);
|
|
||||||
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
@ -1723,7 +1777,6 @@ unmanage(Client *c, int destroyed)
|
||||||
wc.border_width = c->oldbw;
|
wc.border_width = c->oldbw;
|
||||||
XGrabServer(dpy); /* avoid race conditions */
|
XGrabServer(dpy); /* avoid race conditions */
|
||||||
XSetErrorHandler(xerrordummy);
|
XSetErrorHandler(xerrordummy);
|
||||||
XSelectInput(dpy, c->win, NoEventMask);
|
|
||||||
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
|
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
setclientstate(c, WithdrawnState);
|
setclientstate(c, WithdrawnState);
|
||||||
|
@ -1821,42 +1874,42 @@ updategeom(void)
|
||||||
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
|
||||||
XFree(info);
|
XFree(info);
|
||||||
nn = j;
|
nn = j;
|
||||||
|
if (n <= nn) { /* new monitors available */
|
||||||
/* new monitors if nn > n */
|
for (i = 0; i < (nn - n); i++) {
|
||||||
for (i = n; i < nn; i++) {
|
for (m = mons; m && m->next; m = m->next);
|
||||||
for (m = mons; m && m->next; m = m->next);
|
if (m)
|
||||||
if (m)
|
m->next = createmon();
|
||||||
m->next = createmon();
|
else
|
||||||
else
|
mons = createmon();
|
||||||
mons = createmon();
|
|
||||||
}
|
|
||||||
for (i = 0, m = mons; i < nn && m; m = m->next, i++)
|
|
||||||
if (i >= n
|
|
||||||
|| unique[i].x_org != m->mx || unique[i].y_org != m->my
|
|
||||||
|| unique[i].width != m->mw || unique[i].height != m->mh)
|
|
||||||
{
|
|
||||||
dirty = 1;
|
|
||||||
m->num = i;
|
|
||||||
m->mx = m->wx = unique[i].x_org;
|
|
||||||
m->my = m->wy = unique[i].y_org;
|
|
||||||
m->mw = m->ww = unique[i].width;
|
|
||||||
m->mh = m->wh = unique[i].height;
|
|
||||||
updatebarpos(m);
|
|
||||||
}
|
}
|
||||||
/* removed monitors if n > nn */
|
for (i = 0, m = mons; i < nn && m; m = m->next, i++)
|
||||||
for (i = nn; i < n; i++) {
|
if (i >= n
|
||||||
for (m = mons; m && m->next; m = m->next);
|
|| unique[i].x_org != m->mx || unique[i].y_org != m->my
|
||||||
while ((c = m->clients)) {
|
|| unique[i].width != m->mw || unique[i].height != m->mh)
|
||||||
dirty = 1;
|
{
|
||||||
m->clients = c->next;
|
dirty = 1;
|
||||||
detachstack(c);
|
m->num = i;
|
||||||
c->mon = mons;
|
m->mx = m->wx = unique[i].x_org;
|
||||||
attach(c);
|
m->my = m->wy = unique[i].y_org;
|
||||||
attachstack(c);
|
m->mw = m->ww = unique[i].width;
|
||||||
|
m->mh = m->wh = unique[i].height;
|
||||||
|
updatebarpos(m);
|
||||||
|
}
|
||||||
|
} else { /* less monitors available nn < n */
|
||||||
|
for (i = nn; i < n; i++) {
|
||||||
|
for (m = mons; m && m->next; m = m->next);
|
||||||
|
while ((c = m->clients)) {
|
||||||
|
dirty = 1;
|
||||||
|
m->clients = c->next;
|
||||||
|
detachstack(c);
|
||||||
|
c->mon = mons;
|
||||||
|
attach(c);
|
||||||
|
attachstack(c);
|
||||||
|
}
|
||||||
|
if (m == selmon)
|
||||||
|
selmon = mons;
|
||||||
|
cleanupmon(m);
|
||||||
}
|
}
|
||||||
if (m == selmon)
|
|
||||||
selmon = mons;
|
|
||||||
cleanupmon(m);
|
|
||||||
}
|
}
|
||||||
free(unique);
|
free(unique);
|
||||||
} else
|
} else
|
||||||
|
@ -1935,29 +1988,13 @@ updatesizehints(Client *c)
|
||||||
} else
|
} else
|
||||||
c->maxa = c->mina = 0.0;
|
c->maxa = c->mina = 0.0;
|
||||||
c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
|
c->isfixed = (c->maxw && c->maxh && c->maxw == c->minw && c->maxh == c->minh);
|
||||||
c->hintsvalid = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatestatus(void)
|
updatestatus(void)
|
||||||
{
|
{
|
||||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
|
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||||
strcpy(stext, "dwm-"VERSION);
|
strcpy(stext, "dwm-"VERSION);
|
||||||
statusw = TEXTW(stext) - lrpad + 2;
|
|
||||||
} else {
|
|
||||||
char *text, *s, ch;
|
|
||||||
statusw = 0;
|
|
||||||
for (text = s = stext; *s; s++) {
|
|
||||||
if ((unsigned char)(*s) < ' ') {
|
|
||||||
ch = *s;
|
|
||||||
*s = '\0';
|
|
||||||
statusw += TEXTW(text) - lrpad;
|
|
||||||
*s = ch;
|
|
||||||
text = s + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
statusw += TEXTW(text) - lrpad + 2;
|
|
||||||
}
|
|
||||||
drawbar(selmon);
|
drawbar(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2004,37 +2041,11 @@ updatewmhints(Client *c)
|
||||||
void
|
void
|
||||||
view(const Arg *arg)
|
view(const Arg *arg)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
unsigned int tmptag;
|
|
||||||
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||||
return;
|
return;
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
if (arg->ui & TAGMASK) {
|
if (arg->ui & TAGMASK)
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
|
|
||||||
if (arg->ui == ~0)
|
|
||||||
selmon->pertag->curtag = 0;
|
|
||||||
else {
|
|
||||||
for (i = 0; !(arg->ui & 1 << i); i++) ;
|
|
||||||
selmon->pertag->curtag = i + 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tmptag = selmon->pertag->prevtag;
|
|
||||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
selmon->pertag->curtag = tmptag;
|
|
||||||
}
|
|
||||||
|
|
||||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
|
|
||||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
togglebar(NULL);
|
|
||||||
|
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
@ -2110,10 +2121,12 @@ zoom(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c = selmon->sel;
|
Client *c = selmon->sel;
|
||||||
|
|
||||||
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
|
if (!selmon->lt[selmon->sellt]->arrange
|
||||||
return;
|
|| (selmon->sel && selmon->sel->isfloating))
|
||||||
if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
|
|
||||||
return;
|
return;
|
||||||
|
if (c == nexttiled(selmon->clients))
|
||||||
|
if (!c || !(c = nexttiled(c->next)))
|
||||||
|
return;
|
||||||
pop(c);
|
pop(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2135,7 +2148,6 @@ main(int argc, char *argv[])
|
||||||
die("pledge");
|
die("pledge");
|
||||||
#endif /* __OpenBSD__ */
|
#endif /* __OpenBSD__ */
|
||||||
scan();
|
scan();
|
||||||
runAutostart();
|
|
||||||
run();
|
run();
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
# copy to /usr/share/xsessions/dwm.desktop
|
|
||||||
|
|
||||||
[Desktop Entry]
|
|
||||||
Encoding=UTF-8
|
|
||||||
Name=dwm
|
|
||||||
Comment=Dynamic window manager
|
|
||||||
Exec=dwm
|
|
||||||
Icon=dwm
|
|
||||||
Type=XSession
|
|
292
dwm.h
292
dwm.h
|
@ -1,292 +0,0 @@
|
||||||
#ifndef _H_DWM
|
|
||||||
#define _H_DWM
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <X11/cursorfont.h>
|
|
||||||
#include <X11/keysym.h>
|
|
||||||
#include <X11/XF86keysym.h>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xproto.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#ifdef XINERAMA
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
|
||||||
#endif /* XINERAMA */
|
|
||||||
#include <X11/Xft/Xft.h>
|
|
||||||
|
|
||||||
#include "drw.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* macros */
|
|
||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
|
||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
|
||||||
|
|
||||||
#define GAP_TOGGLE 100
|
|
||||||
#define GAP_RESET 0
|
|
||||||
|
|
||||||
/* enums */
|
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
|
||||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
|
||||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
|
||||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
|
||||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
|
||||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
|
||||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
|
||||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
int i;
|
|
||||||
unsigned int ui;
|
|
||||||
float f;
|
|
||||||
const void *v;
|
|
||||||
} Arg;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int click;
|
|
||||||
unsigned int mask;
|
|
||||||
unsigned int button;
|
|
||||||
void (*func)(const Arg *arg);
|
|
||||||
const Arg arg;
|
|
||||||
} Button;
|
|
||||||
|
|
||||||
typedef struct Monitor Monitor;
|
|
||||||
typedef struct Client Client;
|
|
||||||
struct Client {
|
|
||||||
char name[256];
|
|
||||||
float mina, maxa;
|
|
||||||
int x, y, w, h;
|
|
||||||
int oldx, oldy, oldw, oldh;
|
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
|
||||||
int bw, oldbw;
|
|
||||||
unsigned int tags;
|
|
||||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
|
||||||
Client *next;
|
|
||||||
Client *snext;
|
|
||||||
Monitor *mon;
|
|
||||||
Window win;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int mod;
|
|
||||||
KeySym keysym;
|
|
||||||
void (*func)(const Arg *);
|
|
||||||
const Arg arg;
|
|
||||||
} Key;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *symbol;
|
|
||||||
void (*arrange)(Monitor *);
|
|
||||||
} Layout;
|
|
||||||
|
|
||||||
typedef struct Pertag Pertag;
|
|
||||||
|
|
||||||
struct Monitor {
|
|
||||||
char ltsymbol[16];
|
|
||||||
float mfact;
|
|
||||||
int nmaster;
|
|
||||||
int num;
|
|
||||||
int by; /* bar geometry */
|
|
||||||
int mx, my, mw, mh; /* screen size */
|
|
||||||
int wx, wy, ww, wh; /* window area */
|
|
||||||
unsigned int seltags;
|
|
||||||
unsigned int sellt;
|
|
||||||
unsigned int tagset[2];
|
|
||||||
int showbar;
|
|
||||||
int topbar;
|
|
||||||
Client *clients;
|
|
||||||
Client *sel;
|
|
||||||
Client *stack;
|
|
||||||
Monitor *next;
|
|
||||||
Window barwin;
|
|
||||||
const Layout *lt[2];
|
|
||||||
Pertag *pertag;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *class;
|
|
||||||
const char *instance;
|
|
||||||
const char *title;
|
|
||||||
unsigned int tags;
|
|
||||||
int isfloating;
|
|
||||||
int monitor;
|
|
||||||
} Rule;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char *cmd;
|
|
||||||
int id;
|
|
||||||
} StatusCmd;
|
|
||||||
|
|
||||||
/* function declarations */
|
|
||||||
void applyrules(Client *c);
|
|
||||||
int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
|
||||||
void arrange(Monitor *m);
|
|
||||||
void arrangemon(Monitor *m);
|
|
||||||
void attach(Client *c);
|
|
||||||
void attachstack(Client *c);
|
|
||||||
void buttonpress(XEvent *e);
|
|
||||||
void checkotherwm(void);
|
|
||||||
void cleanup(void);
|
|
||||||
void cleanupmon(Monitor *mon);
|
|
||||||
void clientmessage(XEvent *e);
|
|
||||||
void configure(Client *c);
|
|
||||||
void configurenotify(XEvent *e);
|
|
||||||
void configurerequest(XEvent *e);
|
|
||||||
Monitor *createmon(void);
|
|
||||||
void destroynotify(XEvent *e);
|
|
||||||
void detach(Client *c);
|
|
||||||
void detachstack(Client *c);
|
|
||||||
Monitor *dirtomon(int dir);
|
|
||||||
void drawbar(Monitor *m);
|
|
||||||
void drawbars(void);
|
|
||||||
void enternotify(XEvent *e);
|
|
||||||
void expose(XEvent *e);
|
|
||||||
void focus(Client *c);
|
|
||||||
void focusin(XEvent *e);
|
|
||||||
void focusmon(const Arg *arg);
|
|
||||||
void focusstack(const Arg *arg);
|
|
||||||
Atom getatomprop(Client *c, Atom prop);
|
|
||||||
int getrootptr(int *x, int *y);
|
|
||||||
long getstate(Window w);
|
|
||||||
int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
|
||||||
void grabbuttons(Client *c, int focused);
|
|
||||||
void grabkeys(void);
|
|
||||||
void incnmaster(const Arg *arg);
|
|
||||||
void keypress(XEvent *e);
|
|
||||||
void killclient(const Arg *arg);
|
|
||||||
void manage(Window w, XWindowAttributes *wa);
|
|
||||||
void mappingnotify(XEvent *e);
|
|
||||||
void maprequest(XEvent *e);
|
|
||||||
void monocle(Monitor *m);
|
|
||||||
void motionnotify(XEvent *e);
|
|
||||||
void movemouse(const Arg *arg);
|
|
||||||
Client *nexttiled(Client *c);
|
|
||||||
void pop(Client *c);
|
|
||||||
void propertynotify(XEvent *e);
|
|
||||||
void quit(const Arg *arg);
|
|
||||||
Monitor *recttomon(int x, int y, int w, int h);
|
|
||||||
void resize(Client *c, int x, int y, int w, int h, int interact);
|
|
||||||
void resizeclient(Client *c, int x, int y, int w, int h);
|
|
||||||
void resizemouse(const Arg *arg);
|
|
||||||
void restack(Monitor *m);
|
|
||||||
void run(void);
|
|
||||||
void runAutostart(void);
|
|
||||||
void scan(void);
|
|
||||||
int sendevent(Client *c, Atom proto);
|
|
||||||
void sendmon(Client *c, Monitor *m);
|
|
||||||
void setclientstate(Client *c, long state);
|
|
||||||
void setfocus(Client *c);
|
|
||||||
void setfullscreen(Client *c, int fullscreen);
|
|
||||||
void setgaps(const Arg *arg);
|
|
||||||
void setlayout(const Arg *arg);
|
|
||||||
void setmfact(const Arg *arg);
|
|
||||||
void setup(void);
|
|
||||||
void seturgent(Client *c, int urg);
|
|
||||||
void showhide(Client *c);
|
|
||||||
void spawn(const Arg *arg);
|
|
||||||
void tag(const Arg *arg);
|
|
||||||
void tagmon(const Arg *arg);
|
|
||||||
void tile(Monitor *m);
|
|
||||||
void togglebar(const Arg *arg);
|
|
||||||
void togglefloating(const Arg *arg);
|
|
||||||
void togglefullscr(const Arg *arg);
|
|
||||||
void toggletag(const Arg *arg);
|
|
||||||
void toggleview(const Arg *arg);
|
|
||||||
void unfocus(Client *c, int setfocus);
|
|
||||||
void unmanage(Client *c, int destroyed);
|
|
||||||
void unmapnotify(XEvent *e);
|
|
||||||
void updatebarpos(Monitor *m);
|
|
||||||
void updatebars(void);
|
|
||||||
void updateclientlist(void);
|
|
||||||
int updategeom(void);
|
|
||||||
void updatenumlockmask(void);
|
|
||||||
void updatesizehints(Client *c);
|
|
||||||
void updatestatus(void);
|
|
||||||
void updatetitle(Client *c);
|
|
||||||
void updatewindowtype(Client *c);
|
|
||||||
void updatewmhints(Client *c);
|
|
||||||
void view(const Arg *arg);
|
|
||||||
Client *wintoclient(Window w);
|
|
||||||
Monitor *wintomon(Window w);
|
|
||||||
int xerror(Display *dpy, XErrorEvent *ee);
|
|
||||||
int xerrordummy(Display *dpy, XErrorEvent *ee);
|
|
||||||
int xerrorstart(Display *dpy, XErrorEvent *ee);
|
|
||||||
void zoom(const Arg *arg);
|
|
||||||
|
|
||||||
/* variables */
|
|
||||||
const char broken[] = "broken";
|
|
||||||
char stext[256];
|
|
||||||
int screen;
|
|
||||||
int sw, sh; /* X display screen geometry width, height */
|
|
||||||
int bh; /* bar height */
|
|
||||||
int lrpad; /* sum of left and right padding for text */
|
|
||||||
int (*xerrorxlib)(Display *, XErrorEvent *);
|
|
||||||
unsigned int numlockmask = 0;
|
|
||||||
void (*handler[LASTEvent]) (XEvent *) = {
|
|
||||||
[ButtonPress] = buttonpress,
|
|
||||||
[ClientMessage] = clientmessage,
|
|
||||||
[ConfigureRequest] = configurerequest,
|
|
||||||
[ConfigureNotify] = configurenotify,
|
|
||||||
[DestroyNotify] = destroynotify,
|
|
||||||
[EnterNotify] = enternotify,
|
|
||||||
[Expose] = expose,
|
|
||||||
[FocusIn] = focusin,
|
|
||||||
[KeyPress] = keypress,
|
|
||||||
[MappingNotify] = mappingnotify,
|
|
||||||
[MapRequest] = maprequest,
|
|
||||||
[MotionNotify] = motionnotify,
|
|
||||||
[PropertyNotify] = propertynotify,
|
|
||||||
[UnmapNotify] = unmapnotify
|
|
||||||
};
|
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
|
||||||
int running = 1;
|
|
||||||
Cur *cursor[CurLast];
|
|
||||||
Clr **scheme;
|
|
||||||
Display *dpy;
|
|
||||||
Drw *drw;
|
|
||||||
Monitor *mons, *selmon;
|
|
||||||
Window root, wmcheckwin;
|
|
||||||
int statusw;
|
|
||||||
int statuscmdn;
|
|
||||||
char lastbutton[] = "-";
|
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
|
||||||
|
|
||||||
struct Pertag {
|
|
||||||
unsigned int curtag, prevtag; /* current and previous tag */
|
|
||||||
int nmasters[10]; /* number of windows in master area */
|
|
||||||
float mfacts[10]; /* mfacts per tag */
|
|
||||||
unsigned int sellts[10]; /* selected layouts */
|
|
||||||
const Layout *ltidxs[10][2]; /* matrix of tags and layouts indexes */
|
|
||||||
int showbars[10]; /* display bar for the current tag */
|
|
||||||
|
|
||||||
int drawwithgaps[10]; /* gaps toggle for each tag */
|
|
||||||
int gappx[10]; /* gaps for each tag */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
|
||||||
struct NumTags { char limitexceeded[10 > 31 ? -1 : 1]; };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
From eea13010ffc3983392857ee1e3804e3aa1064d7a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Soenke Lambert <s.lambert@mittwald.de>
|
|
||||||
Date: Wed, 13 Oct 2021 18:21:09 +0200
|
|
||||||
Subject: [PATCH] Fullscreen current window with [Alt]+[Shift]+[f]
|
|
||||||
|
|
||||||
This actually fullscreens a window, instead of just hiding the statusbar
|
|
||||||
and applying the monocle layout.
|
|
||||||
---
|
|
||||||
config.def.h | 1 +
|
|
||||||
dwm.1 | 3 +++
|
|
||||||
dwm.c | 8 ++++++++
|
|
||||||
3 files changed, 12 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 1c0b587..8cd3204 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -78,6 +78,7 @@ static Key keys[] = {
|
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
|
||||||
+ { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
|
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
|
||||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
|
||||||
diff --git a/dwm.1 b/dwm.1
|
|
||||||
index 13b3729..a368d05 100644
|
|
||||||
--- a/dwm.1
|
|
||||||
+++ b/dwm.1
|
|
||||||
@@ -116,6 +116,9 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
|
|
||||||
.B Mod1\-Shift\-c
|
|
||||||
Close focused window.
|
|
||||||
.TP
|
|
||||||
+.B Mod1\-Shift\-f
|
|
||||||
+Toggle fullscreen for focused window.
|
|
||||||
+.TP
|
|
||||||
.B Mod1\-Shift\-space
|
|
||||||
Toggle focused window between tiled and floating state.
|
|
||||||
.TP
|
|
||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index 4465af1..c1b899a 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
|
|
||||||
static void tile(Monitor *);
|
|
||||||
static void togglebar(const Arg *arg);
|
|
||||||
static void togglefloating(const Arg *arg);
|
|
||||||
+static void togglefullscr(const Arg *arg);
|
|
||||||
static void toggletag(const Arg *arg);
|
|
||||||
static void toggleview(const Arg *arg);
|
|
||||||
static void unfocus(Client *c, int setfocus);
|
|
||||||
@@ -1719,6 +1720,13 @@ togglefloating(const Arg *arg)
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+togglefullscr(const Arg *arg)
|
|
||||||
+{
|
|
||||||
+ if(selmon->sel)
|
|
||||||
+ setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
toggletag(const Arg *arg)
|
|
||||||
{
|
|
||||||
--
|
|
||||||
2.30.2
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
commit 5918623c5bd7fda155bf9dc3d33890c4ae1722d0
|
|
||||||
Author: Simon Bremer <simon.bremer@tum.de>
|
|
||||||
Date: Thu Dec 22 17:31:07 2016 +0100
|
|
||||||
|
|
||||||
Applied and fixed autostart patch for previous version;
|
|
||||||
|
|
||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index d27cb67..066ed71 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -194,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
|
||||||
static void resizemouse(const Arg *arg);
|
|
||||||
static void restack(Monitor *m);
|
|
||||||
static void run(void);
|
|
||||||
+static void runAutostart(void);
|
|
||||||
static void scan(void);
|
|
||||||
static int sendevent(Client *c, Atom proto);
|
|
||||||
static void sendmon(Client *c, Monitor *m);
|
|
||||||
@@ -1386,6 +1387,12 @@ run(void)
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
+runAutostart(void) {
|
|
||||||
+ system("cd ~/.dwm; ./autostart_blocking.sh");
|
|
||||||
+ system("cd ~/.dwm; ./autostart.sh &");
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void
|
|
||||||
scan(void)
|
|
||||||
{
|
|
||||||
unsigned int i, num;
|
|
||||||
@@ -2145,6 +2152,7 @@ main(int argc, char *argv[])
|
|
||||||
checkotherwm();
|
|
||||||
setup();
|
|
||||||
scan();
|
|
||||||
+ runAutostart();
|
|
||||||
run();
|
|
||||||
cleanup();
|
|
||||||
XCloseDisplay(dpy);
|
|
|
@ -1,352 +0,0 @@
|
||||||
diff -pu dwm.git/config.def.h dwm.functionalgapspertag/config.def.h
|
|
||||||
--- dwm.git/config.def.h 2021-02-27 21:17:53.862314811 -0600
|
|
||||||
+++ dwm.functionalgapspertag/config.def.h 2021-03-01 15:40:07.312696974 -0600
|
|
||||||
@@ -2,6 +2,8 @@
|
|
||||||
|
|
||||||
/* appearance */
|
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
|
||||||
+static const int startwithgaps[] = { 0 }; /* 1 means gaps are used by default, this can be customized for each tag */
|
|
||||||
+static const unsigned int gappx[] = { 10 }; /* default gap between windows in pixels, this can be customized for each tag */
|
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
|
||||||
@@ -84,6 +86,10 @@ static Key keys[] = {
|
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
|
||||||
+ { MODKEY, XK_minus, setgaps, {.i = -5 } },
|
|
||||||
+ { MODKEY, XK_equal, setgaps, {.i = +5 } },
|
|
||||||
+ { MODKEY|ShiftMask, XK_minus, setgaps, {.i = GAP_RESET } },
|
|
||||||
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = GAP_TOGGLE} },
|
|
||||||
TAGKEYS( XK_1, 0)
|
|
||||||
TAGKEYS( XK_2, 1)
|
|
||||||
TAGKEYS( XK_3, 2)
|
|
||||||
diff -pu dwm.git/dwm.c dwm.functionalgapspertag/dwm.c
|
|
||||||
--- dwm.git/dwm.c 2021-02-27 21:17:53.862314811 -0600
|
|
||||||
+++ dwm.functionalgapspertag/dwm.c 2021-03-01 17:10:10.402964866 -0600
|
|
||||||
@@ -57,6 +57,9 @@
|
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
|
||||||
|
|
||||||
+#define GAP_TOGGLE 100
|
|
||||||
+#define GAP_RESET 0
|
|
||||||
+
|
|
||||||
/* enums */
|
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
|
||||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
|
||||||
@@ -111,6 +114,8 @@ typedef struct {
|
|
||||||
void (*arrange)(Monitor *);
|
|
||||||
} Layout;
|
|
||||||
|
|
||||||
+typedef struct Pertag Pertag;
|
|
||||||
+
|
|
||||||
struct Monitor {
|
|
||||||
char ltsymbol[16];
|
|
||||||
float mfact;
|
|
||||||
@@ -130,6 +135,7 @@ struct Monitor {
|
|
||||||
Monitor *next;
|
|
||||||
Window barwin;
|
|
||||||
const Layout *lt[2];
|
|
||||||
+ Pertag *pertag;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
@@ -200,6 +206,7 @@ static void sendmon(Client *c, Monitor *
|
|
||||||
static void setclientstate(Client *c, long state);
|
|
||||||
static void setfocus(Client *c);
|
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
|
||||||
+static void setgaps(const Arg *arg);
|
|
||||||
static void setlayout(const Arg *arg);
|
|
||||||
static void setmfact(const Arg *arg);
|
|
||||||
static void setup(void);
|
|
||||||
@@ -272,6 +279,18 @@ static Window root, wmcheckwin;
|
|
||||||
/* configuration, allows nested code to access above variables */
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
+struct Pertag {
|
|
||||||
+ unsigned int curtag, prevtag; /* current and previous tag */
|
|
||||||
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
|
|
||||||
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
|
|
||||||
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
|
|
||||||
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
|
||||||
+ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
|
|
||||||
+
|
|
||||||
+ int drawwithgaps[LENGTH(tags) + 1]; /* gaps toggle for each tag */
|
|
||||||
+ int gappx[LENGTH(tags) + 1]; /* gaps for each tag */
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
|
||||||
|
|
||||||
@@ -632,6 +651,7 @@ Monitor *
|
|
||||||
createmon(void)
|
|
||||||
{
|
|
||||||
Monitor *m;
|
|
||||||
+ unsigned int i;
|
|
||||||
|
|
||||||
m = ecalloc(1, sizeof(Monitor));
|
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
|
||||||
@@ -642,6 +662,26 @@ createmon(void)
|
|
||||||
m->lt[0] = &layouts[0];
|
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
|
||||||
+ m->pertag = ecalloc(1, sizeof(Pertag));
|
|
||||||
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i <= LENGTH(tags); i++) {
|
|
||||||
+ m->pertag->nmasters[i] = m->nmaster;
|
|
||||||
+ m->pertag->mfacts[i] = m->mfact;
|
|
||||||
+
|
|
||||||
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
|
||||||
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
|
||||||
+ m->pertag->sellts[i] = m->sellt;
|
|
||||||
+
|
|
||||||
+ m->pertag->showbars[i] = m->showbar;
|
|
||||||
+ if (i > 0) {
|
|
||||||
+ m->pertag->drawwithgaps[i] = startwithgaps[(i - 1) % LENGTH(gappx)];
|
|
||||||
+ m->pertag->gappx[i] = gappx[(i - 1) % LENGTH(gappx)];
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ m->pertag->drawwithgaps[0] = startwithgaps[0];
|
|
||||||
+ m->pertag->gappx[0] = gappx[0];
|
|
||||||
+
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -797,6 +837,12 @@ focus(Client *c)
|
|
||||||
attachstack(c);
|
|
||||||
grabbuttons(c, 1);
|
|
||||||
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
|
|
||||||
+ if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && !c->isfloating) {
|
|
||||||
+ XWindowChanges wc;
|
|
||||||
+ wc.sibling = selmon->barwin;
|
|
||||||
+ wc.stack_mode = Below;
|
|
||||||
+ XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
|
|
||||||
+ }
|
|
||||||
setfocus(c);
|
|
||||||
} else {
|
|
||||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
|
||||||
@@ -967,7 +1013,7 @@ grabkeys(void)
|
|
||||||
void
|
|
||||||
incnmaster(const Arg *arg)
|
|
||||||
{
|
|
||||||
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1113,7 +1159,10 @@ monocle(Monitor *m)
|
|
||||||
if (n > 0) /* override layout symbol */
|
|
||||||
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
|
|
||||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
|
||||||
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
|
||||||
+ if (selmon->pertag->drawwithgaps[selmon->pertag->curtag])
|
|
||||||
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
|
||||||
+ else
|
|
||||||
+ resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -1283,6 +1332,15 @@ resizeclient(Client *c, int x, int y, in
|
|
||||||
c->oldw = c->w; c->w = wc.width = w;
|
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
|
||||||
wc.border_width = c->bw;
|
|
||||||
+ if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && /* this is the noborderfloatingfix patch, slightly modified so that it will work if, and only if, gaps are disabled. */
|
|
||||||
+ (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) /* these two first lines are the only ones changed. if you are manually patching and have noborder installed already, just change these lines; or conversely, just remove this section if the noborder patch is not desired;) */
|
|
||||||
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange))
|
|
||||||
+ && !c->isfullscreen && !c->isfloating
|
|
||||||
+ && NULL != c->mon->lt[c->mon->sellt]->arrange) {
|
|
||||||
+ c->w = wc.width += c->bw * 2;
|
|
||||||
+ c->h = wc.height += c->bw * 2;
|
|
||||||
+ wc.border_width = 0;
|
|
||||||
+ }
|
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
|
||||||
configure(c);
|
|
||||||
XSync(dpy, False);
|
|
||||||
@@ -1499,12 +1557,35 @@ setfullscreen(Client *c, int fullscreen)
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
+setgaps(const Arg *arg)
|
|
||||||
+{
|
|
||||||
+ switch(arg->i)
|
|
||||||
+ {
|
|
||||||
+ case GAP_TOGGLE:
|
|
||||||
+ selmon->pertag->drawwithgaps[selmon->pertag->curtag] = !selmon->pertag->drawwithgaps[selmon->pertag->curtag];
|
|
||||||
+ break;
|
|
||||||
+ case GAP_RESET:
|
|
||||||
+ if (selmon->pertag->curtag > 0)
|
|
||||||
+ selmon->pertag->gappx[selmon->pertag->curtag] = gappx[selmon->pertag->curtag - 1 % LENGTH(gappx)];
|
|
||||||
+ else
|
|
||||||
+ selmon->pertag->gappx[0] = gappx[0];
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ if (selmon->pertag->gappx[selmon->pertag->curtag] + arg->i < 0)
|
|
||||||
+ selmon->pertag->gappx[selmon->pertag->curtag] = 0;
|
|
||||||
+ else
|
|
||||||
+ selmon->pertag->gappx[selmon->pertag->curtag] += arg->i;
|
|
||||||
+ }
|
|
||||||
+ arrange(selmon);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void
|
|
||||||
setlayout(const Arg *arg)
|
|
||||||
{
|
|
||||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
|
||||||
- selmon->sellt ^= 1;
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
|
||||||
if (arg && arg->v)
|
|
||||||
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
|
||||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
|
|
||||||
if (selmon->sel)
|
|
||||||
arrange(selmon);
|
|
||||||
@@ -1523,7 +1604,7 @@ setmfact(const Arg *arg)
|
|
||||||
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
|
|
||||||
if (f < 0.05 || f > 0.95)
|
|
||||||
return;
|
|
||||||
- selmon->mfact = f;
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1680,29 +1761,48 @@ tile(Monitor *m)
|
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
|
||||||
if (n == 0)
|
|
||||||
return;
|
|
||||||
-
|
|
||||||
- if (n > m->nmaster)
|
|
||||||
- mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
- else
|
|
||||||
- mw = m->ww;
|
|
||||||
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
||||||
- if (i < m->nmaster) {
|
|
||||||
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
|
||||||
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
|
||||||
- if (my + HEIGHT(c) < m->wh)
|
|
||||||
- my += HEIGHT(c);
|
|
||||||
- } else {
|
|
||||||
- h = (m->wh - ty) / (n - i);
|
|
||||||
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
|
||||||
- if (ty + HEIGHT(c) < m->wh)
|
|
||||||
- ty += HEIGHT(c);
|
|
||||||
- }
|
|
||||||
+ if (m->pertag->drawwithgaps[m->pertag->curtag]) { /* draw with fullgaps logic */
|
|
||||||
+ if (n > m->nmaster)
|
|
||||||
+ mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
+ else
|
|
||||||
+ mw = m->ww - m->pertag->gappx[m->pertag->curtag];
|
|
||||||
+ for (i = 0, my = ty = m->pertag->gappx[m->pertag->curtag], c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
||||||
+ if (i < m->nmaster) {
|
|
||||||
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->pertag->gappx[m->pertag->curtag];
|
|
||||||
+ resize(c, m->wx + m->pertag->gappx[m->pertag->curtag], m->wy + my, mw - (2*c->bw) - m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
|
|
||||||
+ if (my + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
|
|
||||||
+ my += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
|
|
||||||
+ } else {
|
|
||||||
+ h = (m->wh - ty) / (n - i) - m->pertag->gappx[m->pertag->curtag];
|
|
||||||
+ resize(c, m->wx + mw + m->pertag->gappx[m->pertag->curtag], m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
|
|
||||||
+ if (ty + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
|
|
||||||
+ ty += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
|
|
||||||
+ }
|
|
||||||
+ } else { /* draw with singularborders logic */
|
|
||||||
+ if (n > m->nmaster)
|
|
||||||
+ mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
+ else
|
|
||||||
+ mw = m->ww;
|
|
||||||
+ for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
||||||
+ if (i < m->nmaster) {
|
|
||||||
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
|
||||||
+ if (n == 1)
|
|
||||||
+ resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
|
|
||||||
+ else
|
|
||||||
+ resize(c, m->wx - c->bw, m->wy + my, mw - c->bw, h - c->bw, False);
|
|
||||||
+ my += HEIGHT(c) - c->bw;
|
|
||||||
+ } else {
|
|
||||||
+ h = (m->wh - ty) / (n - i);
|
|
||||||
+ resize(c, m->wx + mw - c->bw, m->wy + ty, m->ww - mw, h - c->bw, False);
|
|
||||||
+ ty += HEIGHT(c) - c->bw;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
togglebar(const Arg *arg)
|
|
||||||
{
|
|
||||||
- selmon->showbar = !selmon->showbar;
|
|
||||||
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
|
||||||
updatebarpos(selmon);
|
|
||||||
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
|
||||||
arrange(selmon);
|
|
||||||
@@ -1741,9 +1841,33 @@ void
|
|
||||||
toggleview(const Arg *arg)
|
|
||||||
{
|
|
||||||
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
|
|
||||||
+ int i;
|
|
||||||
|
|
||||||
if (newtagset) {
|
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
|
||||||
+
|
|
||||||
+ if (newtagset == ~0) {
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ selmon->pertag->curtag = 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* test if the user did not select the same tag */
|
|
||||||
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
|
||||||
+ selmon->pertag->curtag = i + 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* apply settings for this view */
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
+
|
|
||||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
+ togglebar(NULL);
|
|
||||||
+
|
|
||||||
focus(NULL);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
@@ -2038,11 +2162,37 @@ updatewmhints(Client *c)
|
|
||||||
void
|
|
||||||
view(const Arg *arg)
|
|
||||||
{
|
|
||||||
+ int i;
|
|
||||||
+ unsigned int tmptag;
|
|
||||||
+
|
|
||||||
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
|
||||||
return;
|
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
|
||||||
- if (arg->ui & TAGMASK)
|
|
||||||
+ if (arg->ui & TAGMASK) {
|
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+
|
|
||||||
+ if (arg->ui == ~0)
|
|
||||||
+ selmon->pertag->curtag = 0;
|
|
||||||
+ else {
|
|
||||||
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
|
||||||
+ selmon->pertag->curtag = i + 1;
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ tmptag = selmon->pertag->prevtag;
|
|
||||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
|
||||||
+ selmon->pertag->curtag = tmptag;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
|
||||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
|
||||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
|
||||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
|
||||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
|
||||||
+
|
|
||||||
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
|
||||||
+ togglebar(NULL);
|
|
||||||
+
|
|
||||||
focus(NULL);
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
From 02c4a28dd7f3a88eef3a4e533ace35f79cf09d57 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Daniel Bylinka <daniel.bylinka@gmail.com>
|
|
||||||
Date: Fri, 2 Apr 2021 19:34:38 +0200
|
|
||||||
Subject: [PATCH] [statuscmd] Run shell commands based on mouse location and
|
|
||||||
button
|
|
||||||
|
|
||||||
---
|
|
||||||
config.def.h | 10 ++++++-
|
|
||||||
dwm.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++---
|
|
||||||
2 files changed, 81 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 1c0b587..8f88366 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -59,6 +59,12 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
|
|
||||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
|
||||||
static const char *termcmd[] = { "st", NULL };
|
|
||||||
|
|
||||||
+/* commands spawned when clicking statusbar, the mouse button pressed is exported as BUTTON */
|
|
||||||
+static const StatusCmd statuscmds[] = {
|
|
||||||
+ { "notify-send Mouse$BUTTON", 1 },
|
|
||||||
+};
|
|
||||||
+static const char *statuscmd[] = { "/bin/sh", "-c", NULL, NULL };
|
|
||||||
+
|
|
||||||
static Key keys[] = {
|
|
||||||
/* modifier key function argument */
|
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
|
||||||
@@ -103,7 +109,9 @@ static Button buttons[] = {
|
|
||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
|
||||||
- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
|
||||||
+ { ClkStatusText, 0, Button1, spawn, {.v = statuscmd } },
|
|
||||||
+ { ClkStatusText, 0, Button2, spawn, {.v = statuscmd } },
|
|
||||||
+ { ClkStatusText, 0, Button3, spawn, {.v = statuscmd } },
|
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
|
||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index b0b3466..eb478a5 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -141,6 +141,11 @@ typedef struct {
|
|
||||||
int monitor;
|
|
||||||
} Rule;
|
|
||||||
|
|
||||||
+typedef struct {
|
|
||||||
+ const char *cmd;
|
|
||||||
+ int id;
|
|
||||||
+} StatusCmd;
|
|
||||||
+
|
|
||||||
/* function declarations */
|
|
||||||
static void applyrules(Client *c);
|
|
||||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
|
||||||
@@ -238,6 +243,9 @@ static void zoom(const Arg *arg);
|
|
||||||
/* variables */
|
|
||||||
static const char broken[] = "broken";
|
|
||||||
static char stext[256];
|
|
||||||
+static int statusw;
|
|
||||||
+static int statuscmdn;
|
|
||||||
+static char lastbutton[] = "-";
|
|
||||||
static int screen;
|
|
||||||
static int sw, sh; /* X display screen geometry width, height */
|
|
||||||
static int bh, blw = 0; /* bar geometry */
|
|
||||||
@@ -440,8 +448,27 @@ buttonpress(XEvent *e)
|
|
||||||
arg.ui = 1 << i;
|
|
||||||
} else if (ev->x < x + blw)
|
|
||||||
click = ClkLtSymbol;
|
|
||||||
- else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
|
||||||
+ else if (ev->x > selmon->ww - statusw) {
|
|
||||||
+ char *text, *s, ch;
|
|
||||||
+ *lastbutton = '0' + ev->button;
|
|
||||||
+
|
|
||||||
+ x = selmon->ww - statusw;
|
|
||||||
click = ClkStatusText;
|
|
||||||
+
|
|
||||||
+ statuscmdn = 0;
|
|
||||||
+ for (text = s = stext; *s && x <= ev->x; s++) {
|
|
||||||
+ if ((unsigned char)(*s) < ' ') {
|
|
||||||
+ ch = *s;
|
|
||||||
+ *s = '\0';
|
|
||||||
+ x += TEXTW(text) - lrpad;
|
|
||||||
+ *s = ch;
|
|
||||||
+ text = s + 1;
|
|
||||||
+ if (x >= ev->x)
|
|
||||||
+ break;
|
|
||||||
+ statuscmdn = ch;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
else
|
|
||||||
click = ClkWinTitle;
|
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
|
||||||
@@ -704,9 +731,24 @@ drawbar(Monitor *m)
|
|
||||||
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
|
||||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
|
||||||
+ char *text, *s, ch;
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
|
||||||
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
|
||||||
+
|
|
||||||
+ x = 0;
|
|
||||||
+ for (text = s = stext; *s; s++) {
|
|
||||||
+ if ((unsigned char)(*s) < ' ') {
|
|
||||||
+ ch = *s;
|
|
||||||
+ *s = '\0';
|
|
||||||
+ tw = TEXTW(text) - lrpad;
|
|
||||||
+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
|
||||||
+ x += tw;
|
|
||||||
+ *s = ch;
|
|
||||||
+ text = s + 1;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ tw = TEXTW(text) - lrpad + 2;
|
|
||||||
+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
|
||||||
+ tw = statusw;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
|
||||||
@@ -1645,6 +1687,17 @@ spawn(const Arg *arg)
|
|
||||||
if (fork() == 0) {
|
|
||||||
if (dpy)
|
|
||||||
close(ConnectionNumber(dpy));
|
|
||||||
+ if (arg->v == statuscmd) {
|
|
||||||
+ for (int i = 0; i < LENGTH(statuscmds); i++) {
|
|
||||||
+ if (statuscmdn == statuscmds[i].id) {
|
|
||||||
+ statuscmd[2] = statuscmds[i].cmd;
|
|
||||||
+ setenv("BUTTON", lastbutton, 1);
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ if (!statuscmd[2])
|
|
||||||
+ exit(EXIT_SUCCESS);
|
|
||||||
+ }
|
|
||||||
setsid();
|
|
||||||
execvp(((char **)arg->v)[0], (char **)arg->v);
|
|
||||||
fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
|
|
||||||
@@ -1990,8 +2043,23 @@ updatesizehints(Client *c)
|
|
||||||
void
|
|
||||||
updatestatus(void)
|
|
||||||
{
|
|
||||||
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
|
||||||
+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
|
|
||||||
strcpy(stext, "dwm-"VERSION);
|
|
||||||
+ statusw = TEXTW(stext) - lrpad + 2;
|
|
||||||
+ } else {
|
|
||||||
+ char *text, *s, ch;
|
|
||||||
+ statusw = 0;
|
|
||||||
+ for (text = s = stext; *s; s++) {
|
|
||||||
+ if ((unsigned char)(*s) < ' ') {
|
|
||||||
+ ch = *s;
|
|
||||||
+ *s = '\0';
|
|
||||||
+ statusw += TEXTW(text) - lrpad;
|
|
||||||
+ *s = ch;
|
|
||||||
+ text = s + 1;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ statusw += TEXTW(text) - lrpad + 2;
|
|
||||||
+ }
|
|
||||||
drawbar(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.31.0
|
|
||||||
|
|
23
util.c
23
util.c
|
@ -6,9 +6,18 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
void
|
void *
|
||||||
die(const char *fmt, ...)
|
ecalloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if (!(p = calloc(nmemb, size)))
|
||||||
|
die("calloc:");
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
die(const char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
@ -24,13 +33,3 @@ die(const char *fmt, ...)
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
ecalloc(size_t nmemb, size_t size)
|
|
||||||
{
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
if (!(p = calloc(nmemb, size)))
|
|
||||||
die("calloc:");
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user