From 37b1b54ab9b79a144d6224264f39ad946aea5d4e Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 2 Oct 2019 00:03:21 +0200 Subject: [PATCH] Adding fullscreen, holdbar and unfloatvisible patches --- README.md | 13 ++++++++++++- config.def.h | 15 +++++++++++++++ dwm.c | 8 ++++---- patch/fullscreen.c | 13 +++++++++++++ patch/fullscreen.h | 1 + patch/holdbar.c | 31 +++++++++++++++++++++++++++++++ patch/holdbar.h | 3 +++ patch/include.c | 12 ++++++++++++ patch/include.h | 12 ++++++++++++ patch/unfloatvisible.c | 14 ++++++++++++++ patch/unfloatvisible.h | 1 + patches.h | 19 +++++++++++++++++++ 12 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 patch/fullscreen.c create mode 100644 patch/fullscreen.h create mode 100644 patch/holdbar.c create mode 100644 patch/holdbar.h create mode 100644 patch/unfloatvisible.c create mode 100644 patch/unfloatvisible.h diff --git a/README.md b/README.md index 1599f7e..484e223 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2019-10-01 - Added leftlayout patch +2019-10-01 - Added leftlayout, fullscreen, holdbar and unfloatvisible patches 2019-09-30 - Replaced flextile with flextile-deluxe, refactored monitor rules to support predetermined layouts per tag @@ -102,6 +102,14 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - by default, dwm responds to \_NET_ACTIVE_WINDOW client messages by setting the urgency bit on the named window - this patch activates the window instead + - [fullscreen](https://dwm.suckless.org/patches/fullscreen/) + - applies the monocle layout with the focused client on top and hides the bar + - when pressed again it shows the bar and restores the layout that was active before going fullscreen + + - [holdbar](http://dwm.suckless.org/patches/holdbar/) + - with this patch dwm's built-in status bar is only shown when HOLDKEY is pressed + - additionally the bar will now overlay the display + - [leftlayout](http://dwm.suckless.org/patches/leftlayout/) - moves the layout symbol in the status bar to the left hand side @@ -164,6 +172,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [togglefullscreen](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-togglefullscreen-6.2.diff) - allows you to toggle fullscreen on and off using a single shortcut key + - [unfloatvisible](https://dwm.suckless.org/patches/unfloatvisible/) + - resets isfloating on any visible windows that have it set and optionally also applies a layout + - [urgentborder](https://dwm.suckless.org/patches/urgentborder/) - this patch makes "urgent" windows have different colors diff --git a/config.def.h b/config.def.h index 7ec5e3d..bf55176 100644 --- a/config.def.h +++ b/config.def.h @@ -10,7 +10,11 @@ static const unsigned int gappoh = 10 /* horiz outer gap between windo static const unsigned int gappov = 30 /* vert outer gap between windows and screen edge */ static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ #endif // VANITYGAPS_PATCH +#if HOLDBAR_PATCH +static const int showbar = 0; /* 0 means no bar */ +#else static const int showbar = 1; /* 0 means no bar */ +#endif // HOLDBAR_PATCH static const int topbar = 1; /* 0 means bottom bar */ #if FOCUSONCLICK_PATCH static const int focusonwheel = 0; @@ -290,6 +294,10 @@ static const Layout layouts[] = { { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, #endif // COMBO_PATCH +#if HOLDBAR_PATCH +#define HOLDKEY 0 // replace 0 with the keysym to activate holdbar +#endif // HOLDBAR_PATCH + /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } @@ -350,6 +358,9 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_r, self_restart, {0} }, #endif // SELFRESTART_PATCH { MODKEY|ShiftMask, XK_q, quit, {0} }, + #if HOLDBAR_PATCH + { 0, HOLDKEY, holdbar, {0} }, + #endif // HOLDBAR_PATCH #if WINVIEW_PATCH { MODKEY, XK_o, winview, {0} }, #endif // WINVIEW_PATCH @@ -368,6 +379,10 @@ static Key keys[] = { #endif // FLEXTILE_DELUXE_LAYOUT { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + #if UNFLOATVISIBLE_PATCH + { MODKEY|Mod4Mask, XK_space, unfloatvisible, {0} }, + { MODKEY|ShiftMask, XK_t, unfloatvisible, {.v = &layouts[0]} }, + #endif // UNFLOATVISIBLE_PATCH #if TOGGLEFULLSCREEN_PATCH { MODKEY, XK_y, togglefullscreen, {0} }, #endif // TOGGLEFULLSCREEN_PATCH diff --git a/dwm.c b/dwm.c index 8fc13ab..55b89e6 100644 --- a/dwm.c +++ b/dwm.c @@ -372,9 +372,9 @@ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; static void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, - #if COMBO_PATCH + #if COMBO_PATCH || HOLDBAR_PATCH [ButtonRelease] = keyrelease, - #endif // COMBO_PATCH + #endif // COMBO_PATCH / HOLDBAR_PATCH [ClientMessage] = clientmessage, [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, @@ -385,9 +385,9 @@ static void (*handler[LASTEvent]) (XEvent *) = { [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, - #if COMBO_PATCH + #if COMBO_PATCH || HOLDBAR_PATCH [KeyRelease] = keyrelease, - #endif // COMBO_PATCH + #endif // COMBO_PATCH / HOLDBAR_PATCH [MappingNotify] = mappingnotify, [MapRequest] = maprequest, #if !FOCUSONCLICK_PATCH diff --git a/patch/fullscreen.c b/patch/fullscreen.c new file mode 100644 index 0000000..3ddb0e1 --- /dev/null +++ b/patch/fullscreen.c @@ -0,0 +1,13 @@ +Layout *last_layout; + +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 + } else { + setlayout(&((Arg) { .v = last_layout })); + } + togglebar(arg); +} \ No newline at end of file diff --git a/patch/fullscreen.h b/patch/fullscreen.h new file mode 100644 index 0000000..b380c2e --- /dev/null +++ b/patch/fullscreen.h @@ -0,0 +1 @@ +static void fullscreen(const Arg *arg); \ No newline at end of file diff --git a/patch/holdbar.c b/patch/holdbar.c new file mode 100644 index 0000000..a7727b8 --- /dev/null +++ b/patch/holdbar.c @@ -0,0 +1,31 @@ +void +holdbar(const Arg *arg) +{ + selmon->showbar = 1; + updateholdbarpos(selmon); + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); +} + +void +keyrelease(XEvent *e) +{ + if (e->xkey.keycode == XKeysymToKeycode(dpy, HOLDKEY)) { + selmon->showbar = 0; + updateholdbarpos(selmon); + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); + arrange(selmon); + } +} + +void +updateholdbarpos(Monitor *m) +{ + m->wy = m->my; + m->wh = m->mh; + if (m->showbar) { + m->by = m->topbar ? m->wy : m->wy + m->wh - bh; + m->wy = m->topbar ? m->wy - bh + bh : m->wy; + } else { + m->by = -bh; + } +} \ No newline at end of file diff --git a/patch/holdbar.h b/patch/holdbar.h new file mode 100644 index 0000000..719b9ea --- /dev/null +++ b/patch/holdbar.h @@ -0,0 +1,3 @@ +static void keyrelease(XEvent *e); +static void holdbar(const Arg *arg); +static void updateholdbarpos(Monitor *m); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 9fd267f..bb41382 100644 --- a/patch/include.c +++ b/patch/include.c @@ -36,6 +36,14 @@ #include "ewmhtags.c" #endif +#if FULLSCREEN_PATCH +#include "fullscreen.c" +#endif + +#if HOLDBAR_PATCH +#include "holdbar.c" +#endif + #if PERTAG_PATCH #include "pertag.c" #endif @@ -78,6 +86,10 @@ #include "togglefullscreen.c" #endif +#if UNFLOATVISIBLE_PATCH +#include "unfloatvisible.c" +#endif + #if VANITYGAPS_PATCH #include "vanitygaps.c" #endif diff --git a/patch/include.h b/patch/include.h index cc6ac94..d19423e 100644 --- a/patch/include.h +++ b/patch/include.h @@ -36,6 +36,14 @@ #include "ewmhtags.h" #endif +#if FULLSCREEN_PATCH +#include "fullscreen.h" +#endif + +#if HOLDBAR_PATCH +#include "holdbar.h" +#endif + #if PERTAG_PATCH #include "pertag.h" #endif @@ -78,6 +86,10 @@ #include "togglefullscreen.h" #endif +#if UNFLOATVISIBLE_PATCH +#include "unfloatvisible.h" +#endif + #if VANITYGAPS_PATCH #include "vanitygaps.h" #endif diff --git a/patch/unfloatvisible.c b/patch/unfloatvisible.c new file mode 100644 index 0000000..8f0360d --- /dev/null +++ b/patch/unfloatvisible.c @@ -0,0 +1,14 @@ +void +unfloatvisible(const Arg *arg) +{ + Client *c; + + for (c = selmon->clients; c; c = c->next) + if (ISVISIBLE(c) && c->isfloating) + c->isfloating = c->isfixed; + + if (arg && arg->v) + setlayout(arg); + else + arrange(selmon); +} \ No newline at end of file diff --git a/patch/unfloatvisible.h b/patch/unfloatvisible.h new file mode 100644 index 0000000..690b6ef --- /dev/null +++ b/patch/unfloatvisible.h @@ -0,0 +1 @@ +static void unfloatvisible(const Arg *arg); \ No newline at end of file diff --git a/patches.h b/patches.h index f4548f7..d43169e 100644 --- a/patches.h +++ b/patches.h @@ -141,6 +141,19 @@ */ #define FOCUSONNETACTIVE_PATCH 0 +/* Applies the monocle layout with the focused client on top and hides the bar. When pressed + * again it shows the bar and restores the layout that was active before going fullscreen. + * NB: This patch assumes that the third layout is monocle and that the bar is shown. + * https://dwm.suckless.org/patches/fullscreen/ + */ +#define FULLSCREEN_PATCH 0 + +/* With this patch dwm's built-in status bar is only shown when HOLDKEY is pressed + * and the bar will now overlay the display. + * http://dwm.suckless.org/patches/holdbar/ + */ +#define HOLDBAR_PATCH 0 + /* Moves the layout symbol in the status bar to the left hand side. * http://dwm.suckless.org/patches/leftlayout/ */ @@ -273,6 +286,12 @@ */ #define TOGGLEFULLSCREEN_PATCH 0 +/* This patch resets isfloating on any visible windows that have it set. + * Optionally also applies a layout. + * https://dwm.suckless.org/patches/unfloatvisible/ + */ +#define UNFLOATVISIBLE_PATCH 0 + /* This patch makes "urgent" windows have different colors. * https://dwm.suckless.org/patches/urgentborder/ */