Compare commits
22 commits
16dc543e11
...
377f064d3e
Author | SHA1 | Date | |
---|---|---|---|
377f064d3e | |||
8dec419f63 | |||
c5738de01d | |||
7516b03d7d | |||
4da4ae80e4 | |||
89ea6276f5 | |||
7b657cf04d | |||
12da4da048 | |||
5c838a4273 | |||
3e7db78a19 | |||
0df08d5efd | |||
39d86bd3ff | |||
daf0fff860 | |||
83ef57559a | |||
1647a70ea6 | |||
3425d4bda4 | |||
51eabedba7 | |||
ed5d75083c | |||
507760bbff | |||
59db9120dc | |||
b01b3c639a | |||
ab3f787725 |
10 changed files with 460 additions and 100 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
*.o
|
||||||
|
/patches
|
||||||
|
dwm
|
||||||
|
*.orig
|
||||||
|
*.rej
|
1
LICENSE
1
LICENSE
|
@ -18,6 +18,7 @@ MIT/X Consortium License
|
||||||
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
||||||
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
||||||
© 2020-2022 Chris Down <chris@chrisdown.name>
|
© 2020-2022 Chris Down <chris@chrisdown.name>
|
||||||
|
© 2021-2022 Bryson Steck <brysonsteck@protonmail.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
|
48
README
48
README
|
@ -1,48 +0,0 @@
|
||||||
dwm - dynamic window manager
|
|
||||||
============================
|
|
||||||
dwm is an extremely fast, small, and dynamic window manager for X.
|
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
In order to build dwm you need the Xlib header files.
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
Edit config.mk to match your local setup (dwm is installed into
|
|
||||||
the /usr/local namespace by default).
|
|
||||||
|
|
||||||
Afterwards enter the following command to build and install dwm (if
|
|
||||||
necessary as root):
|
|
||||||
|
|
||||||
make clean install
|
|
||||||
|
|
||||||
|
|
||||||
Running dwm
|
|
||||||
-----------
|
|
||||||
Add the following line to your .xinitrc to start dwm using startx:
|
|
||||||
|
|
||||||
exec dwm
|
|
||||||
|
|
||||||
In order to connect dwm to a specific display, make sure that
|
|
||||||
the DISPLAY environment variable is set correctly, e.g.:
|
|
||||||
|
|
||||||
DISPLAY=foo.bar:1 exec dwm
|
|
||||||
|
|
||||||
(This will start dwm on display :1 of the host foo.bar.)
|
|
||||||
|
|
||||||
In order to display status info in the bar, you can do something
|
|
||||||
like this in your .xinitrc:
|
|
||||||
|
|
||||||
while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
done &
|
|
||||||
exec dwm
|
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
-------------
|
|
||||||
The configuration of dwm is done by creating a custom config.h
|
|
||||||
and (re)compiling the source code.
|
|
37
README.md
Normal file
37
README.md
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# dwm
|
||||||
|
|
||||||
|
This is my personal fork of the [suckless tool](https://dwm.suckless.org), Dynamic Window Manager (`dwm`), that I use on any computers where workflow is critical.
|
||||||
|
|
||||||
|
## My changes/patches
|
||||||
|
|
||||||
|
Here are the biggest changes and patches I applied to this fork of `dwm`:
|
||||||
|
|
||||||
|
* Gruvbox Dark themed
|
||||||
|
* Uses JetBrains Mono as the font
|
||||||
|
* `MODKEY` set to Super
|
||||||
|
* Added the following patches from the suckless website:
|
||||||
|
* swallow
|
||||||
|
* cursorwarp
|
||||||
|
* fullgaps
|
||||||
|
* hide_vacant_tags
|
||||||
|
* sticky and stickyindicator
|
||||||
|
* bottomstack
|
||||||
|
* there may be more... I have no idea lol
|
||||||
|
* A couple keybinds are not stock (compared to vanilla dwm):
|
||||||
|
* Quitting dwm rebinded to `Super+Shift+BackSpace` and confirms quitting with a script
|
||||||
|
* The increments to resize the master area have been decreased
|
||||||
|
* Launching `dmenu` launches a binary called `dmenu_run_history` which I found online somewhere, literally no idea where I found it lol. Eventually I'll patch it myself someday
|
||||||
|
* Launching the terminal is bound to a script that launches Alacritty in the same directory as the current terminal window
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://codeberg.org/brysonsteck/dwm
|
||||||
|
cd dwm
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
## License and Warranty Disclaimer
|
||||||
|
|
||||||
|
`dwm` is free and open source software under the MIT/X Consortium License. Read the [LICENSE](LICENSE) file for more information.
|
||||||
|
|
17
config.def.h
17
config.def.h
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
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 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 showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
@ -17,6 +19,8 @@ static const char *colors[][3] = {
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
};
|
};
|
||||||
|
static const XPoint stickyicon[] = { {0,0}, {4,0}, {4,8}, {2,6}, {0,8}, {0,0} }; /* represents the icon as an array of vertices */
|
||||||
|
static const XPoint stickyiconbb = {4,8}; /* defines the bottom right corner of the polygon's bounding box (speeds up scaling) */
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
@ -26,9 +30,11 @@ static const Rule rules[] = {
|
||||||
* WM_CLASS(STRING) = instance, class
|
* WM_CLASS(STRING) = instance, class
|
||||||
* WM_NAME(STRING) = title
|
* WM_NAME(STRING) = title
|
||||||
*/
|
*/
|
||||||
/* class instance title tags mask isfloating monitor */
|
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "Firefox", NULL, NULL, 1 << 8, 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) */
|
/* layout(s) */
|
||||||
|
@ -42,6 +48,8 @@ static const Layout layouts[] = {
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
|
{ "TTT", bstack },
|
||||||
|
{ "===", bstackhoriz },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
|
@ -77,8 +85,11 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
|
||||||
|
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XK_s, togglesticky, {0} },
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
|
|
49
config.h
49
config.h
|
@ -6,8 +6,9 @@ static const unsigned int gappx = 8; /* gaps between windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const char *fonts[] = { "JetBrains Mono:style=medium:size=11" };
|
static const int swallowfloating = 0;
|
||||||
static const char dmenufont[] = "JetBrains Mono:stlye=medium:size=11";
|
static const char *fonts[] = { "JetBrains Mono NF:style=medium:size=11" };
|
||||||
|
static const char dmenufont[] = "JetBrains Mono NF:style=medium:size=11";
|
||||||
// gruvbox
|
// gruvbox
|
||||||
static const char fg[] = "#ebdbb2";
|
static const char fg[] = "#ebdbb2";
|
||||||
static const char bg_normal[] = "#3c3836";
|
static const char bg_normal[] = "#3c3836";
|
||||||
|
@ -26,23 +27,27 @@ static const char *colors[][3] = {
|
||||||
[SchemeSel] = { fg, bg_selected, dr_selected },
|
[SchemeSel] = { fg, bg_selected, dr_selected },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const XPoint stickyicon[] = { {0,0}, {4,0}, {4,8}, {2,6}, {0,8}, {0,0} }; /* represents the icon as an array of vertices */
|
||||||
|
static const XPoint stickyiconbb = {4,8}; /* defines the bottom right corner of the polygon's bounding box (speeds up scaling) */
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "!", "@", "#", "$", "%", "^", "&", "*" };
|
static const char *tags[] = { "!", "@", "#", "$", "%", "^", "&", "*", "(" };
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* xprop(1):
|
/* xprop(1):
|
||||||
* WM_CLASS(STRING) = instance, class
|
* WM_CLASS(STRING) = instance, class
|
||||||
* WM_NAME(STRING) = title
|
* WM_NAME(STRING) = title
|
||||||
*/
|
*/
|
||||||
/* class instance title tags mask isfloating monitor */
|
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||||
{ "zoom", NULL, NULL, 0, 1, -1 },
|
{ "zoom", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "Mars", NULL, NULL, 0, 1, -1 },
|
{ "Mars", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "Engrampa", NULL, NULL, 0, 1, -1 },
|
{ "Engrampa", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "chatterino",NULL, NULL, 0, 1, -1 },
|
{ "chatterino",NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "Wiimmfi-RPC v1.7.5",NULL,NULL, 0, 1, -1 },
|
{ "Wiimmfi-RPC v1.7.5",NULL,NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "minecraft-launcher",NULL,NULL, 0, 1, -1 },
|
{ "minecraft-launcher",NULL,NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "nitrogen", NULL, NULL, 0, 1, -1 },
|
{ "nitrogen", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
{ "Galculator",NULL, NULL, 0, 1, -1 },
|
{ "Galculator",NULL, NULL, 0, 1, 0, 0, -1 },
|
||||||
|
{ "Alacritty",NULL, NULL, 0, 0, 1, 0, -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
|
@ -56,9 +61,13 @@ static const Layout layouts[] = {
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
|
{ "TTT", bstack },
|
||||||
|
{ "===", bstackhoriz },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
|
// Mod4Mask is super
|
||||||
|
// Mod1Mask is alt/meta
|
||||||
#define MODKEY Mod4Mask
|
#define MODKEY Mod4Mask
|
||||||
#define TAGKEYS(KEY,TAG) \
|
#define TAGKEYS(KEY,TAG) \
|
||||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
|
@ -71,21 +80,23 @@ static const Layout layouts[] = {
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
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[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", bg_normal, "-nf", fg, "-sb", bg_selected, "-sf", fg, NULL };
|
||||||
static const char *dmenucmd[] = { "dmenu_run_history", "-m", dmenumon, "-fn", dmenufont, "-nb", bg_normal, "-nf", fg, "-sb", bg_selected, "-sf", fg, NULL };
|
static const char *dmenucmd[] = { "dmenu_run_history", "-m", dmenumon, "-fn", dmenufont, "-nb", bg_normal, "-nf", fg, "-sb", bg_selected, "-sf", fg, NULL };
|
||||||
//static const char *termcmd[] = { "st", NULL };
|
|
||||||
static const char *termcmd[] = { "spawn-alacritty.sh", NULL };
|
static const char *termcmd[] = { "spawn-alacritty.sh", NULL };
|
||||||
static const char *brightnessup[] = { "brightness-up.sh", NULL };
|
static const char *brightnessup[] = { "brightness-up.sh", NULL };
|
||||||
static const char *brightnessdown[] = { "brightness-down.sh", NULL };
|
static const char *brightnessdown[] = { "brightness-down.sh", NULL };
|
||||||
static const char *screenshooter[] = { "screenshot.sh", NULL };
|
static const char *screenshooter[] = { "screenshot.sh", NULL };
|
||||||
static const char *volup[] = { "volup.sh", NULL };
|
static const char *volup[] = { "volup.sh", NULL };
|
||||||
static const char *voldown[] = { "voldown.sh", NULL };
|
static const char *voldown[] = { "voldown.sh", NULL };
|
||||||
//static const char *volmute[] = { "volmute.sh", NULL }; (replaced with *next[] for different keyboards)
|
//static const char *firefox[] = { "firefox-bin", NULL };
|
||||||
static const char *firefox[] = { "librewolf-bin", NULL };
|
static const char *firefox[] = { "librewolf-bin", NULL };
|
||||||
static const char *slock[] = { "slock", NULL };
|
static const char *slock[] = { "slock", NULL };
|
||||||
static const char *playpause[] = { "playerctl", "play-pause", NULL };
|
static const char *playpause[] = { "playerctl", "play-pause", NULL };
|
||||||
static const char *next[] = { "f9.sh", NULL };
|
static const char *next[] = { "f9.sh", NULL };
|
||||||
static const char *previous[] = { "playerctl", "previous", NULL };
|
static const char *previous[] = { "playerctl", "previous", NULL };
|
||||||
|
static const char *keepass[] = { "keepassxc", NULL };
|
||||||
|
static const char *joplin[] = { "joplin.AppImage", NULL };
|
||||||
|
static const char *quitconf[] = { "quitconf", dmenumon, bg_normal, fg, fg, NULL };
|
||||||
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
|
@ -94,7 +105,6 @@ static Key keys[] = {
|
||||||
{ MODKEY|ShiftMask, XK_f, spawn, {.v = firefox } },
|
{ MODKEY|ShiftMask, XK_f, spawn, {.v = firefox } },
|
||||||
{ MODKEY|ShiftMask, XK_Escape, spawn, {.v = slock } },
|
{ MODKEY|ShiftMask, XK_Escape, spawn, {.v = slock } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
// { MODKEY, XK_w, tabmode, {-1} },
|
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
|
@ -107,8 +117,11 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
|
||||||
|
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
||||||
{ MODKEY, XK_space, setlayout, {0} },
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XK_s, togglesticky, {0} },
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
|
@ -126,6 +139,9 @@ static Key keys[] = {
|
||||||
{ MODKEY, XK_F7, spawn, {.v = previous } },
|
{ MODKEY, XK_F7, spawn, {.v = previous } },
|
||||||
{ MODKEY, XK_F8, spawn, {.v = playpause } },
|
{ MODKEY, XK_F8, spawn, {.v = playpause } },
|
||||||
{ MODKEY, XK_F9, spawn, {.v = next } },
|
{ MODKEY, XK_F9, spawn, {.v = next } },
|
||||||
|
{ MODKEY|ShiftMask, XK_k, spawn, {.v = keepass } },
|
||||||
|
{ MODKEY|ShiftMask, XK_j, spawn, {.v = joplin } },
|
||||||
|
{ MODKEY|ShiftMask, XK_BackSpace, spawn, {.v = quitconf} },
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
|
@ -135,7 +151,6 @@ static Key keys[] = {
|
||||||
TAGKEYS( XK_7, 6)
|
TAGKEYS( XK_7, 6)
|
||||||
TAGKEYS( XK_8, 7)
|
TAGKEYS( XK_8, 7)
|
||||||
TAGKEYS( XK_9, 8)
|
TAGKEYS( XK_9, 8)
|
||||||
{ MODKEY|ShiftMask, XK_BackSpace, quit, {0} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* button definitions */
|
/* button definitions */
|
||||||
|
|
|
@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2
|
||||||
# OpenBSD (uncomment)
|
# OpenBSD (uncomment)
|
||||||
#FREETYPEINC = ${X11INC}/freetype2
|
#FREETYPEINC = ${X11INC}/freetype2
|
||||||
#MANPREFIX = ${PREFIX}/man
|
#MANPREFIX = ${PREFIX}/man
|
||||||
|
#KVMLIB = -lkvm
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||||
|
|
21
drw.c
21
drw.c
|
@ -203,6 +203,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||||
DefaultColormap(drw->dpy, drw->screen),
|
DefaultColormap(drw->dpy, drw->screen),
|
||||||
clrname, dest))
|
clrname, dest))
|
||||||
die("error, cannot allocate color '%s'", clrname);
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
|
dest->pixel |= 0xff << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
@ -248,6 +249,26 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
|
||||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled) /* wrapper function to scale and draw a polygon with X11 */
|
||||||
|
{
|
||||||
|
if (!drw || !drw->scheme)
|
||||||
|
return;
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel);
|
||||||
|
if (!filled) { /* reduces the scaled width and height by 1 when drawing the outline to compensate for X11 drawing the line 1 pixel over */
|
||||||
|
sw -= 1;
|
||||||
|
sh -= 1;
|
||||||
|
}
|
||||||
|
XPoint scaledpoints[npoints];
|
||||||
|
memcpy(scaledpoints, points, npoints);
|
||||||
|
for (int v = 0; v < npoints; v++)
|
||||||
|
scaledpoints[v] = (XPoint){ .x = points[v].x * sw / ow + x, .y = points[v].y * sh / oh + y };
|
||||||
|
if (filled)
|
||||||
|
XFillPolygon(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, shape, CoordModeOrigin); /* Change shape to 'Convex' or 'Complex' in dwm.c if the shape is not 'Nonconvex' */
|
||||||
|
else
|
||||||
|
XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
{
|
{
|
||||||
|
|
1
drw.h
1
drw.h
|
@ -52,6 +52,7 @@ void drw_setscheme(Drw *drw, Clr *scm);
|
||||||
|
|
||||||
/* Drawing functions */
|
/* Drawing functions */
|
||||||
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||||
|
void drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled);
|
||||||
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||||
|
|
||||||
/* Map functions */
|
/* Map functions */
|
||||||
|
|
344
dwm.c
344
dwm.c
|
@ -40,6 +40,12 @@
|
||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
#include <X11/Xft/Xft.h>
|
#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 "drw.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -49,11 +55,11 @@
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
|
||||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
@ -92,9 +98,12 @@ struct Client {
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
|
||||||
int bw, oldbw;
|
int bw, oldbw;
|
||||||
unsigned int tags;
|
unsigned int tags;
|
||||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, issticky, isterminal, noswallow;
|
||||||
|
pid_t pid;
|
||||||
|
int issteam;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *snext;
|
Client *snext;
|
||||||
|
Client *swallowing;
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
Window win;
|
Window win;
|
||||||
};
|
};
|
||||||
|
@ -139,6 +148,8 @@ typedef struct {
|
||||||
const char *title;
|
const char *title;
|
||||||
unsigned int tags;
|
unsigned int tags;
|
||||||
int isfloating;
|
int isfloating;
|
||||||
|
int isterminal;
|
||||||
|
int noswallow;
|
||||||
int monitor;
|
int monitor;
|
||||||
} Rule;
|
} Rule;
|
||||||
|
|
||||||
|
@ -214,6 +225,7 @@ static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *);
|
static void tile(Monitor *);
|
||||||
static void togglebar(const Arg *arg);
|
static void togglebar(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void togglesticky(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
static void unfocus(Client *c, int setfocus);
|
static void unfocus(Client *c, int setfocus);
|
||||||
|
@ -236,6 +248,14 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
static void bstack(Monitor *m);
|
||||||
|
static void bstackhoriz(Monitor *m);
|
||||||
|
|
||||||
|
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 */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
|
@ -271,6 +291,8 @@ static Drw *drw;
|
||||||
static Monitor *mons, *selmon;
|
static Monitor *mons, *selmon;
|
||||||
static Window root, wmcheckwin;
|
static Window root, wmcheckwin;
|
||||||
|
|
||||||
|
static xcb_connection_t *xcon;
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -294,12 +316,17 @@ applyrules(Client *c)
|
||||||
class = ch.res_class ? ch.res_class : broken;
|
class = ch.res_class ? ch.res_class : broken;
|
||||||
instance = ch.res_name ? ch.res_name : broken;
|
instance = ch.res_name ? ch.res_name : broken;
|
||||||
|
|
||||||
|
if (strstr(class, "Steam") || strstr(class, "steam_app_"))
|
||||||
|
c->issteam = 1;
|
||||||
|
|
||||||
for (i = 0; i < LENGTH(rules); i++) {
|
for (i = 0; i < LENGTH(rules); i++) {
|
||||||
r = &rules[i];
|
r = &rules[i];
|
||||||
if ((!r->title || strstr(c->name, r->title))
|
if ((!r->title || strstr(c->name, r->title))
|
||||||
&& (!r->class || strstr(class, r->class))
|
&& (!r->class || strstr(class, r->class))
|
||||||
&& (!r->instance || strstr(instance, r->instance)))
|
&& (!r->instance || strstr(instance, r->instance)))
|
||||||
{
|
{
|
||||||
|
c->isterminal = r->isterminal;
|
||||||
|
c->noswallow = r->noswallow;
|
||||||
c->isfloating = r->isfloating;
|
c->isfloating = r->isfloating;
|
||||||
c->tags |= r->tags;
|
c->tags |= r->tags;
|
||||||
for (m = mons; m && m->num != r->monitor; m = m->next);
|
for (m = mons; m && m->num != r->monitor; m = m->next);
|
||||||
|
@ -418,6 +445,53 @@ attachstack(Client *c)
|
||||||
c->mon->stack = 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
|
void
|
||||||
buttonpress(XEvent *e)
|
buttonpress(XEvent *e)
|
||||||
{
|
{
|
||||||
|
@ -436,9 +510,15 @@ buttonpress(XEvent *e)
|
||||||
}
|
}
|
||||||
if (ev->window == selmon->barwin) {
|
if (ev->window == selmon->barwin) {
|
||||||
i = x = 0;
|
i = x = 0;
|
||||||
do
|
unsigned int occ = 0;
|
||||||
|
for(c = m->clients; c; c=c->next)
|
||||||
|
occ |= 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]);
|
x += TEXTW(tags[i]);
|
||||||
while (ev->x >= x && ++i < LENGTH(tags));
|
} while (ev->x >= x && ++i < LENGTH(tags));
|
||||||
if (i < LENGTH(tags)) {
|
if (i < LENGTH(tags)) {
|
||||||
click = ClkTagBar;
|
click = ClkTagBar;
|
||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
|
@ -594,6 +674,7 @@ configurerequest(XEvent *e)
|
||||||
c->bw = ev->border_width;
|
c->bw = ev->border_width;
|
||||||
else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
|
else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
|
||||||
m = c->mon;
|
m = c->mon;
|
||||||
|
if (!c->issteam) {
|
||||||
if (ev->value_mask & CWX) {
|
if (ev->value_mask & CWX) {
|
||||||
c->oldx = c->x;
|
c->oldx = c->x;
|
||||||
c->x = m->mx + ev->x;
|
c->x = m->mx + ev->x;
|
||||||
|
@ -602,6 +683,7 @@ configurerequest(XEvent *e)
|
||||||
c->oldy = c->y;
|
c->oldy = c->y;
|
||||||
c->y = m->my + ev->y;
|
c->y = m->my + ev->y;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ev->value_mask & CWWidth) {
|
if (ev->value_mask & CWWidth) {
|
||||||
c->oldw = c->w;
|
c->oldw = c->w;
|
||||||
c->w = ev->width;
|
c->w = ev->width;
|
||||||
|
@ -659,6 +741,9 @@ destroynotify(XEvent *e)
|
||||||
|
|
||||||
if ((c = wintoclient(ev->window)))
|
if ((c = wintoclient(ev->window)))
|
||||||
unmanage(c, 1);
|
unmanage(c, 1);
|
||||||
|
|
||||||
|
else if ((c = swallowingclient(ev->window)))
|
||||||
|
unmanage(c->swallowing, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -725,13 +810,12 @@ drawbar(Monitor *m)
|
||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
for (i = 0; i < LENGTH(tags); i++) {
|
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]);
|
w = TEXTW(tags[i]);
|
||||||
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
|
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);
|
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;
|
x += w;
|
||||||
}
|
}
|
||||||
w = blw = TEXTW(m->ltsymbol);
|
w = blw = TEXTW(m->ltsymbol);
|
||||||
|
@ -744,6 +828,8 @@ drawbar(Monitor *m)
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
|
||||||
if (m->sel->isfloating)
|
if (m->sel->isfloating)
|
||||||
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
|
||||||
|
if (m->sel->issticky)
|
||||||
|
drw_polygon(drw, x + boxs, m->sel->isfloating ? boxs * 2 + boxw : boxs, stickyiconbb.x, stickyiconbb.y, boxw, boxw * stickyiconbb.y / stickyiconbb.x, stickyicon, LENGTH(stickyicon), Nonconvex, m->sel->tags & m->tagset[m->seltags]);
|
||||||
} else {
|
} else {
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||||
|
@ -837,6 +923,8 @@ focusmon(const Arg *arg)
|
||||||
unfocus(selmon->sel, 0);
|
unfocus(selmon->sel, 0);
|
||||||
selmon = m;
|
selmon = m;
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
|
if (selmon->sel)
|
||||||
|
XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w/2, selmon->sel->h/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -862,6 +950,7 @@ focusstack(const Arg *arg)
|
||||||
if (c) {
|
if (c) {
|
||||||
focus(c);
|
focus(c);
|
||||||
restack(selmon);
|
restack(selmon);
|
||||||
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1027,12 +1116,13 @@ killclient(const Arg *arg)
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
Client *c, *t = NULL;
|
Client *c, *t = NULL, *term = NULL;
|
||||||
Window trans = None;
|
Window trans = None;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
c = ecalloc(1, sizeof(Client));
|
c = ecalloc(1, sizeof(Client));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
|
c->pid = winpid(w);
|
||||||
/* geometry */
|
/* geometry */
|
||||||
c->x = c->oldx = wa->x;
|
c->x = c->oldx = wa->x;
|
||||||
c->y = c->oldy = wa->y;
|
c->y = c->oldy = wa->y;
|
||||||
|
@ -1047,6 +1137,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
} else {
|
} else {
|
||||||
c->mon = selmon;
|
c->mon = selmon;
|
||||||
applyrules(c);
|
applyrules(c);
|
||||||
|
term = termforwin(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
|
if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
|
||||||
|
@ -1083,6 +1174,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
c->mon->sel = c;
|
c->mon->sel = c;
|
||||||
arrange(c->mon);
|
arrange(c->mon);
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
|
if (term)
|
||||||
|
swallow(term, c);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,6 +1385,7 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
||||||
c->oldw = c->w; c->w = wc.width = w;
|
c->oldw = c->w; c->w = wc.width = w;
|
||||||
c->oldh = c->h; c->h = wc.height = h;
|
c->oldh = c->h; c->h = wc.height = h;
|
||||||
wc.border_width = c->bw;
|
wc.border_width = c->bw;
|
||||||
|
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||||
configure(c);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -1739,6 +1833,15 @@ togglefloating(const Arg *arg)
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglesticky(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (!selmon->sel)
|
||||||
|
return;
|
||||||
|
selmon->sel->issticky = !selmon->sel->issticky;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
@ -1785,6 +1888,20 @@ unmanage(Client *c, int destroyed)
|
||||||
Monitor *m = c->mon;
|
Monitor *m = c->mon;
|
||||||
XWindowChanges wc;
|
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);
|
detach(c);
|
||||||
detachstack(c);
|
detachstack(c);
|
||||||
if (!destroyed) {
|
if (!destroyed) {
|
||||||
|
@ -1799,9 +1916,12 @@ unmanage(Client *c, int destroyed)
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
}
|
}
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
|
if (!s) {
|
||||||
|
arrange(m);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
updateclientlist();
|
updateclientlist();
|
||||||
arrange(m);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1849,8 +1969,9 @@ updatebarpos(Monitor *m)
|
||||||
m->wh -= bh;
|
m->wh -= bh;
|
||||||
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
||||||
m->wy = m->topbar ? m->wy + bh : m->wy;
|
m->wy = m->topbar ? m->wy + bh : m->wy;
|
||||||
} else
|
} else {
|
||||||
m->by = -bh;
|
m->by = -bh;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2065,6 +2186,136 @@ view(const Arg *arg)
|
||||||
arrange(selmon);
|
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 *
|
Client *
|
||||||
wintoclient(Window w)
|
wintoclient(Window w)
|
||||||
{
|
{
|
||||||
|
@ -2156,10 +2407,12 @@ main(int argc, char *argv[])
|
||||||
fputs("warning: no locale support\n", stderr);
|
fputs("warning: no locale support\n", stderr);
|
||||||
if (!(dpy = XOpenDisplay(NULL)))
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
die("dwm: cannot open display");
|
die("dwm: cannot open display");
|
||||||
|
if (!(xcon = XGetXCBConnection(dpy)))
|
||||||
|
die("dwm: cannot get xcb connection\n");
|
||||||
checkotherwm();
|
checkotherwm();
|
||||||
setup();
|
setup();
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
if (pledge("stdio rpath proc exec ps", NULL) == -1)
|
||||||
die("pledge");
|
die("pledge");
|
||||||
#endif /* __OpenBSD__ */
|
#endif /* __OpenBSD__ */
|
||||||
scan();
|
scan();
|
||||||
|
@ -2168,3 +2421,66 @@ main(int argc, char *argv[])
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
bstack(Monitor *m) {
|
||||||
|
int w, h, mh, mx, tx, ty, tw;
|
||||||
|
unsigned int i, n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
tw = m->ww / (n - m->nmaster);
|
||||||
|
ty = m->wy + mh;
|
||||||
|
} else {
|
||||||
|
mh = m->wh;
|
||||||
|
tw = m->ww;
|
||||||
|
ty = m->wy;
|
||||||
|
}
|
||||||
|
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
mx += WIDTH(c);
|
||||||
|
} else {
|
||||||
|
h = m->wh - mh;
|
||||||
|
resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
|
||||||
|
if (tw != m->ww)
|
||||||
|
tx += WIDTH(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bstackhoriz(Monitor *m) {
|
||||||
|
int w, mh, mx, tx, ty, th;
|
||||||
|
unsigned int i, n;
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
|
if (n == 0)
|
||||||
|
return;
|
||||||
|
if (n > m->nmaster) {
|
||||||
|
mh = m->nmaster ? m->mfact * m->wh : 0;
|
||||||
|
th = (m->wh - mh) / (n - m->nmaster);
|
||||||
|
ty = m->wy + mh;
|
||||||
|
} else {
|
||||||
|
th = mh = m->wh;
|
||||||
|
ty = m->wy;
|
||||||
|
}
|
||||||
|
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
|
||||||
|
if (i < m->nmaster) {
|
||||||
|
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
|
||||||
|
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
|
||||||
|
mx += WIDTH(c);
|
||||||
|
} else {
|
||||||
|
resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
|
||||||
|
if (th != m->wh)
|
||||||
|
ty += HEIGHT(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue