Adding quitonlyonempty patch and made monocle layout position configurable for fullscreen and warp patches

This commit is contained in:
bakkeby 2019-10-03 22:58:58 +02:00
parent 9ebd9c8397
commit 40000bba1c
5 changed files with 39 additions and 3 deletions

View File

@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2019-10-03 - Added onlyquitonempty patch
2019-10-02 - Added restartsig, emptyview, focusurgent and focusadjacenttag patches
2019-10-01 - Added leftlayout, fullscreen, holdbar and unfloatvisible patches
@ -135,6 +137,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- adds rules per monitor, e.g. have default layouts per monitor
- the use case for this is if the second monitor is vertical (i.e. rotated) then you may want to use a different default layout for this monitor than what is used for the main monitor (for example normal vertical split for main monitor and horizontal split for the second)
- [onlyquitonempty](https://dwm.suckless.org/patches/onlyquitonempty/)
- makes it so dwm will only exit via quit() if no windows are open (in order to prevent accidental loss of work)
- [pertag](https://dwm.suckless.org/patches/pertag/)
- adds nmaster, mfact, layouts and more per tag rather than per monitor

View File

@ -29,6 +29,9 @@ 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 */
#endif // SYSTRAY_PATCH
#if ONLYQUITONEMPTY_PATCH
static const int quit_empty_window_count = 2; /* only allow dwm to quit if no windows are open, value here represents number of deamons */
#endif // ONLYQUITONEMPTY_PATCH
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
@ -210,6 +213,9 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi
#define FORCE_VSPLIT 1
#endif
/* Position of the monocle layout in the layouts variable, used by warp and fullscreen patches */
#define MONOCLE_LAYOUT_POS 2
#if FLEXTILE_DELUXE_LAYOUT
static const Layout layouts[] = {
/* symbol arrange function, { nmaster, nstack, layout, master axis, stack axis, secondary stack axis } */

21
dwm.c
View File

@ -1978,11 +1978,30 @@ propertynotify(XEvent *e)
void
quit(const Arg *arg)
{
#if ONLYQUITONEMPTY_PATCH
unsigned int n;
Window *junk = malloc(1);
XQueryTree(dpy, root, junk, junk, &junk, &n);
if (n == quit_empty_window_count) {
#if RESTARTSIG_PATCH
if (arg->i)
restart = 1;
#endif // RESTARTSIG_PATCH
running = 0;
}
else
printf("[dwm] not exiting (n=%d)\n", n);
free(junk);
#else
#if RESTARTSIG_PATCH
if (arg->i)
restart = 1;
#endif // RESTARTSIG_PATCH
running = 0;
#endif // ONLYQUITONEMPTY_PATCH
}
Monitor *
@ -2153,7 +2172,7 @@ restack(Monitor *m)
XSync(dpy, False);
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
#if WARP_PATCH
if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[2]) // <-- NB! hardcoded monocle
if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && selmon->lt[selmon->sellt] != &layouts[MONOCLE_LAYOUT_POS])
warp(m->sel);
#endif // WARP_PATCH
}

View File

@ -1,11 +1,11 @@
Layout *last_layout;
Layout *last_layout = &layouts[0];
void
fullscreen(const Arg *arg)
{
if (selmon->showbar) {
for (last_layout = (Layout *)layouts; last_layout != selmon->lt[selmon->sellt]; last_layout++);
setlayout(&((Arg) { .v = &layouts[2] })); // <-- NB! hardcoded monocle
setlayout(&((Arg) { .v = &layouts[MONOCLE_LAYOUT_POS] }));
} else {
setlayout(&((Arg) { .v = last_layout }));
}

View File

@ -197,6 +197,12 @@
*/
#define MONITOR_RULES_PATCH 0
/* This patch makes it so dwm will only exit via quit() if no windows are open.
* This is to prevent you accidentally losing all your work.
* https://dwm.suckless.org/patches/onlyquitonempty/
*/
#define ONLYQUITONEMPTY_PATCH 0
/* The pertag patch adds nmaster, mfacts and layouts per tag rather than per
* monitor (default).
* https://dwm.suckless.org/patches/pertag/