Compare commits
No commits in common. "377f064d3ec4983a443650d5203618a746c9e0e8" and "16dc543e11cde35a56ff126a0c55e5e99f02d4fe" have entirely different histories.
377f064d3e
...
16dc543e11
10 changed files with 100 additions and 460 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
*.o
|
||||
/patches
|
||||
dwm
|
||||
*.orig
|
||||
*.rej
|
1
LICENSE
1
LICENSE
|
@ -18,7 +18,6 @@ MIT/X Consortium License
|
|||
© 2015-2016 Eric Pruitt <eric.pruitt@gmail.com>
|
||||
© 2016-2017 Markus Teich <markus.teich@stusta.mhn.de>
|
||||
© 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
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
|
48
README
Normal file
48
README
Normal file
|
@ -0,0 +1,48 @@
|
|||
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
37
README.md
|
@ -1,37 +0,0 @@
|
|||
# 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,9 +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 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" };
|
||||
|
@ -19,8 +17,6 @@ static const char *colors[][3] = {
|
|||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||
[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 */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
@ -30,11 +26,9 @@ static const Rule rules[] = {
|
|||
* 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 },
|
||||
{ "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 */
|
||||
/* class instance title tags mask isfloating monitor */
|
||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
|
@ -48,8 +42,6 @@ static const Layout layouts[] = {
|
|||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "TTT", bstack },
|
||||
{ "===", bstackhoriz },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
|
@ -85,11 +77,8 @@ 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_u, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_s, togglesticky, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||
|
|
49
config.h
49
config.h
|
@ -6,9 +6,8 @@ static const unsigned int gappx = 8; /* 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 */
|
||||
static const int swallowfloating = 0;
|
||||
static const char *fonts[] = { "JetBrains Mono NF:style=medium:size=11" };
|
||||
static const char dmenufont[] = "JetBrains Mono NF:style=medium:size=11";
|
||||
static const char *fonts[] = { "JetBrains Mono:style=medium:size=11" };
|
||||
static const char dmenufont[] = "JetBrains Mono:stlye=medium:size=11";
|
||||
// gruvbox
|
||||
static const char fg[] = "#ebdbb2";
|
||||
static const char bg_normal[] = "#3c3836";
|
||||
|
@ -27,27 +26,23 @@ static const char *colors[][3] = {
|
|||
[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 */
|
||||
static const char *tags[] = { "!", "@", "#", "$", "%", "^", "&", "*", "(" };
|
||||
static const char *tags[] = { "!", "@", "#", "$", "%", "^", "&", "*" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
/* class instance title tags mask isfloating isterminal noswallow monitor */
|
||||
{ "zoom", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "Mars", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "Engrampa", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "chatterino",NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "Wiimmfi-RPC v1.7.5",NULL,NULL, 0, 1, 0, 0, -1 },
|
||||
{ "minecraft-launcher",NULL,NULL, 0, 1, 0, 0, -1 },
|
||||
{ "nitrogen", NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "Galculator",NULL, NULL, 0, 1, 0, 0, -1 },
|
||||
{ "Alacritty",NULL, NULL, 0, 0, 1, 0, -1 },
|
||||
/* class instance title tags mask isfloating monitor */
|
||||
{ "zoom", NULL, NULL, 0, 1, -1 },
|
||||
{ "Mars", NULL, NULL, 0, 1, -1 },
|
||||
{ "Engrampa", NULL, NULL, 0, 1, -1 },
|
||||
{ "chatterino",NULL, NULL, 0, 1, -1 },
|
||||
{ "Wiimmfi-RPC v1.7.5",NULL,NULL, 0, 1, -1 },
|
||||
{ "minecraft-launcher",NULL,NULL, 0, 1, -1 },
|
||||
{ "nitrogen", NULL, NULL, 0, 1, -1 },
|
||||
{ "Galculator",NULL, NULL, 0, 1, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
|
@ -61,13 +56,9 @@ static const Layout layouts[] = {
|
|||
{ "[]=", tile }, /* first entry is default */
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "TTT", bstack },
|
||||
{ "===", bstackhoriz },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
// Mod4Mask is super
|
||||
// Mod1Mask is alt/meta
|
||||
#define MODKEY Mod4Mask
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
|
@ -80,23 +71,21 @@ static const Layout layouts[] = {
|
|||
|
||||
/* commands */
|
||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||
//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", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, 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 *brightnessup[] = { "brightness-up.sh", NULL };
|
||||
static const char *brightnessdown[] = { "brightness-down.sh", NULL };
|
||||
static const char *screenshooter[] = { "screenshot.sh", NULL };
|
||||
static const char *volup[] = { "volup.sh", NULL };
|
||||
static const char *voldown[] = { "voldown.sh", NULL };
|
||||
//static const char *firefox[] = { "firefox-bin", NULL };
|
||||
//static const char *volmute[] = { "volmute.sh", NULL }; (replaced with *next[] for different keyboards)
|
||||
static const char *firefox[] = { "librewolf-bin", NULL };
|
||||
static const char *slock[] = { "slock", NULL };
|
||||
static const char *playpause[] = { "playerctl", "play-pause", NULL };
|
||||
static const char *next[] = { "f9.sh", 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[] = {
|
||||
/* modifier key function argument */
|
||||
|
@ -105,6 +94,7 @@ static Key keys[] = {
|
|||
{ MODKEY|ShiftMask, XK_f, spawn, {.v = firefox } },
|
||||
{ MODKEY|ShiftMask, XK_Escape, spawn, {.v = slock } },
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
// { MODKEY, XK_w, tabmode, {-1} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
|
@ -117,11 +107,8 @@ 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_u, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_s, togglesticky, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||
|
@ -139,9 +126,6 @@ static Key keys[] = {
|
|||
{ MODKEY, XK_F7, spawn, {.v = previous } },
|
||||
{ MODKEY, XK_F8, spawn, {.v = playpause } },
|
||||
{ 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_2, 1)
|
||||
TAGKEYS( XK_3, 2)
|
||||
|
@ -151,6 +135,7 @@ static Key keys[] = {
|
|||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ShiftMask, XK_BackSpace, quit, {0} },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
|
|
|
@ -20,11 +20,10 @@ 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} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
|
|
21
drw.c
21
drw.c
|
@ -203,7 +203,6 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, dest))
|
||||
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
|
||||
|
@ -249,26 +248,6 @@ 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);
|
||||
}
|
||||
|
||||
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
|
||||
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,7 +52,6 @@ void drw_setscheme(Drw *drw, Clr *scm);
|
|||
|
||||
/* Drawing functions */
|
||||
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);
|
||||
|
||||
/* Map functions */
|
||||
|
|
344
dwm.c
344
dwm.c
|
@ -40,12 +40,6 @@
|
|||
#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"
|
||||
|
@ -55,11 +49,11 @@
|
|||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
|
||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]) || C->issticky)
|
||||
#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 + gappx)
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
|
||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||
#define TAGMASK ((1 << LENGTH(tags)) - 1)
|
||||
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||
|
||||
|
@ -98,12 +92,9 @@ 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, issticky, isterminal, noswallow;
|
||||
pid_t pid;
|
||||
int issteam;
|
||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||
Client *next;
|
||||
Client *snext;
|
||||
Client *swallowing;
|
||||
Monitor *mon;
|
||||
Window win;
|
||||
};
|
||||
|
@ -148,8 +139,6 @@ typedef struct {
|
|||
const char *title;
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
int isterminal;
|
||||
int noswallow;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
|
@ -225,7 +214,6 @@ static void tagmon(const Arg *arg);
|
|||
static void tile(Monitor *);
|
||||
static void togglebar(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglesticky(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unfocus(Client *c, int setfocus);
|
||||
|
@ -248,14 +236,6 @@ 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);
|
||||
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 */
|
||||
static const char broken[] = "broken";
|
||||
|
@ -291,8 +271,6 @@ 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"
|
||||
|
||||
|
@ -316,17 +294,12 @@ applyrules(Client *c)
|
|||
class = ch.res_class ? ch.res_class : 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++) {
|
||||
r = &rules[i];
|
||||
if ((!r->title || strstr(c->name, r->title))
|
||||
&& (!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);
|
||||
|
@ -445,53 +418,6 @@ 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)
|
||||
{
|
||||
|
@ -510,15 +436,9 @@ buttonpress(XEvent *e)
|
|||
}
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = 0;
|
||||
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;
|
||||
do
|
||||
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;
|
||||
|
@ -674,7 +594,6 @@ configurerequest(XEvent *e)
|
|||
c->bw = ev->border_width;
|
||||
else if (c->isfloating || !selmon->lt[selmon->sellt]->arrange) {
|
||||
m = c->mon;
|
||||
if (!c->issteam) {
|
||||
if (ev->value_mask & CWX) {
|
||||
c->oldx = c->x;
|
||||
c->x = m->mx + ev->x;
|
||||
|
@ -683,7 +602,6 @@ configurerequest(XEvent *e)
|
|||
c->oldy = c->y;
|
||||
c->y = m->my + ev->y;
|
||||
}
|
||||
}
|
||||
if (ev->value_mask & CWWidth) {
|
||||
c->oldw = c->w;
|
||||
c->w = ev->width;
|
||||
|
@ -741,9 +659,6 @@ destroynotify(XEvent *e)
|
|||
|
||||
if ((c = wintoclient(ev->window)))
|
||||
unmanage(c, 1);
|
||||
|
||||
else if ((c = swallowingclient(ev->window)))
|
||||
unmanage(c->swallowing, 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -810,12 +725,13 @@ drawbar(Monitor *m)
|
|||
}
|
||||
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 = blw = TEXTW(m->ltsymbol);
|
||||
|
@ -828,8 +744,6 @@ drawbar(Monitor *m)
|
|||
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);
|
||||
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 {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
|
@ -923,8 +837,6 @@ focusmon(const Arg *arg)
|
|||
unfocus(selmon->sel, 0);
|
||||
selmon = m;
|
||||
focus(NULL);
|
||||
if (selmon->sel)
|
||||
XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w/2, selmon->sel->h/2);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -950,7 +862,6 @@ focusstack(const Arg *arg)
|
|||
if (c) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w/2, c->h/2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1116,13 +1027,12 @@ killclient(const Arg *arg)
|
|||
void
|
||||
manage(Window w, XWindowAttributes *wa)
|
||||
{
|
||||
Client *c, *t = NULL, *term = NULL;
|
||||
Client *c, *t = 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;
|
||||
|
@ -1137,7 +1047,6 @@ manage(Window w, XWindowAttributes *wa)
|
|||
} else {
|
||||
c->mon = selmon;
|
||||
applyrules(c);
|
||||
term = termforwin(c);
|
||||
}
|
||||
|
||||
if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
|
||||
|
@ -1174,8 +1083,6 @@ manage(Window w, XWindowAttributes *wa)
|
|||
c->mon->sel = c;
|
||||
arrange(c->mon);
|
||||
XMapWindow(dpy, c->win);
|
||||
if (term)
|
||||
swallow(term, c);
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
|
@ -1385,7 +1292,6 @@ resizeclient(Client *c, int x, int y, int w, int h)
|
|||
c->oldw = c->w; c->w = wc.width = w;
|
||||
c->oldh = c->h; c->h = wc.height = h;
|
||||
wc.border_width = c->bw;
|
||||
|
||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
|
@ -1833,15 +1739,6 @@ togglefloating(const Arg *arg)
|
|||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
togglesticky(const Arg *arg)
|
||||
{
|
||||
if (!selmon->sel)
|
||||
return;
|
||||
selmon->sel->issticky = !selmon->sel->issticky;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
|
@ -1888,20 +1785,6 @@ 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) {
|
||||
|
@ -1916,12 +1799,9 @@ unmanage(Client *c, int destroyed)
|
|||
XUngrabServer(dpy);
|
||||
}
|
||||
free(c);
|
||||
|
||||
if (!s) {
|
||||
arrange(m);
|
||||
focus(NULL);
|
||||
updateclientlist();
|
||||
}
|
||||
arrange(m);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1969,10 +1849,9 @@ updatebarpos(Monitor *m)
|
|||
m->wh -= bh;
|
||||
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
||||
m->wy = m->topbar ? m->wy + bh : m->wy;
|
||||
} else {
|
||||
} else
|
||||
m->by = -bh;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
updateclientlist()
|
||||
|
@ -2186,136 +2065,6 @@ 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)
|
||||
{
|
||||
|
@ -2407,12 +2156,10 @@ 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 ps", NULL) == -1)
|
||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||
die("pledge");
|
||||
#endif /* __OpenBSD__ */
|
||||
scan();
|
||||
|
@ -2421,66 +2168,3 @@ main(int argc, char *argv[])
|
|||
XCloseDisplay(dpy);
|
||||
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