Compare commits
10 commits
970f376973
...
7099ce7011
Author | SHA1 | Date | |
---|---|---|---|
qugalet | 7099ce7011 | ||
5687f46964 | |||
061e9fe9a7 | |||
9f8855343c | |||
e81f17d4c1 | |||
348f6559ab | |||
712d6639ff | |||
89f9905714 | |||
ba56fe9fea | |||
50ad171eea |
10
Makefile
10
Makefile
|
@ -6,13 +6,7 @@ include config.mk
|
|||
SRC = drw.c dwm.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: options dwm
|
||||
|
||||
options:
|
||||
@echo dwm build options:
|
||||
@echo "CFLAGS = ${CFLAGS}"
|
||||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
all: dwm
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} $<
|
||||
|
@ -48,4 +42,4 @@ uninstall:
|
|||
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
||||
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||
|
||||
.PHONY: all options clean dist install uninstall
|
||||
.PHONY: all clean dist install uninstall
|
||||
|
|
48
config.def.h
48
config.def.h
|
@ -1,8 +1,16 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#define SESSION_FILE "/tmp/dwm-session"
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int gappx = 6; /* gaps between windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
static const int showsystray = 1; /* 0 means no systray */
|
||||
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" };
|
||||
|
@ -12,10 +20,26 @@ 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 col1[] = "#ffffff";
|
||||
static const char col2[] = "#ffffff";
|
||||
static const char col3[] = "#ffffff";
|
||||
static const char col4[] = "#ffffff";
|
||||
static const char col5[] = "#ffffff";
|
||||
static const char col6[] = "#ffffff";
|
||||
|
||||
enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
|
||||
SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
|
||||
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeCol1] = { col1, col_gray1, col_gray2 },
|
||||
[SchemeCol2] = { col2, col_gray1, col_gray2 },
|
||||
[SchemeCol3] = { col3, col_gray1, col_gray2 },
|
||||
[SchemeCol4] = { col4, col_gray1, col_gray2 },
|
||||
[SchemeCol5] = { col5, col_gray1, col_gray2 },
|
||||
[SchemeCol6] = { col6, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
|
@ -26,15 +50,17 @@ static const Rule rules[] = {
|
|||
* 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 },
|
||||
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
|
||||
{ "St", NULL, NULL, 0, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
|
||||
};
|
||||
|
||||
/* 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 resizehints = 0; /* 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[] = {
|
||||
|
@ -42,6 +68,7 @@ static const Layout layouts[] = {
|
|||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "[D]", deck },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
|
@ -56,7 +83,8 @@ static const Layout layouts[] = {
|
|||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||
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 const Key keys[] = {
|
||||
|
@ -76,6 +104,7 @@ static const Key keys[] = {
|
|||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
|
@ -94,6 +123,7 @@ static const Key keys[] = {
|
|||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
@ -103,7 +133,9 @@ static const 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, sigdwmblocks, {.i = 1} },
|
||||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
|
|
180
config.h
Normal file
180
config.h
Normal file
|
@ -0,0 +1,180 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
#define SESSION_FILE "/tmp/dwm-session"
|
||||
#define TERMINAL "alacritty"
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int gappx = 6; /* gaps between windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
// static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
static const int showsystray = 1; /* 0 means no systray */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
static const char *fonts[] = { "Fira Code:size=12", "Symbols Nerd Font:size=12" };
|
||||
static const char dmenufont[] = "Fira Code:size=12";
|
||||
static char normbgcolor[] = "#1d2021";
|
||||
static char normbordercolor[] = "#1d2021";
|
||||
static char normfgcolor[] = "#458588";
|
||||
static char selfgcolor[] = "#1d2021";
|
||||
static char selbordercolor[] = "#928374";
|
||||
static char selbgcolor[] = "#458588";
|
||||
static const char col1[] = "#ffffff";
|
||||
static const char col2[] = "#ffffff";
|
||||
static const char col3[] = "#ffffff";
|
||||
static const char col4[] = "#ffffff";
|
||||
static const char col5[] = "#ffffff";
|
||||
static const char col6[] = "#ffffff";
|
||||
|
||||
enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
|
||||
SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||
[SchemeCol1] = { col1, normbgcolor, normbordercolor },
|
||||
[SchemeCol2] = { col2, normbgcolor, normbordercolor },
|
||||
[SchemeCol3] = { col3, normbgcolor, normbordercolor },
|
||||
[SchemeCol4] = { col4, normbgcolor, normbordercolor },
|
||||
[SchemeCol5] = { col5, normbgcolor, normbordercolor },
|
||||
[SchemeCol6] = { col6, normbgcolor, normbordercolor },
|
||||
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||
|
||||
};
|
||||
|
||||
/* 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 isterminal noswallow monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "st-256color", NULL, NULL, 0, 0, 1, 0, -1 },
|
||||
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 0; /* 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 },
|
||||
{ "[D]", deck },
|
||||
};
|
||||
|
||||
/* 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/sh", "-c", cmd, NULL } }
|
||||
|
||||
#define STATUSBAR "dwmblocks"
|
||||
|
||||
|
||||
/* 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 *dmenucmd[] = { "rofi", "-show", "drun", NULL };
|
||||
static const char *termcmd[] = { TERMINAL, NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
|
||||
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_o, incnmaster, {.i = +1 } },
|
||||
{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_space, zoom, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY, XK_q, killclient, {0} },
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[3]} },
|
||||
// { 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} },
|
||||
{ MODKEY|ShiftMask, XK_r, quit, {1} },
|
||||
|
||||
{ MODKEY, XK_BackSpace, spawn, SHCMD("sysact") },
|
||||
{ MODKEY, XK_w, spawn, SHCMD("firefox") },
|
||||
|
||||
// media keys
|
||||
{ 0, XF86XK_AudioPlay, spawn, SHCMD("music_mode play") },
|
||||
{ 0|ShiftMask, XF86XK_AudioPlay, spawn, SHCMD("music_mode change-mode") },
|
||||
{ 0|ControlMask, XF86XK_AudioPlay, spawn, SHCMD("music_mode set-playerctl-player") },
|
||||
{ 0, XF86XK_AudioNext, spawn, SHCMD("music_mode next") },
|
||||
{ 0, XF86XK_AudioPrev, spawn, SHCMD("music_mode prev") },
|
||||
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pactl set-sink-volume 0 +5%") },
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pactl set-sink-volume 0 -5%") },
|
||||
{ 0, XF86XK_AudioMute, spawn, SHCMD("pactl set-sink-mute 0 toggle") },
|
||||
|
||||
// screenshot
|
||||
{ 0, XK_Print, spawn, SHCMD("screenshot full") },
|
||||
{ 0|ShiftMask, XK_Print, spawn, SHCMD("screenshot window") },
|
||||
{ 0|ControlMask, XK_Print, spawn, SHCMD("screenshot rect") },
|
||||
|
||||
// awful.key({ "Control" }, "Print", function() awful.spawn("screenshot rect") end,
|
||||
// { description = "screenshot rectangle", group = "screenshot" }),
|
||||
// awful.key({ "Shift" }, "Print", function() awful.spawn("screenshot window") end,
|
||||
// { description = "screenshot window", group = "screenshot" }),
|
||||
// awful.key({}, "Print", function() awful.spawn("screenshot full") end,
|
||||
// { description = "screenshot full screen", group = "screenshot" }),
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
|
||||
static 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, sigdwmblocks, {.i = 1} },
|
||||
{ ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||
{ ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
|
||||
{ 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} },
|
||||
};
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# dwm version
|
||||
VERSION = 6.3
|
||||
VERSION = 6.5
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
@ -20,13 +20,14 @@ FREETYPEINC = /usr/include/freetype2
|
|||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
#KVMLIB = -lkvm
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = ${LIBS}
|
||||
|
|
139
patches/1-dwm-restartsig-20180523-6.2.diff
Normal file
139
patches/1-dwm-restartsig-20180523-6.2.diff
Normal file
|
@ -0,0 +1,139 @@
|
|||
From 2991f37f0aaf44b9f9b11e7893ff0af8eb88f649 Mon Sep 17 00:00:00 2001
|
||||
From: Christopher Drelich <cd@cdrakka.com>
|
||||
Date: Wed, 23 May 2018 22:50:38 -0400
|
||||
Subject: [PATCH] Modifies quit to handle restarts and adds SIGHUP and SIGTERM
|
||||
handlers.
|
||||
|
||||
Modified quit() to restart if it receives arg .i = 1
|
||||
MOD+CTRL+SHIFT+Q was added to confid.def.h to do just that.
|
||||
|
||||
Signal handlers were handled for SIGHUP and SIGTERM.
|
||||
If dwm receives these signals it calls quit() with
|
||||
arg .i = to 1 or 0, respectively.
|
||||
|
||||
To restart dwm:
|
||||
MOD+CTRL+SHIFT+Q
|
||||
or
|
||||
kill -HUP dwmpid
|
||||
|
||||
To quit dwm cleanly:
|
||||
MOD+SHIFT+Q
|
||||
or
|
||||
kill -TERM dwmpid
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwm.1 | 10 ++++++++++
|
||||
dwm.c | 22 ++++++++++++++++++++++
|
||||
3 files changed, 33 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a9ac303..e559429 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -94,6 +94,7 @@ static Key keys[] = {
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||
+ { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
diff --git a/dwm.1 b/dwm.1
|
||||
index 13b3729..36a331c 100644
|
||||
--- a/dwm.1
|
||||
+++ b/dwm.1
|
||||
@@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view.
|
||||
.TP
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
+.TP
|
||||
+.B Mod1\-Control\-Shift\-q
|
||||
+Restart dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1\-Button1
|
||||
@@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
+.SH SIGNALS
|
||||
+.TP
|
||||
+.B SIGHUP - 1
|
||||
+Restart the dwm process.
|
||||
+.TP
|
||||
+.B SIGTERM - 15
|
||||
+Cleanly terminate the dwm process.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1),
|
||||
.BR st (1)
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index bb95e26..286eecd 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -205,6 +205,8 @@ static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
+static void sighup(int unused);
|
||||
+static void sigterm(int unused);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@@ -260,6 +262,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
static Atom wmatom[WMLast], netatom[NetLast];
|
||||
+static int restart = 0;
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
@@ -1248,6 +1251,7 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
+ if(arg->i) restart = 1;
|
||||
running = 0;
|
||||
}
|
||||
|
||||
@@ -1536,6 +1540,9 @@ setup(void)
|
||||
/* clean up any zombies immediately */
|
||||
sigchld(0);
|
||||
|
||||
+ signal(SIGHUP, sighup);
|
||||
+ signal(SIGTERM, sigterm);
|
||||
+
|
||||
/* init screen */
|
||||
screen = DefaultScreen(dpy);
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
@@ -1637,6 +1644,20 @@ sigchld(int unused)
|
||||
}
|
||||
|
||||
void
|
||||
+sighup(int unused)
|
||||
+{
|
||||
+ Arg a = {.i = 1};
|
||||
+ quit(&a);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+sigterm(int unused)
|
||||
+{
|
||||
+ Arg a = {.i = 0};
|
||||
+ quit(&a);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
if (arg->v == dmenucmd)
|
||||
@@ -2139,6 +2160,7 @@ main(int argc, char *argv[])
|
||||
setup();
|
||||
scan();
|
||||
run();
|
||||
+ if(restart) execvp(argv[0], argv);
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
return EXIT_SUCCESS;
|
||||
--
|
||||
2.7.4
|
||||
|
177
patches/2-dwm-pertag-20200914-61bb8b2.diff
Normal file
177
patches/2-dwm-pertag-20200914-61bb8b2.diff
Normal file
|
@ -0,0 +1,177 @@
|
|||
diff --git a/dwm.c b/dwm.c
|
||||
index 664c527..ac8e4ec 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -111,6 +111,7 @@ typedef struct {
|
||||
void (*arrange)(Monitor *);
|
||||
} Layout;
|
||||
|
||||
+typedef struct Pertag Pertag;
|
||||
struct Monitor {
|
||||
char ltsymbol[16];
|
||||
float mfact;
|
||||
@@ -130,6 +131,7 @@ struct Monitor {
|
||||
Monitor *next;
|
||||
Window barwin;
|
||||
const Layout *lt[2];
|
||||
+ Pertag *pertag;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -272,6 +274,15 @@ 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 */
|
||||
+};
|
||||
+
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
@@ -632,6 +643,7 @@ Monitor *
|
||||
createmon(void)
|
||||
{
|
||||
Monitor *m;
|
||||
+ unsigned int i;
|
||||
|
||||
m = ecalloc(1, sizeof(Monitor));
|
||||
m->tagset[0] = m->tagset[1] = 1;
|
||||
@@ -642,6 +654,20 @@ 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;
|
||||
+ }
|
||||
+
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -967,7 +993,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);
|
||||
}
|
||||
|
||||
@@ -1502,9 +1528,9 @@ 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 +1549,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);
|
||||
}
|
||||
|
||||
@@ -1702,7 +1728,7 @@ tile(Monitor *m)
|
||||
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 +1767,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 +2088,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);
|
||||
}
|
101
patches/3-dwm-restoreafterrestart-20220709-d3f93c7.diff
Normal file
101
patches/3-dwm-restoreafterrestart-20220709-d3f93c7.diff
Normal file
|
@ -0,0 +1,101 @@
|
|||
From 9fd4a02b57aa8a764d8105d5f2f854372f4ef559 Mon Sep 17 00:00:00 2001
|
||||
From: ViliamKovac1223 <viliamkovac1223@gmail.com>
|
||||
Date: Sat, 9 Jul 2022 17:35:54 +0200
|
||||
Subject: [PATCH] add restore patch
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 55 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 6ec4146..0b91976 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -1,5 +1,7 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
+#define SESSION_FILE "/tmp/dwm-session"
|
||||
+
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 74cec7e..76b40a2 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -1255,11 +1255,63 @@ propertynotify(XEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+saveSession(void)
|
||||
+{
|
||||
+ FILE *fw = fopen(SESSION_FILE, "w");
|
||||
+ for (Client *c = selmon->clients; c != NULL; c = c->next) { // get all the clients with their tags and write them to the file
|
||||
+ fprintf(fw, "%lu %u\n", c->win, c->tags);
|
||||
+ }
|
||||
+ fclose(fw);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+restoreSession(void)
|
||||
+{
|
||||
+ // restore session
|
||||
+ FILE *fr = fopen(SESSION_FILE, "r");
|
||||
+ if (!fr)
|
||||
+ return;
|
||||
+
|
||||
+ char *str = malloc(23 * sizeof(char)); // allocate enough space for excepted input from text file
|
||||
+ while (fscanf(fr, "%[^\n] ", str) != EOF) { // read file till the end
|
||||
+ long unsigned int winId;
|
||||
+ unsigned int tagsForWin;
|
||||
+ int check = sscanf(str, "%lu %u", &winId, &tagsForWin); // get data
|
||||
+ if (check != 2) // break loop if data wasn't read correctly
|
||||
+ break;
|
||||
+
|
||||
+ for (Client *c = selmon->clients; c ; c = c->next) { // add tags to every window by winId
|
||||
+ if (c->win == winId) {
|
||||
+ c->tags = tagsForWin;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (Client *c = selmon->clients; c ; c = c->next) { // refocus on windows
|
||||
+ focus(c);
|
||||
+ restack(c->mon);
|
||||
+ }
|
||||
+
|
||||
+ for (Monitor *m = selmon; m; m = m->next) // rearrange all monitors
|
||||
+ arrange(m);
|
||||
+
|
||||
+ free(str);
|
||||
+ fclose(fr);
|
||||
+
|
||||
+ // delete a file
|
||||
+ remove(SESSION_FILE);
|
||||
+}
|
||||
+
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
if(arg->i) restart = 1;
|
||||
running = 0;
|
||||
+
|
||||
+ if (restart == 1)
|
||||
+ saveSession();
|
||||
}
|
||||
|
||||
Monitor *
|
||||
@@ -2173,6 +2225,7 @@ main(int argc, char *argv[])
|
||||
die("pledge");
|
||||
#endif /* __OpenBSD__ */
|
||||
scan();
|
||||
+ restoreSession();
|
||||
run();
|
||||
if(restart) execvp(argv[0], argv);
|
||||
cleanup();
|
||||
--
|
||||
2.35.1
|
||||
|
187
patches/4-dwm-bartabgroups-20210802-138b405.diff
Normal file
187
patches/4-dwm-bartabgroups-20210802-138b405.diff
Normal file
|
@ -0,0 +1,187 @@
|
|||
From 653c99b94cc780a2def9c7e50a87703156535f8b Mon Sep 17 00:00:00 2001
|
||||
From: Jack Bird <jack.bird@durham.ac.uk>
|
||||
Date: Mon, 2 Aug 2021 18:50:02 +0100
|
||||
Subject: [PATCH] bartabgroups updated to work with 138b405
|
||||
|
||||
---
|
||||
config.def.h | 11 +++++
|
||||
dwm.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
2 files changed, 112 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..82accf1 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -16,6 +16,8 @@ static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
+ [SchemeTabActive] = { col_gray2, col_gray3, col_gray2 },
|
||||
+ [SchemeTabInactive] = { col_gray1, col_gray3, col_gray1 }
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@@ -37,6 +39,15 @@ 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 */
|
||||
|
||||
+/* Bartabgroups properties */
|
||||
+#define BARTAB_BORDERS 1 // 0 = off, 1 = on
|
||||
+#define BARTAB_BOTTOMBORDER 1 // 0 = off, 1 = on
|
||||
+#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on
|
||||
+#define BARTAB_TAGSPX 5 // # pixels for tag grid boxes
|
||||
+#define BARTAB_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3)
|
||||
+static void (*bartabmonfns[])(Monitor *) = { monocle /* , customlayoutfn */ };
|
||||
+static void (*bartabfloatfns[])(Monitor *) = { NULL /* , customlayoutfn */ };
|
||||
+
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..1839a56 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
-enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeTabActive, SchemeTabInactive }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
@@ -378,6 +378,98 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact)
|
||||
return *x != c->x || *y != c->y || *w != c->w || *h != c->h;
|
||||
}
|
||||
|
||||
+void
|
||||
+bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive) {
|
||||
+ if (!c) return;
|
||||
+ int i, nclienttags = 0, nviewtags = 0;
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[
|
||||
+ m->sel == c ? SchemeSel : (groupactive ? SchemeTabActive: SchemeTabInactive)
|
||||
+ ]);
|
||||
+ drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0);
|
||||
+
|
||||
+ // Floating win indicator
|
||||
+ if (c->isfloating) drw_rect(drw, x + 2, 2, 5, 5, 0, 0);
|
||||
+
|
||||
+ // Optional borders between tabs
|
||||
+ if (BARTAB_BORDERS) {
|
||||
+ XSetForeground(drw->dpy, drw->gc, drw->scheme[ColBorder].pixel);
|
||||
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, 0, 1, bh);
|
||||
+ XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w, 0, 1, bh);
|
||||
+ }
|
||||
+
|
||||
+ // Optional tags icons
|
||||
+ for (i = 0; i < LENGTH(tags); i++) {
|
||||
+ if ((m->tagset[m->seltags] >> i) & 1) { nviewtags++; }
|
||||
+ if ((c->tags >> i) & 1) { nclienttags++; }
|
||||
+ }
|
||||
+ if (BARTAB_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1) {
|
||||
+ for (i = 0; i < LENGTH(tags); i++) {
|
||||
+ drw_rect(drw,
|
||||
+ ( x + w - 2 - ((LENGTH(tags) / BARTAB_TAGSROWS) * BARTAB_TAGSPX)
|
||||
+ - (i % (LENGTH(tags)/BARTAB_TAGSROWS)) + ((i % (LENGTH(tags) / BARTAB_TAGSROWS)) * BARTAB_TAGSPX)
|
||||
+ ),
|
||||
+ ( 2 + ((i / (LENGTH(tags)/BARTAB_TAGSROWS)) * BARTAB_TAGSPX)
|
||||
+ - ((i / (LENGTH(tags)/BARTAB_TAGSROWS)))
|
||||
+ ),
|
||||
+ BARTAB_TAGSPX, BARTAB_TAGSPX, (c->tags >> i) & 1, 0
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+battabclick(Monitor *m, Client *c, int passx, int x, int w, int unused) {
|
||||
+ if (passx >= x && passx <= x + w) {
|
||||
+ focus(c);
|
||||
+ restack(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+bartabcalculate(
|
||||
+ Monitor *m, int offx, int sw, int passx,
|
||||
+ void(*tabfn)(Monitor *, Client *, int, int, int, int)
|
||||
+) {
|
||||
+ Client *c;
|
||||
+ int
|
||||
+ i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0,
|
||||
+ masteractive = 0, fulllayout = 0, floatlayout = 0,
|
||||
+ x, w, tgactive;
|
||||
+
|
||||
+ for (i = 0, c = m->clients; c; c = c->next) {
|
||||
+ if (!ISVISIBLE(c)) continue;
|
||||
+ if (c->isfloating) { clientsnfloating++; continue; }
|
||||
+ if (m->sel == c) { masteractive = i < m->nmaster; }
|
||||
+ if (i < m->nmaster) { clientsnmaster++; } else { clientsnstack++; }
|
||||
+ i++;
|
||||
+ }
|
||||
+ for (i = 0; i < LENGTH(bartabfloatfns); i++) if (m ->lt[m->sellt]->arrange == bartabfloatfns[i]) { floatlayout = 1; break; }
|
||||
+ for (i = 0; i < LENGTH(bartabmonfns); i++) if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) { fulllayout = 1; break; }
|
||||
+ for (c = m->clients, i = 0; c; c = c->next) {
|
||||
+ if (!ISVISIBLE(c)) continue;
|
||||
+ if (clientsnmaster + clientsnstack == 0 || floatlayout) {
|
||||
+ x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating)) * i);
|
||||
+ w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack + clientsnfloating);
|
||||
+ tgactive = 1;
|
||||
+ } else if (!c->isfloating && (fulllayout || ((clientsnmaster == 0) ^ (clientsnstack == 0)))) {
|
||||
+ x = offx + (((m->mw - offx - sw) / (clientsnmaster + clientsnstack)) * i);
|
||||
+ w = (m->mw - offx - sw) / (clientsnmaster + clientsnstack);
|
||||
+ tgactive = 1;
|
||||
+ } else if (i < m->nmaster && !c->isfloating) {
|
||||
+ x = offx + ((((m->mw * m->mfact) - offx) /clientsnmaster) * i);
|
||||
+ w = ((m->mw * m->mfact) - offx) / clientsnmaster;
|
||||
+ tgactive = masteractive;
|
||||
+ } else if (!c->isfloating) {
|
||||
+ x = (m->mw * m->mfact) + ((((m->mw * (1 - m->mfact)) - sw) / clientsnstack) * (i - m->nmaster));
|
||||
+ w = ((m->mw * (1 - m->mfact)) - sw) / clientsnstack;
|
||||
+ tgactive = !masteractive;
|
||||
+ } else continue;
|
||||
+ tabfn(m, c, passx, x, w, tgactive);
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
arrange(Monitor *m)
|
||||
{
|
||||
@@ -442,8 +534,8 @@ buttonpress(XEvent *e)
|
||||
click = ClkLtSymbol;
|
||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
click = ClkStatusText;
|
||||
- else
|
||||
- click = ClkWinTitle;
|
||||
+ else // Focus clicked tab bar item
|
||||
+ bartabcalculate(selmon, x, TEXTW(stext) - lrpad + 2, ev->x, battabclick);
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
@@ -729,15 +821,13 @@ drawbar(Monitor *m)
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
+ // Draw bartabgroups
|
||||
+ drw_rect(drw, x, 0, m->ww - tw - x, bh, 1, 1);
|
||||
if ((w = m->ww - tw - x) > bh) {
|
||||
- if (m->sel) {
|
||||
- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
- if (m->sel->isfloating)
|
||||
- drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||
- } else {
|
||||
- drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
- drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
+ bartabcalculate(m, x, tw, -1, bartabdraw);
|
||||
+ if (BARTAB_BOTTOMBORDER) {
|
||||
+ drw_setscheme(drw, scheme[SchemeTabActive]);
|
||||
+ drw_rect(drw, 0, bh - 1, m->ww, 1, 1, 0);
|
||||
}
|
||||
}
|
||||
drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||
--
|
||||
2.32.0
|
||||
|
77
patches/5-dwm-deck-6.2.diff
Normal file
77
patches/5-dwm-deck-6.2.diff
Normal file
|
@ -0,0 +1,77 @@
|
|||
From a071b060a1b9b94bcb167b988cf7774ceb870aad Mon Sep 17 00:00:00 2001
|
||||
From: Jack Bird <jack.bird@durham.ac.uk>
|
||||
Date: Mon, 2 Aug 2021 18:44:05 +0100
|
||||
Subject: [PATCH] deck patch works with 6.2
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwm.c | 26 ++++++++++++++++++++++++++
|
||||
2 files changed, 28 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..d865e18 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -42,6 +42,7 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "[D]", deck },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
@@ -77,6 +78,7 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XK_r, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..c67ff91 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -157,6 +157,7 @@ static void configure(Client *c);
|
||||
static void configurenotify(XEvent *e);
|
||||
static void configurerequest(XEvent *e);
|
||||
static Monitor *createmon(void);
|
||||
+static void deck(Monitor *m);
|
||||
static void destroynotify(XEvent *e);
|
||||
static void detach(Client *c);
|
||||
static void detachstack(Client *c);
|
||||
@@ -655,6 +656,31 @@ destroynotify(XEvent *e)
|
||||
unmanage(c, 1);
|
||||
}
|
||||
|
||||
+void
|
||||
+deck(Monitor *m) {
|
||||
+ unsigned int i, n, h, mw, my;
|
||||
+ Client *c;
|
||||
+
|
||||
+ 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;
|
||||
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
|
||||
+ }
|
||||
+ else
|
||||
+ mw = m->ww;
|
||||
+ for(i = my = 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), False);
|
||||
+ my += HEIGHT(c);
|
||||
+ }
|
||||
+ else
|
||||
+ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False);
|
||||
+}
|
||||
+
|
||||
void
|
||||
detach(Client *c)
|
||||
{
|
||||
--
|
||||
2.32.0
|
||||
|
735
patches/6-dwm-systray-20230922-9f88553.diff
Normal file
735
patches/6-dwm-systray-20230922-9f88553.diff
Normal file
|
@ -0,0 +1,735 @@
|
|||
diff --git a/config.def.h b/config.def.h
|
||||
index 9efa774..fed4fb9 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -3,6 +3,11 @@
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
+static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
+static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
+static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
+static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
+static const int showsystray = 1; /* 0 means no systray */
|
||||
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" };
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index f1d86b2..f9e7e4a 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -57,12 +57,27 @@
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
+#define SYSTEM_TRAY_REQUEST_DOCK 0
|
||||
+/* XEMBED messages */
|
||||
+#define XEMBED_EMBEDDED_NOTIFY 0
|
||||
+#define XEMBED_WINDOW_ACTIVATE 1
|
||||
+#define XEMBED_FOCUS_IN 4
|
||||
+#define XEMBED_MODALITY_ON 10
|
||||
+#define XEMBED_MAPPED (1 << 0)
|
||||
+#define XEMBED_WINDOW_ACTIVATE 1
|
||||
+#define XEMBED_WINDOW_DEACTIVATE 2
|
||||
+#define VERSION_MAJOR 0
|
||||
+#define VERSION_MINOR 0
|
||||
+#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
|
||||
+
|
||||
/* enums */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
+ NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
|
||||
+enum { Manager, Xembed, XembedInfo, XLast }; /* Xembed atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
|
||||
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
|
||||
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
|
||||
@@ -141,6 +156,12 @@ typedef struct {
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
+typedef struct Systray Systray;
|
||||
+struct Systray {
|
||||
+ Window win;
|
||||
+ Client *icons;
|
||||
+};
|
||||
+
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
@@ -172,6 +193,7 @@ 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 unsigned int getsystraywidth();
|
||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
static void grabbuttons(Client *c, int focused);
|
||||
static void grabkeys(void);
|
||||
@@ -189,13 +211,16 @@ static void pop(Client *c);
|
||||
static void propertynotify(XEvent *e);
|
||||
static void quit(const Arg *arg);
|
||||
static Monitor *recttomon(int x, int y, int w, int h);
|
||||
+static void removesystrayicon(Client *i);
|
||||
static void resize(Client *c, int x, int y, int w, int h, int interact);
|
||||
+static void resizebarwin(Monitor *m);
|
||||
static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||
static void resizemouse(const Arg *arg);
|
||||
+static void resizerequest(XEvent *e);
|
||||
static void restack(Monitor *m);
|
||||
static void run(void);
|
||||
static void scan(void);
|
||||
-static int sendevent(Client *c, Atom proto);
|
||||
+static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, long d3, long d4);
|
||||
static void sendmon(Client *c, Monitor *m);
|
||||
static void setclientstate(Client *c, long state);
|
||||
static void setfocus(Client *c);
|
||||
@@ -206,6 +231,7 @@ static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void spawn(const Arg *arg);
|
||||
+static Monitor *systraytomon(Monitor *m);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
@@ -223,18 +249,23 @@ static int updategeom(void);
|
||||
static void updatenumlockmask(void);
|
||||
static void updatesizehints(Client *c);
|
||||
static void updatestatus(void);
|
||||
+static void updatesystray(void);
|
||||
+static void updatesystrayicongeom(Client *i, int w, int h);
|
||||
+static void updatesystrayiconstate(Client *i, XPropertyEvent *ev);
|
||||
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 Client *wintosystrayicon(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 Systray *systray = NULL;
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
static int screen;
|
||||
@@ -257,9 +288,10 @@ static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[MapRequest] = maprequest,
|
||||
[MotionNotify] = motionnotify,
|
||||
[PropertyNotify] = propertynotify,
|
||||
+ [ResizeRequest] = resizerequest,
|
||||
[UnmapNotify] = unmapnotify
|
||||
};
|
||||
-static Atom wmatom[WMLast], netatom[NetLast];
|
||||
+static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
|
||||
static int running = 1;
|
||||
static Cur *cursor[CurLast];
|
||||
static Clr **scheme;
|
||||
@@ -441,7 +473,7 @@ buttonpress(XEvent *e)
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||
click = ClkLtSymbol;
|
||||
- else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||
+ else if (ev->x > selmon->ww - (int)TEXTW(stext) - getsystraywidth())
|
||||
click = ClkStatusText;
|
||||
else
|
||||
click = ClkWinTitle;
|
||||
@@ -484,6 +516,13 @@ cleanup(void)
|
||||
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||
while (mons)
|
||||
cleanupmon(mons);
|
||||
+
|
||||
+ if (showsystray) {
|
||||
+ XUnmapWindow(dpy, systray->win);
|
||||
+ XDestroyWindow(dpy, systray->win);
|
||||
+ free(systray);
|
||||
+ }
|
||||
+
|
||||
for (i = 0; i < CurLast; i++)
|
||||
drw_cur_free(drw, cursor[i]);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
@@ -515,9 +554,58 @@ cleanupmon(Monitor *mon)
|
||||
void
|
||||
clientmessage(XEvent *e)
|
||||
{
|
||||
+ XWindowAttributes wa;
|
||||
+ XSetWindowAttributes swa;
|
||||
XClientMessageEvent *cme = &e->xclient;
|
||||
Client *c = wintoclient(cme->window);
|
||||
|
||||
+ if (showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) {
|
||||
+ /* add systray icons */
|
||||
+ if (cme->data.l[1] == SYSTEM_TRAY_REQUEST_DOCK) {
|
||||
+ if (!(c = (Client *)calloc(1, sizeof(Client))))
|
||||
+ die("fatal: could not malloc() %u bytes\n", sizeof(Client));
|
||||
+ if (!(c->win = cme->data.l[2])) {
|
||||
+ free(c);
|
||||
+ return;
|
||||
+ }
|
||||
+ c->mon = selmon;
|
||||
+ c->next = systray->icons;
|
||||
+ systray->icons = c;
|
||||
+ if (!XGetWindowAttributes(dpy, c->win, &wa)) {
|
||||
+ /* use sane defaults */
|
||||
+ wa.width = bh;
|
||||
+ wa.height = bh;
|
||||
+ wa.border_width = 0;
|
||||
+ }
|
||||
+ c->x = c->oldx = c->y = c->oldy = 0;
|
||||
+ c->w = c->oldw = wa.width;
|
||||
+ c->h = c->oldh = wa.height;
|
||||
+ c->oldbw = wa.border_width;
|
||||
+ c->bw = 0;
|
||||
+ c->isfloating = True;
|
||||
+ /* reuse tags field as mapped status */
|
||||
+ c->tags = 1;
|
||||
+ updatesizehints(c);
|
||||
+ updatesystrayicongeom(c, wa.width, wa.height);
|
||||
+ XAddToSaveSet(dpy, c->win);
|
||||
+ XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
|
||||
+ XReparentWindow(dpy, c->win, systray->win, 0, 0);
|
||||
+ /* use parents background color */
|
||||
+ swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
+ XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa);
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ /* FIXME not sure if I have to send these events, too */
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_FOCUS_IN, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_MODALITY_ON, 0 , systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ XSync(dpy, False);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ setclientstate(c, NormalState);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (!c)
|
||||
return;
|
||||
if (cme->message_type == netatom[NetWMState]) {
|
||||
@@ -570,7 +658,7 @@ configurenotify(XEvent *e)
|
||||
for (c = m->clients; c; c = c->next)
|
||||
if (c->isfullscreen)
|
||||
resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||
- XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||
+ resizebarwin(m);
|
||||
}
|
||||
focus(NULL);
|
||||
arrange(NULL);
|
||||
@@ -655,6 +743,11 @@ destroynotify(XEvent *e)
|
||||
|
||||
if ((c = wintoclient(ev->window)))
|
||||
unmanage(c, 1);
|
||||
+ else if ((c = wintosystrayicon(ev->window))) {
|
||||
+ removesystrayicon(c);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -698,7 +791,7 @@ dirtomon(int dir)
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
- int x, w, tw = 0;
|
||||
+ int x, w, tw = 0, stw = 0;
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
@@ -707,13 +800,17 @@ drawbar(Monitor *m)
|
||||
if (!m->showbar)
|
||||
return;
|
||||
|
||||
+ if(showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
+ stw = getsystraywidth();
|
||||
+
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
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);
|
||||
+ tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px extra right padding */
|
||||
+ drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
|
||||
}
|
||||
|
||||
+ resizebarwin(m);
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
@@ -734,7 +831,7 @@ drawbar(Monitor *m)
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
- if ((w = m->ww - tw - x) > bh) {
|
||||
+ if ((w = m->ww - tw - stw - x) > bh) {
|
||||
if (m->sel) {
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
@@ -745,7 +842,7 @@ drawbar(Monitor *m)
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
}
|
||||
}
|
||||
- drw_map(drw, m->barwin, 0, 0, m->ww, bh);
|
||||
+ drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -782,8 +879,11 @@ expose(XEvent *e)
|
||||
Monitor *m;
|
||||
XExposeEvent *ev = &e->xexpose;
|
||||
|
||||
- if (ev->count == 0 && (m = wintomon(ev->window)))
|
||||
+ if (ev->count == 0 && (m = wintomon(ev->window))) {
|
||||
drawbar(m);
|
||||
+ if (m == selmon)
|
||||
+ updatesystray();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -869,14 +969,32 @@ getatomprop(Client *c, Atom prop)
|
||||
unsigned char *p = NULL;
|
||||
Atom da, atom = None;
|
||||
|
||||
- if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
||||
+ /* FIXME getatomprop should return the number of items and a pointer to
|
||||
+ * the stored data instead of this workaround */
|
||||
+ Atom req = XA_ATOM;
|
||||
+ if (prop == xatom[XembedInfo])
|
||||
+ req = xatom[XembedInfo];
|
||||
+
|
||||
+ if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, req,
|
||||
&da, &di, &dl, &dl, &p) == Success && p) {
|
||||
atom = *(Atom *)p;
|
||||
+ if (da == xatom[XembedInfo] && dl == 2)
|
||||
+ atom = ((Atom *)p)[1];
|
||||
XFree(p);
|
||||
}
|
||||
return atom;
|
||||
}
|
||||
|
||||
+unsigned int
|
||||
+getsystraywidth()
|
||||
+{
|
||||
+ unsigned int w = 0;
|
||||
+ Client *i;
|
||||
+ if(showsystray)
|
||||
+ for(i = systray->icons; i; w += i->w + systrayspacing, i = i->next) ;
|
||||
+ return w ? w + systrayspacing : 1;
|
||||
+}
|
||||
+
|
||||
int
|
||||
getrootptr(int *x, int *y)
|
||||
{
|
||||
@@ -1017,7 +1135,8 @@ killclient(const Arg *arg)
|
||||
{
|
||||
if (!selmon->sel)
|
||||
return;
|
||||
- if (!sendevent(selmon->sel, wmatom[WMDelete])) {
|
||||
+
|
||||
+ if (!sendevent(selmon->sel->win, wmatom[WMDelete], NoEventMask, wmatom[WMDelete], CurrentTime, 0 , 0, 0)) {
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
XSetCloseDownMode(dpy, DestroyAll);
|
||||
@@ -1104,6 +1223,13 @@ maprequest(XEvent *e)
|
||||
static XWindowAttributes wa;
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
|
||||
+ Client *i;
|
||||
+ if ((i = wintosystrayicon(ev->window))) {
|
||||
+ sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime, XEMBED_WINDOW_ACTIVATE, 0, systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
+
|
||||
if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
|
||||
return;
|
||||
if (!wintoclient(ev->window))
|
||||
@@ -1225,6 +1351,17 @@ propertynotify(XEvent *e)
|
||||
Window trans;
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
|
||||
+ if ((c = wintosystrayicon(ev->window))) {
|
||||
+ if (ev->atom == XA_WM_NORMAL_HINTS) {
|
||||
+ updatesizehints(c);
|
||||
+ updatesystrayicongeom(c, c->w, c->h);
|
||||
+ }
|
||||
+ else
|
||||
+ updatesystrayiconstate(c, ev);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
+
|
||||
if ((ev->window == root) && (ev->atom == XA_WM_NAME))
|
||||
updatestatus();
|
||||
else if (ev->state == PropertyDelete)
|
||||
@@ -1275,6 +1412,19 @@ recttomon(int x, int y, int w, int h)
|
||||
return r;
|
||||
}
|
||||
|
||||
+void
|
||||
+removesystrayicon(Client *i)
|
||||
+{
|
||||
+ Client **ii;
|
||||
+
|
||||
+ if (!showsystray || !i)
|
||||
+ return;
|
||||
+ for (ii = &systray->icons; *ii && *ii != i; ii = &(*ii)->next);
|
||||
+ if (ii)
|
||||
+ *ii = i->next;
|
||||
+ free(i);
|
||||
+}
|
||||
+
|
||||
void
|
||||
resize(Client *c, int x, int y, int w, int h, int interact)
|
||||
{
|
||||
@@ -1282,6 +1432,14 @@ resize(Client *c, int x, int y, int w, int h, int interact)
|
||||
resizeclient(c, x, y, w, h);
|
||||
}
|
||||
|
||||
+void
|
||||
+resizebarwin(Monitor *m) {
|
||||
+ unsigned int w = m->ww;
|
||||
+ if (showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
+ w -= getsystraywidth();
|
||||
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
|
||||
+}
|
||||
+
|
||||
void
|
||||
resizeclient(Client *c, int x, int y, int w, int h)
|
||||
{
|
||||
@@ -1297,6 +1455,19 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
+void
|
||||
+resizerequest(XEvent *e)
|
||||
+{
|
||||
+ XResizeRequestEvent *ev = &e->xresizerequest;
|
||||
+ Client *i;
|
||||
+
|
||||
+ if ((i = wintosystrayicon(ev->window))) {
|
||||
+ updatesystrayicongeom(i, ev->width, ev->height);
|
||||
+ resizebarwin(selmon);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
resizemouse(const Arg *arg)
|
||||
{
|
||||
@@ -1443,26 +1614,37 @@ setclientstate(Client *c, long state)
|
||||
}
|
||||
|
||||
int
|
||||
-sendevent(Client *c, Atom proto)
|
||||
+sendevent(Window w, Atom proto, int mask, long d0, long d1, long d2, long d3, long d4)
|
||||
{
|
||||
int n;
|
||||
- Atom *protocols;
|
||||
+ Atom *protocols, mt;
|
||||
int exists = 0;
|
||||
XEvent ev;
|
||||
|
||||
- if (XGetWMProtocols(dpy, c->win, &protocols, &n)) {
|
||||
- while (!exists && n--)
|
||||
- exists = protocols[n] == proto;
|
||||
- XFree(protocols);
|
||||
+ if (proto == wmatom[WMTakeFocus] || proto == wmatom[WMDelete]) {
|
||||
+ mt = wmatom[WMProtocols];
|
||||
+ if (XGetWMProtocols(dpy, w, &protocols, &n)) {
|
||||
+ while (!exists && n--)
|
||||
+ exists = protocols[n] == proto;
|
||||
+ XFree(protocols);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ exists = True;
|
||||
+ mt = proto;
|
||||
}
|
||||
+
|
||||
if (exists) {
|
||||
ev.type = ClientMessage;
|
||||
- ev.xclient.window = c->win;
|
||||
- ev.xclient.message_type = wmatom[WMProtocols];
|
||||
+ ev.xclient.window = w;
|
||||
+ ev.xclient.message_type = mt;
|
||||
ev.xclient.format = 32;
|
||||
- ev.xclient.data.l[0] = proto;
|
||||
- ev.xclient.data.l[1] = CurrentTime;
|
||||
- XSendEvent(dpy, c->win, False, NoEventMask, &ev);
|
||||
+ ev.xclient.data.l[0] = d0;
|
||||
+ ev.xclient.data.l[1] = d1;
|
||||
+ ev.xclient.data.l[2] = d2;
|
||||
+ ev.xclient.data.l[3] = d3;
|
||||
+ ev.xclient.data.l[4] = d4;
|
||||
+ XSendEvent(dpy, w, False, mask, &ev);
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
@@ -1476,7 +1658,7 @@ setfocus(Client *c)
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
(unsigned char *) &(c->win), 1);
|
||||
}
|
||||
- sendevent(c, wmatom[WMTakeFocus]);
|
||||
+ sendevent(c->win, wmatom[WMTakeFocus], NoEventMask, wmatom[WMTakeFocus], CurrentTime, 0, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1572,6 +1754,10 @@ setup(void)
|
||||
wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
|
||||
netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
|
||||
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
+ netatom[NetSystemTray] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_S0", False);
|
||||
+ netatom[NetSystemTrayOP] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False);
|
||||
+ netatom[NetSystemTrayOrientation] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION", False);
|
||||
+ netatom[NetSystemTrayOrientationHorz] = XInternAtom(dpy, "_NET_SYSTEM_TRAY_ORIENTATION_HORZ", False);
|
||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
|
||||
netatom[NetWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
|
||||
@@ -1579,6 +1765,9 @@ setup(void)
|
||||
netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
|
||||
netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
|
||||
+ xatom[Manager] = XInternAtom(dpy, "MANAGER", False);
|
||||
+ xatom[Xembed] = XInternAtom(dpy, "_XEMBED", False);
|
||||
+ xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
@@ -1587,6 +1776,8 @@ setup(void)
|
||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||
+ /* init system tray */
|
||||
+ updatesystray();
|
||||
/* init bars */
|
||||
updatebars();
|
||||
updatestatus();
|
||||
@@ -1717,7 +1908,18 @@ togglebar(const Arg *arg)
|
||||
{
|
||||
selmon->showbar = !selmon->showbar;
|
||||
updatebarpos(selmon);
|
||||
- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
|
||||
+ resizebarwin(selmon);
|
||||
+ if (showsystray) {
|
||||
+ XWindowChanges wc;
|
||||
+ if (!selmon->showbar)
|
||||
+ wc.y = -bh;
|
||||
+ else if (selmon->showbar) {
|
||||
+ wc.y = 0;
|
||||
+ if (!selmon->topbar)
|
||||
+ wc.y = selmon->mh - bh;
|
||||
+ }
|
||||
+ XConfigureWindow(dpy, systray->win, CWY, &wc);
|
||||
+ }
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1813,11 +2015,18 @@ unmapnotify(XEvent *e)
|
||||
else
|
||||
unmanage(c, 0);
|
||||
}
|
||||
+ else if ((c = wintosystrayicon(ev->window))) {
|
||||
+ /* KLUDGE! sometimes icons occasionally unmap their windows, but do
|
||||
+ * _not_ destroy them. We map those windows back */
|
||||
+ XMapRaised(dpy, c->win);
|
||||
+ updatesystray();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
updatebars(void)
|
||||
{
|
||||
+ unsigned int w;
|
||||
Monitor *m;
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
@@ -1828,10 +2037,15 @@ updatebars(void)
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m->barwin)
|
||||
continue;
|
||||
- m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
|
||||
+ w = m->ww;
|
||||
+ if (showsystray && m == systraytomon(m))
|
||||
+ w -= getsystraywidth();
|
||||
+ m->barwin = XCreateWindow(dpy, root, m->wx, m->by, w, bh, 0, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||
XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
|
||||
+ if (showsystray && m == systraytomon(m))
|
||||
+ XMapRaised(dpy, systray->win);
|
||||
XMapRaised(dpy, m->barwin);
|
||||
XSetClassHint(dpy, m->barwin, &ch);
|
||||
}
|
||||
@@ -2008,6 +2222,125 @@ updatestatus(void)
|
||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
drawbar(selmon);
|
||||
+ updatesystray();
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void
|
||||
+updatesystrayicongeom(Client *i, int w, int h)
|
||||
+{
|
||||
+ if (i) {
|
||||
+ i->h = bh;
|
||||
+ if (w == h)
|
||||
+ i->w = bh;
|
||||
+ else if (h == bh)
|
||||
+ i->w = w;
|
||||
+ else
|
||||
+ i->w = (int) ((float)bh * ((float)w / (float)h));
|
||||
+ applysizehints(i, &(i->x), &(i->y), &(i->w), &(i->h), False);
|
||||
+ /* force icons into the systray dimensions if they don't want to */
|
||||
+ if (i->h > bh) {
|
||||
+ if (i->w == i->h)
|
||||
+ i->w = bh;
|
||||
+ else
|
||||
+ i->w = (int) ((float)bh * ((float)i->w / (float)i->h));
|
||||
+ i->h = bh;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+updatesystrayiconstate(Client *i, XPropertyEvent *ev)
|
||||
+{
|
||||
+ long flags;
|
||||
+ int code = 0;
|
||||
+
|
||||
+ if (!showsystray || !i || ev->atom != xatom[XembedInfo] ||
|
||||
+ !(flags = getatomprop(i, xatom[XembedInfo])))
|
||||
+ return;
|
||||
+
|
||||
+ if (flags & XEMBED_MAPPED && !i->tags) {
|
||||
+ i->tags = 1;
|
||||
+ code = XEMBED_WINDOW_ACTIVATE;
|
||||
+ XMapRaised(dpy, i->win);
|
||||
+ setclientstate(i, NormalState);
|
||||
+ }
|
||||
+ else if (!(flags & XEMBED_MAPPED) && i->tags) {
|
||||
+ i->tags = 0;
|
||||
+ code = XEMBED_WINDOW_DEACTIVATE;
|
||||
+ XUnmapWindow(dpy, i->win);
|
||||
+ setclientstate(i, WithdrawnState);
|
||||
+ }
|
||||
+ else
|
||||
+ return;
|
||||
+ sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime, code, 0,
|
||||
+ systray->win, XEMBED_EMBEDDED_VERSION);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+updatesystray(void)
|
||||
+{
|
||||
+ XSetWindowAttributes wa;
|
||||
+ XWindowChanges wc;
|
||||
+ Client *i;
|
||||
+ Monitor *m = systraytomon(NULL);
|
||||
+ unsigned int x = m->mx + m->mw;
|
||||
+ unsigned int sw = TEXTW(stext) - lrpad + systrayspacing;
|
||||
+ unsigned int w = 1;
|
||||
+
|
||||
+ if (!showsystray)
|
||||
+ return;
|
||||
+ if (systrayonleft)
|
||||
+ x -= sw + lrpad / 2;
|
||||
+ if (!systray) {
|
||||
+ /* init systray */
|
||||
+ if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
|
||||
+ die("fatal: could not malloc() %u bytes\n", sizeof(Systray));
|
||||
+ systray->win = XCreateSimpleWindow(dpy, root, x, m->by, w, bh, 0, 0, scheme[SchemeSel][ColBg].pixel);
|
||||
+ wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
+ wa.override_redirect = True;
|
||||
+ wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
+ XSelectInput(dpy, systray->win, SubstructureNotifyMask);
|
||||
+ XChangeProperty(dpy, systray->win, netatom[NetSystemTrayOrientation], XA_CARDINAL, 32,
|
||||
+ PropModeReplace, (unsigned char *)&netatom[NetSystemTrayOrientationHorz], 1);
|
||||
+ XChangeWindowAttributes(dpy, systray->win, CWEventMask|CWOverrideRedirect|CWBackPixel, &wa);
|
||||
+ XMapRaised(dpy, systray->win);
|
||||
+ XSetSelectionOwner(dpy, netatom[NetSystemTray], systray->win, CurrentTime);
|
||||
+ if (XGetSelectionOwner(dpy, netatom[NetSystemTray]) == systray->win) {
|
||||
+ sendevent(root, xatom[Manager], StructureNotifyMask, CurrentTime, netatom[NetSystemTray], systray->win, 0, 0);
|
||||
+ XSync(dpy, False);
|
||||
+ }
|
||||
+ else {
|
||||
+ fprintf(stderr, "dwm: unable to obtain system tray.\n");
|
||||
+ free(systray);
|
||||
+ systray = NULL;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ for (w = 0, i = systray->icons; i; i = i->next) {
|
||||
+ /* make sure the background color stays the same */
|
||||
+ wa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
+ XChangeWindowAttributes(dpy, i->win, CWBackPixel, &wa);
|
||||
+ XMapRaised(dpy, i->win);
|
||||
+ w += systrayspacing;
|
||||
+ i->x = w;
|
||||
+ XMoveResizeWindow(dpy, i->win, i->x, 0, i->w, i->h);
|
||||
+ w += i->w;
|
||||
+ if (i->mon != m)
|
||||
+ i->mon = m;
|
||||
+ }
|
||||
+ w = w ? w + systrayspacing : 1;
|
||||
+ x -= w;
|
||||
+ XMoveResizeWindow(dpy, systray->win, x, m->by, w, bh);
|
||||
+ wc.x = x; wc.y = m->by; wc.width = w; wc.height = bh;
|
||||
+ wc.stack_mode = Above; wc.sibling = m->barwin;
|
||||
+ XConfigureWindow(dpy, systray->win, CWX|CWY|CWWidth|CWHeight|CWSibling|CWStackMode, &wc);
|
||||
+ XMapWindow(dpy, systray->win);
|
||||
+ XMapSubwindows(dpy, systray->win);
|
||||
+ /* redraw background */
|
||||
+ XSetForeground(dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
|
||||
+ XFillRectangle(dpy, systray->win, drw->gc, 0, 0, w, bh);
|
||||
+ XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2075,6 +2408,16 @@ wintoclient(Window w)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+Client *
|
||||
+wintosystrayicon(Window w) {
|
||||
+ Client *i = NULL;
|
||||
+
|
||||
+ if (!showsystray || !w)
|
||||
+ return i;
|
||||
+ for (i = systray->icons; i && i->win != w; i = i->next) ;
|
||||
+ return i;
|
||||
+}
|
||||
+
|
||||
Monitor *
|
||||
wintomon(Window w)
|
||||
{
|
||||
@@ -2128,6 +2471,22 @@ xerrorstart(Display *dpy, XErrorEvent *ee)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+Monitor *
|
||||
+systraytomon(Monitor *m) {
|
||||
+ Monitor *t;
|
||||
+ int i, n;
|
||||
+ if(!systraypinning) {
|
||||
+ if(!m)
|
||||
+ return selmon;
|
||||
+ return m == selmon ? m : NULL;
|
||||
+ }
|
||||
+ for(n = 1, t = mons; t && t->next; n++, t = t->next) ;
|
||||
+ for(i = 1, t = mons; t && t->next && i < systraypinning; i++, t = t->next) ;
|
||||
+ if(systraypinningfailfirst && n < systraypinning)
|
||||
+ return mons;
|
||||
+ return t;
|
||||
+}
|
||||
+
|
||||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
412
patches/7-dwm-swallow-6.3.diff
Normal file
412
patches/7-dwm-swallow-6.3.diff
Normal file
|
@ -0,0 +1,412 @@
|
|||
From 0cf9a007511f7dfd7dd94171b172562ebac9b6d5 Mon Sep 17 00:00:00 2001
|
||||
From: Tom Schwindl <schwindl@posteo.de>
|
||||
Date: Sat, 10 Sep 2022 12:51:09 +0200
|
||||
Subject: [PATCH] 6.3 swallow patch
|
||||
|
||||
---
|
||||
config.def.h | 9 +-
|
||||
config.mk | 3 +-
|
||||
dwm.c | 235 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
3 files changed, 237 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 061ad662f82a..0b2b8ffd30d5 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -3,6 +3,7 @@
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
+static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
|
||||
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" };
|
||||
@@ -26,9 +27,11 @@ static const Rule rules[] = {
|
||||
* 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 },
|
||||
+ /* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||
+ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
|
||||
+ { "St", NULL, NULL, 0, 0, 1, 0, -1 },
|
||||
+ { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
diff --git a/config.mk b/config.mk
|
||||
index 81c493ef4aff..52d1ebf30bec 100644
|
||||
--- a/config.mk
|
||||
+++ b/config.mk
|
||||
@@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
+#KVMLIB = -lkvm
|
||||
|
||||
# includes and libs
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index e5efb6a22806..e68294b6b679 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -40,6 +40,12 @@
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
#include <X11/Xft/Xft.h>
|
||||
+#include <X11/Xlib-xcb.h>
|
||||
+#include <xcb/res.h>
|
||||
+#ifdef __OpenBSD__
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <kvm.h>
|
||||
+#endif /* __OpenBSD */
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
@@ -92,9 +98,11 @@ struct Client {
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
||||
int bw, oldbw;
|
||||
unsigned int tags;
|
||||
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
|
||||
+ pid_t pid;
|
||||
Client *next;
|
||||
Client *snext;
|
||||
+ Client *swallowing;
|
||||
Monitor *mon;
|
||||
Window win;
|
||||
};
|
||||
@@ -138,6 +146,8 @@ typedef struct {
|
||||
const char *title;
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
+ int isterminal;
|
||||
+ int noswallow;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
@@ -235,6 +245,12 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
+static pid_t getparentprocess(pid_t p);
|
||||
+static int isdescprocess(pid_t p, pid_t c);
|
||||
+static Client *swallowingclient(Window w);
|
||||
+static Client *termforwin(const Client *c);
|
||||
+static pid_t winpid(Window w);
|
||||
+
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
@@ -269,6 +285,8 @@ static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
|
||||
+static xcb_connection_t *xcon;
|
||||
+
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
||||
@@ -298,6 +316,8 @@ applyrules(Client *c)
|
||||
&& (!r->class || strstr(class, r->class))
|
||||
&& (!r->instance || strstr(instance, r->instance)))
|
||||
{
|
||||
+ c->isterminal = r->isterminal;
|
||||
+ c->noswallow = r->noswallow;
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||
@@ -416,6 +436,53 @@ attachstack(Client *c)
|
||||
c->mon->stack = c;
|
||||
}
|
||||
|
||||
+void
|
||||
+swallow(Client *p, Client *c)
|
||||
+{
|
||||
+
|
||||
+ if (c->noswallow || c->isterminal)
|
||||
+ return;
|
||||
+ if (c->noswallow && !swallowfloating && c->isfloating)
|
||||
+ return;
|
||||
+
|
||||
+ detach(c);
|
||||
+ detachstack(c);
|
||||
+
|
||||
+ setclientstate(c, WithdrawnState);
|
||||
+ XUnmapWindow(dpy, p->win);
|
||||
+
|
||||
+ p->swallowing = c;
|
||||
+ c->mon = p->mon;
|
||||
+
|
||||
+ Window w = p->win;
|
||||
+ p->win = c->win;
|
||||
+ c->win = w;
|
||||
+ updatetitle(p);
|
||||
+ XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
|
||||
+ arrange(p->mon);
|
||||
+ configure(p);
|
||||
+ updateclientlist();
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+unswallow(Client *c)
|
||||
+{
|
||||
+ c->win = c->swallowing->win;
|
||||
+
|
||||
+ free(c->swallowing);
|
||||
+ c->swallowing = NULL;
|
||||
+
|
||||
+ /* unfullscreen the client */
|
||||
+ setfullscreen(c, 0);
|
||||
+ updatetitle(c);
|
||||
+ arrange(c->mon);
|
||||
+ XMapWindow(dpy, c->win);
|
||||
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
+ setclientstate(c, NormalState);
|
||||
+ focus(NULL);
|
||||
+ arrange(c->mon);
|
||||
+}
|
||||
+
|
||||
void
|
||||
buttonpress(XEvent *e)
|
||||
{
|
||||
@@ -656,6 +723,9 @@ destroynotify(XEvent *e)
|
||||
|
||||
if ((c = wintoclient(ev->window)))
|
||||
unmanage(c, 1);
|
||||
+
|
||||
+ else if ((c = swallowingclient(ev->window)))
|
||||
+ unmanage(c->swallowing, 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1022,12 +1092,13 @@ killclient(const Arg *arg)
|
||||
void
|
||||
manage(Window w, XWindowAttributes *wa)
|
||||
{
|
||||
- Client *c, *t = NULL;
|
||||
+ Client *c, *t = NULL, *term = NULL;
|
||||
Window trans = None;
|
||||
XWindowChanges wc;
|
||||
|
||||
c = ecalloc(1, sizeof(Client));
|
||||
c->win = w;
|
||||
+ c->pid = winpid(w);
|
||||
/* geometry */
|
||||
c->x = c->oldx = wa->x;
|
||||
c->y = c->oldy = wa->y;
|
||||
@@ -1042,6 +1113,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||
} else {
|
||||
c->mon = selmon;
|
||||
applyrules(c);
|
||||
+ term = termforwin(c);
|
||||
}
|
||||
|
||||
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
||||
@@ -1076,6 +1148,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
XMapWindow(dpy, c->win);
|
||||
+ if (term)
|
||||
+ swallow(term, c);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
@@ -1763,6 +1837,20 @@ unmanage(Client *c, int destroyed)
|
||||
Monitor *m = c->mon;
|
||||
XWindowChanges wc;
|
||||
|
||||
+ if (c->swallowing) {
|
||||
+ unswallow(c);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Client *s = swallowingclient(c->win);
|
||||
+ if (s) {
|
||||
+ free(s->swallowing);
|
||||
+ s->swallowing = NULL;
|
||||
+ arrange(m);
|
||||
+ focus(NULL);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
if (!destroyed) {
|
||||
@@ -1778,9 +1866,12 @@ unmanage(Client *c, int destroyed)
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
free(c);
|
||||
- focus(NULL);
|
||||
- updateclientlist();
|
||||
- arrange(m);
|
||||
+
|
||||
+ if (!s) {
|
||||
+ arrange(m);
|
||||
+ focus(NULL);
|
||||
+ updateclientlist();
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2044,6 +2135,136 @@ view(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
+pid_t
|
||||
+winpid(Window w)
|
||||
+{
|
||||
+
|
||||
+ pid_t result = 0;
|
||||
+
|
||||
+#ifdef __linux__
|
||||
+ xcb_res_client_id_spec_t spec = {0};
|
||||
+ spec.client = w;
|
||||
+ spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
|
||||
+
|
||||
+ xcb_generic_error_t *e = NULL;
|
||||
+ xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
|
||||
+ xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
|
||||
+
|
||||
+ if (!r)
|
||||
+ return (pid_t)0;
|
||||
+
|
||||
+ xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
|
||||
+ for (; i.rem; xcb_res_client_id_value_next(&i)) {
|
||||
+ spec = i.data->spec;
|
||||
+ if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
|
||||
+ uint32_t *t = xcb_res_client_id_value_value(i.data);
|
||||
+ result = *t;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(r);
|
||||
+
|
||||
+ if (result == (pid_t)-1)
|
||||
+ result = 0;
|
||||
+
|
||||
+#endif /* __linux__ */
|
||||
+
|
||||
+#ifdef __OpenBSD__
|
||||
+ Atom type;
|
||||
+ int format;
|
||||
+ unsigned long len, bytes;
|
||||
+ unsigned char *prop;
|
||||
+ pid_t ret;
|
||||
+
|
||||
+ if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
|
||||
+ return 0;
|
||||
+
|
||||
+ ret = *(pid_t*)prop;
|
||||
+ XFree(prop);
|
||||
+ result = ret;
|
||||
+
|
||||
+#endif /* __OpenBSD__ */
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+pid_t
|
||||
+getparentprocess(pid_t p)
|
||||
+{
|
||||
+ unsigned int v = 0;
|
||||
+
|
||||
+#ifdef __linux__
|
||||
+ FILE *f;
|
||||
+ char buf[256];
|
||||
+ snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
|
||||
+
|
||||
+ if (!(f = fopen(buf, "r")))
|
||||
+ return 0;
|
||||
+
|
||||
+ fscanf(f, "%*u %*s %*c %u", &v);
|
||||
+ fclose(f);
|
||||
+#endif /* __linux__*/
|
||||
+
|
||||
+#ifdef __OpenBSD__
|
||||
+ int n;
|
||||
+ kvm_t *kd;
|
||||
+ struct kinfo_proc *kp;
|
||||
+
|
||||
+ kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
||||
+ if (!kd)
|
||||
+ return 0;
|
||||
+
|
||||
+ kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
|
||||
+ v = kp->p_ppid;
|
||||
+#endif /* __OpenBSD__ */
|
||||
+
|
||||
+ return (pid_t)v;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+isdescprocess(pid_t p, pid_t c)
|
||||
+{
|
||||
+ while (p != c && c != 0)
|
||||
+ c = getparentprocess(c);
|
||||
+
|
||||
+ return (int)c;
|
||||
+}
|
||||
+
|
||||
+Client *
|
||||
+termforwin(const Client *w)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ Monitor *m;
|
||||
+
|
||||
+ if (!w->pid || w->isterminal)
|
||||
+ return NULL;
|
||||
+
|
||||
+ for (m = mons; m; m = m->next) {
|
||||
+ for (c = m->clients; c; c = c->next) {
|
||||
+ if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
|
||||
+ return c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+Client *
|
||||
+swallowingclient(Window w)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ Monitor *m;
|
||||
+
|
||||
+ for (m = mons; m; m = m->next) {
|
||||
+ for (c = m->clients; c; c = c->next) {
|
||||
+ if (c->swallowing && c->swallowing->win == w)
|
||||
+ return c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
Client *
|
||||
wintoclient(Window w)
|
||||
{
|
||||
@@ -2133,10 +2354,12 @@ main(int argc, char *argv[])
|
||||
fputs("warning: no locale support\n", stderr);
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("dwm: cannot open display");
|
||||
+ if (!(xcon = XGetXCBConnection(dpy)))
|
||||
+ die("dwm: cannot get xcb connection\n");
|
||||
checkotherwm();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
- if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||
+ if (pledge("stdio rpath proc exec ps", NULL) == -1)
|
||||
die("pledge");
|
||||
#endif /* __OpenBSD__ */
|
||||
scan();
|
||||
--
|
||||
2.37.2
|
||||
|
101
patches/8-dwm-uselessgap-20211119-58414bee958f2.diff
Normal file
101
patches/8-dwm-uselessgap-20211119-58414bee958f2.diff
Normal file
|
@ -0,0 +1,101 @@
|
|||
From 58414bee958f2e7ed91d6fe31f503ec4a406981b Mon Sep 17 00:00:00 2001
|
||||
From: cirala <thim@cederlund.de>
|
||||
Date: Fri, 19 Nov 2021 18:14:07 +0100
|
||||
Subject: [PATCH] Fix for dwm-uselessgap
|
||||
Previous versions of the patch doubles the
|
||||
gap between the master and slave stacks.
|
||||
|
||||
---
|
||||
config.def.h | 3 ++-
|
||||
dwm.c | 38 +++++++++++++++++++++++++++++++-------
|
||||
2 files changed, 33 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..17a205f 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
/* appearance */
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
+static const unsigned int gappx = 6; /* gaps between 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 */
|
||||
@@ -34,7 +35,7 @@ static const Rule rules[] = {
|
||||
/* 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 resizehints = 0; /* 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[] = {
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..b626e89 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -52,8 +52,8 @@
|
||||
#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 WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
|
||||
+#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
@@ -1277,12 +1277,36 @@ void
|
||||
resizeclient(Client *c, int x, int y, int w, int h)
|
||||
{
|
||||
XWindowChanges wc;
|
||||
+ unsigned int n;
|
||||
+ unsigned int gapoffset;
|
||||
+ unsigned int gapincr;
|
||||
+ Client *nbc;
|
||||
|
||||
- c->oldx = c->x; c->x = wc.x = x;
|
||||
- c->oldy = c->y; c->y = wc.y = y;
|
||||
- c->oldw = c->w; c->w = wc.width = w;
|
||||
- c->oldh = c->h; c->h = wc.height = h;
|
||||
wc.border_width = c->bw;
|
||||
+
|
||||
+ /* Get number of clients for the client's monitor */
|
||||
+ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
|
||||
+
|
||||
+ /* Do nothing if layout is floating */
|
||||
+ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
|
||||
+ gapincr = gapoffset = 0;
|
||||
+ } else {
|
||||
+ /* Remove border and gap if layout is monocle or only one client */
|
||||
+ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
|
||||
+ gapoffset = 0;
|
||||
+ gapincr = -2 * borderpx;
|
||||
+ wc.border_width = 0;
|
||||
+ } else {
|
||||
+ gapoffset = gappx;
|
||||
+ gapincr = 2 * gappx;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ c->oldx = c->x; c->x = wc.x = x + gapoffset;
|
||||
+ c->oldy = c->y; c->y = wc.y = y + gapoffset;
|
||||
+ c->oldw = c->w; c->w = wc.width = w - gapincr;
|
||||
+ c->oldh = c->h; c->h = wc.height = h - gapincr;
|
||||
+
|
||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
@@ -1688,7 +1712,7 @@ tile(Monitor *m)
|
||||
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);
|
||||
+ resize(c, m->wx, m->wy + my, mw - (2*c->bw) + (n > 1 ? gappx : 0), h - (2*c->bw), 0);
|
||||
if (my + HEIGHT(c) < m->wh)
|
||||
my += HEIGHT(c);
|
||||
} else {
|
||||
--
|
||||
2.33.1
|
||||
|
208
patches/9-dwm-statuscmd-20210405-67d76bd.diff
Normal file
208
patches/9-dwm-statuscmd-20210405-67d76bd.diff
Normal file
|
@ -0,0 +1,208 @@
|
|||
From f58c7e4fd05ec13383518ccd51663167d45e92d0 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Bylinka <daniel.bylinka@gmail.com>
|
||||
Date: Fri, 2 Apr 2021 19:02:58 +0200
|
||||
Subject: [PATCH] [statuscmd] Signal mouse button and click location to status
|
||||
monitor
|
||||
|
||||
---
|
||||
config.def.h | 6 +++-
|
||||
dwm.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 100 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c0b587..154a59b 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -54,6 +54,8 @@ static const Layout layouts[] = {
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
+#define STATUSBAR "dwmblocks"
|
||||
+
|
||||
/* 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 };
|
||||
@@ -103,7 +105,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, sigstatusbar, {.i = 1} },
|
||||
+ { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} },
|
||||
+ { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} },
|
||||
{ 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..d871457 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -172,6 +172,7 @@ 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 pid_t getstatusbarpid();
|
||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||
static void grabbuttons(Client *c, int focused);
|
||||
static void grabkeys(void);
|
||||
@@ -206,6 +207,7 @@ static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int unused);
|
||||
+static void sigstatusbar(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
@@ -238,6 +240,9 @@ static void zoom(const Arg *arg);
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
+static int statusw;
|
||||
+static int statussig;
|
||||
+static pid_t statuspid = -1;
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh, blw = 0; /* bar geometry */
|
||||
@@ -422,6 +427,7 @@ buttonpress(XEvent *e)
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
+ char *text, *s, ch;
|
||||
|
||||
click = ClkRootWin;
|
||||
/* focus monitor if necessary */
|
||||
@@ -440,9 +446,23 @@ 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) {
|
||||
+ x = selmon->ww - statusw;
|
||||
click = ClkStatusText;
|
||||
- else
|
||||
+ statussig = 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;
|
||||
+ statussig = ch;
|
||||
+ }
|
||||
+ }
|
||||
+ } else
|
||||
click = ClkWinTitle;
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
@@ -704,9 +724,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) {
|
||||
@@ -872,6 +907,30 @@ getatomprop(Client *c, Atom prop)
|
||||
return atom;
|
||||
}
|
||||
|
||||
+pid_t
|
||||
+getstatusbarpid()
|
||||
+{
|
||||
+ char buf[32], *str = buf, *c;
|
||||
+ FILE *fp;
|
||||
+
|
||||
+ if (statuspid > 0) {
|
||||
+ snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
|
||||
+ if ((fp = fopen(buf, "r"))) {
|
||||
+ fgets(buf, sizeof(buf), fp);
|
||||
+ while ((c = strchr(str, '/')))
|
||||
+ str = c + 1;
|
||||
+ fclose(fp);
|
||||
+ if (!strcmp(str, STATUSBAR))
|
||||
+ return statuspid;
|
||||
+ }
|
||||
+ }
|
||||
+ if (!(fp = popen("pidof -s "STATUSBAR, "r")))
|
||||
+ return -1;
|
||||
+ fgets(buf, sizeof(buf), fp);
|
||||
+ pclose(fp);
|
||||
+ return strtol(buf, NULL, 10);
|
||||
+}
|
||||
+
|
||||
int
|
||||
getrootptr(int *x, int *y)
|
||||
{
|
||||
@@ -1637,6 +1696,20 @@ sigchld(int unused)
|
||||
while (0 < waitpid(-1, NULL, WNOHANG));
|
||||
}
|
||||
|
||||
+void
|
||||
+sigstatusbar(const Arg *arg)
|
||||
+{
|
||||
+ union sigval sv;
|
||||
+
|
||||
+ if (!statussig)
|
||||
+ return;
|
||||
+ sv.sival_int = arg->i;
|
||||
+ if ((statuspid = getstatusbarpid()) <= 0)
|
||||
+ return;
|
||||
+
|
||||
+ sigqueue(statuspid, SIGRTMIN+statussig, sv);
|
||||
+}
|
||||
+
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
@@ -1990,8 +2063,25 @@ 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
|
||||
|
48
patches/dwm-hide_vacant_tags-6.4.diff
Normal file
48
patches/dwm-hide_vacant_tags-6.4.diff
Normal file
|
@ -0,0 +1,48 @@
|
|||
:100644 100644 f1d86b2 0000000 M dwm.c
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index f1d86b2..d41cc14 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -433,9 +433,15 @@ buttonpress(XEvent *e)
|
||||
}
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = 0;
|
||||
- do
|
||||
+ unsigned int occ = 0;
|
||||
+ for(c = m->clients; c; c=c->next)
|
||||
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||
+ do {
|
||||
+ /* Do not reserve space for vacant tags */
|
||||
+ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
+ continue;
|
||||
x += TEXTW(tags[i]);
|
||||
- while (ev->x >= x && ++i < LENGTH(tags));
|
||||
+ } while (ev->x >= x && ++i < LENGTH(tags));
|
||||
if (i < LENGTH(tags)) {
|
||||
click = ClkTagBar;
|
||||
arg.ui = 1 << i;
|
||||
@@ -715,19 +721,18 @@ drawbar(Monitor *m)
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
- occ |= c->tags;
|
||||
+ occ |= c->tags == TAGMASK ? 0 : c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
x = 0;
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
+ /* Do not draw vacant tags */
|
||||
+ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
+ continue;
|
||||
w = TEXTW(tags[i]);
|
||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
|
||||
- if (occ & 1 << i)
|
||||
- drw_rect(drw, x + boxs, boxs, boxw, boxw,
|
||||
- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
|
||||
- urg & 1 << i);
|
||||
x += w;
|
||||
}
|
||||
w = TEXTW(m->ltsymbol);
|
609
patches/dwm-systray-dwmblocks-6.5.diff
Normal file
609
patches/dwm-systray-dwmblocks-6.5.diff
Normal file
|
@ -0,0 +1,609 @@
|
|||
diff -ruN dwm-6.5-ori/config.def.h dwm-6.5/config.def.h
|
||||
--- dwm-6.5-ori/config.def.h 2024-06-23 04:37:05.948485762 +0530
|
||||
+++ dwm-6.5/config.def.h 2024-06-23 04:37:51.765664575 +0530
|
||||
@@ -4,7 +4,6 @@
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
-static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */
|
||||
static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
static const int showsystray = 1; /* 0 means no systray */
|
||||
@@ -17,10 +16,26 @@
|
||||
static const char col_gray3[] = "#bbbbbb";
|
||||
static const char col_gray4[] = "#eeeeee";
|
||||
static const char col_cyan[] = "#005577";
|
||||
+static const char col1[] = "#ffffff";
|
||||
+static const char col2[] = "#ffffff";
|
||||
+static const char col3[] = "#ffffff";
|
||||
+static const char col4[] = "#ffffff";
|
||||
+static const char col5[] = "#ffffff";
|
||||
+static const char col6[] = "#ffffff";
|
||||
+
|
||||
+enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
|
||||
+ SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
|
||||
+
|
||||
static const char *colors[][3] = {
|
||||
/* fg bg border */
|
||||
- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
- [SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
+ [SchemeCol1] = { col1, col_gray1, col_gray2 },
|
||||
+ [SchemeCol2] = { col2, col_gray1, col_gray2 },
|
||||
+ [SchemeCol3] = { col3, col_gray1, col_gray2 },
|
||||
+ [SchemeCol4] = { col4, col_gray1, col_gray2 },
|
||||
+ [SchemeCol5] = { col5, col_gray1, col_gray2 },
|
||||
+ [SchemeCol6] = { col6, col_gray1, col_gray2 },
|
||||
+ [SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@@ -109,7 +124,9 @@
|
||||
{ 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, sigdwmblocks, {.i = 1} },
|
||||
+ { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||
+ { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
|
||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||
diff -ruN dwm-6.5-ori/config.h dwm-6.5/config.h
|
||||
--- dwm-6.5-ori/config.h 1970-01-01 05:30:00.000000000 +0530
|
||||
+++ dwm-6.5/config.h 2024-06-23 04:38:30.632805118 +0530
|
||||
@@ -0,0 +1,138 @@
|
||||
+/* 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 unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
|
||||
+static const unsigned int systrayspacing = 2; /* systray spacing */
|
||||
+static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/
|
||||
+static const int showsystray = 1; /* 0 means no systray */
|
||||
+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 col1[] = "#ffffff";
|
||||
+static const char col2[] = "#ffffff";
|
||||
+static const char col3[] = "#ffffff";
|
||||
+static const char col4[] = "#ffffff";
|
||||
+static const char col5[] = "#ffffff";
|
||||
+static const char col6[] = "#ffffff";
|
||||
+
|
||||
+enum { SchemeNorm, SchemeCol1, SchemeCol2, SchemeCol3, SchemeCol4,
|
||||
+ SchemeCol5, SchemeCol6, SchemeSel }; /* color schemes */
|
||||
+
|
||||
+static const char *colors[][3] = {
|
||||
+ /* fg bg border */
|
||||
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
+ [SchemeCol1] = { col1, col_gray1, col_gray2 },
|
||||
+ [SchemeCol2] = { col2, col_gray1, col_gray2 },
|
||||
+ [SchemeCol3] = { col3, col_gray1, col_gray2 },
|
||||
+ [SchemeCol4] = { col4, col_gray1, col_gray2 },
|
||||
+ [SchemeCol5] = { col5, col_gray1, col_gray2 },
|
||||
+ [SchemeCol6] = { col6, 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 const 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 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, sigdwmblocks, {.i = 1} },
|
||||
+ { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} },
|
||||
+ { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} },
|
||||
+ { 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} },
|
||||
+};
|
||||
+
|
||||
diff -ruN dwm-6.5-ori/dwm.c dwm-6.5/dwm.c
|
||||
--- dwm-6.5-ori/dwm.c 2024-06-23 04:37:05.951819133 +0530
|
||||
+++ dwm-6.5/dwm.c 2024-06-23 04:38:21.106019049 +0530
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif /* XINERAMA */
|
||||
#include <X11/Xft/Xft.h>
|
||||
+#include <fcntl.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
@@ -56,6 +57,13 @@
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
+#define TTEXTW(X) (drw_fontset_getwidth(drw, (X)))
|
||||
+
|
||||
+#define STATUSLENGTH 256
|
||||
+#define DWMBLOCKSLOCKFILE "/var/local/dwmblocks/dwmblocks.pid"
|
||||
+#define DELIMITERENDCHAR 10
|
||||
+#define LSPAD (lrpad / 2) /* padding on left side of status text */
|
||||
+#define RSPAD (lrpad / 2) /* padding on right side of status text */
|
||||
|
||||
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
||||
/* XEMBED messages */
|
||||
@@ -71,8 +79,7 @@
|
||||
#define XEMBED_EMBEDDED_VERSION (VERSION_MAJOR << 16) | VERSION_MINOR
|
||||
|
||||
/* enums */
|
||||
-enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
-enum { SchemeNorm, SchemeSel }; /* color schemes */
|
||||
+enum { CurNormal, CurHand, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
|
||||
NetSystemTray, NetSystemTrayOP, NetSystemTrayOrientation, NetSystemTrayOrientationHorz,
|
||||
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
|
||||
@@ -139,6 +146,7 @@
|
||||
unsigned int tagset[2];
|
||||
int showbar;
|
||||
int topbar;
|
||||
+ int statushandcursor;
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
Client *stack;
|
||||
@@ -230,6 +238,7 @@
|
||||
static void setup(void);
|
||||
static void seturgent(Client *c, int urg);
|
||||
static void showhide(Client *c);
|
||||
+static void sigdwmblocks(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static Monitor *systraytomon(Monitor *m);
|
||||
static void tag(const Arg *arg);
|
||||
@@ -245,6 +254,7 @@
|
||||
static void updatebarpos(Monitor *m);
|
||||
static void updatebars(void);
|
||||
static void updateclientlist(void);
|
||||
+static void updatedwmblockssig(int x);
|
||||
static int updategeom(void);
|
||||
static void updatenumlockmask(void);
|
||||
static void updatesizehints(Client *c);
|
||||
@@ -265,14 +275,17 @@
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
-static Systray *systray = NULL;
|
||||
static const char broken[] = "broken";
|
||||
-static char stext[256];
|
||||
+static char stextc[STATUSLENGTH];
|
||||
+static char stexts[STATUSLENGTH];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
-static int bh; /* bar height */
|
||||
+static int bh, blw, ble; /* bar geometry */
|
||||
+static int wsbar; /* width of selmon bar */
|
||||
+static int wstext; /* width of status text */
|
||||
static int lrpad; /* sum of left and right padding for text */
|
||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||
+static unsigned int dwmblockssig;
|
||||
static unsigned int numlockmask = 0;
|
||||
static void (*handler[LASTEvent]) (XEvent *) = {
|
||||
[ButtonPress] = buttonpress,
|
||||
@@ -299,6 +312,7 @@
|
||||
static Drw *drw;
|
||||
static Monitor *mons, *selmon;
|
||||
static Window root, wmcheckwin;
|
||||
+static Systray *systray = NULL;
|
||||
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
@@ -450,13 +464,13 @@
|
||||
void
|
||||
buttonpress(XEvent *e)
|
||||
{
|
||||
- unsigned int i, x, click;
|
||||
+ int i, x;
|
||||
+ unsigned int click;
|
||||
Arg arg = {0};
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
|
||||
- click = ClkRootWin;
|
||||
/* focus monitor if necessary */
|
||||
if ((m = wintomon(ev->window)) && m != selmon) {
|
||||
unfocus(selmon->sel, 1);
|
||||
@@ -464,25 +478,29 @@
|
||||
focus(NULL);
|
||||
}
|
||||
if (ev->window == selmon->barwin) {
|
||||
- i = x = 0;
|
||||
- do
|
||||
- x += TEXTW(tags[i]);
|
||||
- while (ev->x >= x && ++i < LENGTH(tags));
|
||||
- if (i < LENGTH(tags)) {
|
||||
- click = ClkTagBar;
|
||||
- arg.ui = 1 << i;
|
||||
- } else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||
- click = ClkLtSymbol;
|
||||
- else if (ev->x > selmon->ww - (int)TEXTW(stext) - getsystraywidth())
|
||||
- click = ClkStatusText;
|
||||
- else
|
||||
- click = ClkWinTitle;
|
||||
+ if (ev->x < ble - blw) {
|
||||
+ i = -1, x = -ev->x;
|
||||
+ do
|
||||
+ x += TEXTW(tags[++i]);
|
||||
+ while (x <= 0);
|
||||
+ click = ClkTagBar;
|
||||
+ arg.ui = 1 << i;
|
||||
+ } else if (ev->x < ble)
|
||||
+ click = ClkLtSymbol;
|
||||
+ else if (ev->x < wsbar - wstext)
|
||||
+ click = ClkWinTitle;
|
||||
+ else if ((x = wsbar - RSPAD - ev->x) > 0 && (x -= wstext - LSPAD - RSPAD) <= 0) {
|
||||
+ updatedwmblockssig(x);
|
||||
+ click = ClkStatusText;
|
||||
+ } else
|
||||
+ return;
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
||||
click = ClkClientWin;
|
||||
- }
|
||||
+ } else
|
||||
+ click = ClkRootWin;
|
||||
for (i = 0; i < LENGTH(buttons); i++)
|
||||
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
||||
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
|
||||
@@ -791,7 +809,8 @@
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
- int x, w, tw = 0, stw = 0;
|
||||
+ int x, w;
|
||||
+ int wbar = m->ww;
|
||||
int boxs = drw->fonts->h / 9;
|
||||
int boxw = drw->fonts->h / 6 + 2;
|
||||
unsigned int i, occ = 0, urg = 0;
|
||||
@@ -800,17 +819,40 @@
|
||||
if (!m->showbar)
|
||||
return;
|
||||
|
||||
- if(showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
- stw = getsystraywidth();
|
||||
+ if (showsystray && m == systraytomon(m))
|
||||
+ wbar -= getsystraywidth();
|
||||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||
- drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
- tw = TEXTW(stext) - lrpad / 2 + 2; /* 2px extra right padding */
|
||||
- drw_text(drw, m->ww - tw - stw, 0, tw, bh, lrpad / 2 - 2, stext, 0);
|
||||
+ char *stc = stextc;
|
||||
+ char *stp = stextc;
|
||||
+ char tmp;
|
||||
+
|
||||
+ wsbar = wbar;
|
||||
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
+ x = wbar - wstext;
|
||||
+ drw_rect(drw, x, 0, LSPAD, bh, 1, 1); x += LSPAD; /* to keep left padding clean */
|
||||
+ for (;;) {
|
||||
+ if ((unsigned char)*stc >= ' ') {
|
||||
+ stc++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ tmp = *stc;
|
||||
+ if (stp != stc) {
|
||||
+ *stc = '\0';
|
||||
+ x = drw_text(drw, x, 0, TTEXTW(stp), bh, 0, stp, 0);
|
||||
+ }
|
||||
+ if (tmp == '\0')
|
||||
+ break;
|
||||
+ if (tmp - DELIMITERENDCHAR - 1 < LENGTH(colors))
|
||||
+ drw_setscheme(drw, scheme[tmp - DELIMITERENDCHAR - 1]);
|
||||
+ *stc = tmp;
|
||||
+ stp = ++stc;
|
||||
+ }
|
||||
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
+ drw_rect(drw, x, 0, wbar - x, bh, 1, 1); /* to keep right padding clean */
|
||||
}
|
||||
|
||||
- resizebarwin(m);
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
@@ -831,7 +873,13 @@
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
- if ((w = m->ww - tw - stw - x) > bh) {
|
||||
+ if (m == selmon) {
|
||||
+ blw = w, ble = x;
|
||||
+ w = wbar - wstext - x;
|
||||
+ } else
|
||||
+ w = wbar - x;
|
||||
+
|
||||
+ if (w > bh) {
|
||||
if (m->sel) {
|
||||
drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||
@@ -842,7 +890,9 @@
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
}
|
||||
}
|
||||
- drw_map(drw, m->barwin, 0, 0, m->ww - stw, bh);
|
||||
+
|
||||
+ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, wbar, bh);
|
||||
+ drw_map(drw, m->barwin, 0, 0, wbar, bh);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1255,17 +1305,24 @@
|
||||
motionnotify(XEvent *e)
|
||||
{
|
||||
static Monitor *mon = NULL;
|
||||
+ int x;
|
||||
Monitor *m;
|
||||
XMotionEvent *ev = &e->xmotion;
|
||||
|
||||
- if (ev->window != root)
|
||||
- return;
|
||||
- if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||
- unfocus(selmon->sel, 1);
|
||||
- selmon = m;
|
||||
- focus(NULL);
|
||||
- }
|
||||
- mon = m;
|
||||
+ if (ev->window == root) {
|
||||
+ if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) {
|
||||
+ unfocus(selmon->sel, 1);
|
||||
+ selmon = m;
|
||||
+ focus(NULL);
|
||||
+ }
|
||||
+ mon = m;
|
||||
+ } else if (ev->window == selmon->barwin && (x = wsbar - RSPAD - ev->x) > 0
|
||||
+ && (x -= wstext - LSPAD - RSPAD) <= 0)
|
||||
+ updatedwmblockssig(x);
|
||||
+ else if (selmon->statushandcursor) {
|
||||
+ selmon->statushandcursor = 0;
|
||||
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1435,7 +1492,7 @@
|
||||
void
|
||||
resizebarwin(Monitor *m) {
|
||||
unsigned int w = m->ww;
|
||||
- if (showsystray && m == systraytomon(m) && !systrayonleft)
|
||||
+ if (showsystray && m == systraytomon(m))
|
||||
w -= getsystraywidth();
|
||||
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, w, bh);
|
||||
}
|
||||
@@ -1770,6 +1827,7 @@
|
||||
xatom[XembedInfo] = XInternAtom(dpy, "_XEMBED_INFO", False);
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
|
||||
+ cursor[CurHand] = drw_cur_create(drw, XC_hand2);
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
@@ -1836,6 +1894,37 @@
|
||||
}
|
||||
|
||||
void
|
||||
+sigdwmblocks(const Arg *arg)
|
||||
+{
|
||||
+ static int fd = -1;
|
||||
+ struct flock fl;
|
||||
+ union sigval sv;
|
||||
+
|
||||
+ if (!dwmblockssig)
|
||||
+ return;
|
||||
+ fl.l_type = F_WRLCK;
|
||||
+ fl.l_whence = SEEK_SET;
|
||||
+ fl.l_start = 0;
|
||||
+ fl.l_len = 0;
|
||||
+ if (fd != -1) {
|
||||
+ if (fcntl(fd, F_GETLK, &fl) != -1 && fl.l_type == F_WRLCK)
|
||||
+ goto signal;
|
||||
+ close(fd);
|
||||
+ fl.l_type = F_WRLCK;
|
||||
+ }
|
||||
+ if ((fd = open(DWMBLOCKSLOCKFILE, O_RDONLY | O_CLOEXEC)) == -1)
|
||||
+ return;
|
||||
+ if (fcntl(fd, F_GETLK, &fl) == -1 || fl.l_type != F_WRLCK) {
|
||||
+ close(fd);
|
||||
+ fd = -1;
|
||||
+ return;
|
||||
+ }
|
||||
+signal:
|
||||
+ sv.sival_int = (dwmblockssig << 8) | arg->i;
|
||||
+ sigqueue(fl.l_pid, SIGRTMIN, sv);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
struct sigaction sa;
|
||||
@@ -2031,7 +2120,7 @@
|
||||
XSetWindowAttributes wa = {
|
||||
.override_redirect = True,
|
||||
.background_pixmap = ParentRelative,
|
||||
- .event_mask = ButtonPressMask|ExposureMask
|
||||
+ .event_mask = ButtonPressMask|ExposureMask|PointerMotionMask
|
||||
};
|
||||
XClassHint ch = {"dwm", "dwm"};
|
||||
for (m = mons; m; m = m->next) {
|
||||
@@ -2078,6 +2167,41 @@
|
||||
(unsigned char *) &(c->win), 1);
|
||||
}
|
||||
|
||||
+void
|
||||
+updatedwmblockssig(int x)
|
||||
+{
|
||||
+ char *sts = stexts;
|
||||
+ char *stp = stexts;
|
||||
+ char tmp;
|
||||
+
|
||||
+ while (*sts != '\0') {
|
||||
+ if ((unsigned char)*sts >= ' ') {
|
||||
+ sts++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ tmp = *sts;
|
||||
+ *sts = '\0';
|
||||
+ x += TTEXTW(stp);
|
||||
+ *sts = tmp;
|
||||
+ if (x > 0) {
|
||||
+ if (tmp == DELIMITERENDCHAR)
|
||||
+ break;
|
||||
+ if (!selmon->statushandcursor) {
|
||||
+ selmon->statushandcursor = 1;
|
||||
+ XDefineCursor(dpy, selmon->barwin, cursor[CurHand]->cursor);
|
||||
+ }
|
||||
+ dwmblockssig = tmp;
|
||||
+ return;
|
||||
+ }
|
||||
+ stp = ++sts;
|
||||
+ }
|
||||
+ if (selmon->statushandcursor) {
|
||||
+ selmon->statushandcursor = 0;
|
||||
+ XDefineCursor(dpy, selmon->barwin, cursor[CurNormal]->cursor);
|
||||
+ }
|
||||
+ dwmblockssig = 0;
|
||||
+}
|
||||
+
|
||||
int
|
||||
updategeom(void)
|
||||
{
|
||||
@@ -2219,10 +2343,27 @@
|
||||
void
|
||||
updatestatus(void)
|
||||
{
|
||||
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||
- strcpy(stext, "dwm-"VERSION);
|
||||
- drawbar(selmon);
|
||||
- updatesystray();
|
||||
+ char rawstext[STATUSLENGTH];
|
||||
+
|
||||
+ if (gettextprop(root, XA_WM_NAME, rawstext, sizeof rawstext)) {
|
||||
+ char stextp[STATUSLENGTH];
|
||||
+ char *stp = stextp, *stc = stextc, *sts = stexts;
|
||||
+
|
||||
+ for (char *rst = rawstext; *rst != '\0'; rst++)
|
||||
+ if ((unsigned char)*rst >= ' ')
|
||||
+ *(stp++) = *(stc++) = *(sts++) = *rst;
|
||||
+ else if ((unsigned char)*rst > DELIMITERENDCHAR)
|
||||
+ *(stc++) = *rst;
|
||||
+ else
|
||||
+ *(sts++) = *rst;
|
||||
+ *stp = *stc = *sts = '\0';
|
||||
+ wstext = TTEXTW(stextp) + LSPAD + RSPAD;
|
||||
+ } else {
|
||||
+ strcpy(stextc, "dwm-"VERSION);
|
||||
+ strcpy(stexts, stextc);
|
||||
+ wstext = TTEXTW(stextc) + LSPAD + RSPAD;
|
||||
+ }
|
||||
+ drawbar(selmon);
|
||||
}
|
||||
|
||||
|
||||
@@ -2285,13 +2426,10 @@
|
||||
Client *i;
|
||||
Monitor *m = systraytomon(NULL);
|
||||
unsigned int x = m->mx + m->mw;
|
||||
- unsigned int sw = TEXTW(stext) - lrpad + systrayspacing;
|
||||
unsigned int w = 1;
|
||||
|
||||
if (!showsystray)
|
||||
return;
|
||||
- if (systrayonleft)
|
||||
- x -= sw + lrpad / 2;
|
||||
if (!systray) {
|
||||
/* init systray */
|
||||
if (!(systray = (Systray *)calloc(1, sizeof(Systray))))
|
Loading…
Reference in a new issue