Adding nomodbuttons patch

This commit is contained in:
bakkeby 2020-09-18 10:53:07 +02:00
parent 8aa21b0311
commit 00320fb842
8 changed files with 46 additions and 2 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-09-18 - Added the nomodbuttons patch allowing for toggleable mouse button bindings that have no modifiers
2020-09-10 - Added the anybar patch (with experimental support for dwm bar(s) + anybar)
2020-09-09 - Added the bar border patch
@ -408,6 +410,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- enable modifying dmenu in config.def.h which resulted previously in a compilation error because two lines of code hardcode dmenu into dwm
- allows complete removal of dmenu, should you want to do that
- nomodbuttons
- allows for toggleable client button bindings that have no modifiers
- this can, for example, allow you to move or resize using the mouse alone without holding down a modifier key, which can be practical if you have extra buttons on your mouse
- [no_transparent_borders](https://github.com/szatanjl/dwm/commit/1529909466206016f2101457bbf37c67195714c8)
- when terminals have transparency then their borders also become transparent
- this patch ensures that borders have no transparency

View File

@ -11,6 +11,9 @@ static const unsigned int snap = 32; /* snap pixel */
#if SWALLOW_PATCH
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
#endif // SWALLOW_PATCH
#if NO_MOD_BUTTONS_PATCH
static int nomodbuttons = 1; /* allow client mouse button bindings that have no modifier */
#endif // NO_MOD_BUTTONS_PATCH
#if VANITYGAPS_PATCH
static const unsigned int gappih = 20; /* horiz inner gap between windows */
static const unsigned int gappiv = 10; /* vert inner gap between windows */
@ -882,7 +885,7 @@ static Key keys[] = {
{ MODKEY|Mod5Mask, XK_Tab, rotatelayoutaxis, {.i = -2 } }, /* flextile, 2 = master axis */
{ MODKEY|Mod5Mask|ShiftMask, XK_Tab, rotatelayoutaxis, {.i = -3 } }, /* flextile, 3 = stack axis */
{ MODKEY|Mod5Mask|Mod1Mask, XK_Tab, rotatelayoutaxis, {.i = -4 } }, /* flextile, 4 = secondary stack axis */
{ MODKEY|ControlMask, XK_Return, mirrorlayout, {0} }, /* flextile, flip master and stack areas */
{ MODKEY|ControlMask, XK_Return, mirrorlayout, {0} }, /* flextile, flip master and stack areas */
#endif // FLEXTILE_DELUXE_LAYOUT
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
@ -893,6 +896,9 @@ static Key keys[] = {
{ MODKEY|ControlMask|ShiftMask, XK_k, toggleverticalmax, {0} },
{ MODKEY|ControlMask, XK_m, togglemax, {0} },
#endif // MAXIMIZE_PATCH
#if NO_MOD_BUTTONS_PATCH
{ MODKEY|ShiftMask, XK_Escape, togglenomodbuttons, {0} },
#endif // NO_MOD_BUTTONS_PATCH
#if SCRATCHPADS_PATCH
{ MODKEY, XK_grave, togglescratch, {.ui = 0 } },
{ MODKEY|ControlMask, XK_grave, togglescratch, {.ui = 1 } },

6
dwm.c
View File

@ -1992,7 +1992,11 @@ grabbuttons(Client *c, int focused)
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
BUTTONMASK, GrabModeSync, GrabModeSync, None, None);
for (i = 0; i < LENGTH(buttons); i++)
if (buttons[i].click == ClkClientWin)
if (buttons[i].click == ClkClientWin
#if NO_MOD_BUTTONS_PATCH
&& (nomodbuttons || buttons[i].mask != 0)
#endif // NO_MOD_BUTTONS_PATCH
)
for (j = 0; j < LENGTH(modifiers); j++)
XGrabButton(dpy, buttons[i].button,
buttons[i].mask | modifiers[j],

View File

@ -174,6 +174,9 @@
#if MOVESTACK_PATCH
#include "movestack.c"
#endif
#if NO_MOD_BUTTONS_PATCH
#include "nomodbuttons.c"
#endif
#if PERTAG_PATCH
#include "pertag.c"
#endif

View File

@ -170,6 +170,9 @@
#if MOVESTACK_PATCH
#include "movestack.h"
#endif
#if NO_MOD_BUTTONS_PATCH
#include "nomodbuttons.h"
#endif
#if PERTAG_PATCH
#include "pertag.h"
#endif

7
patch/nomodbuttons.c Normal file
View File

@ -0,0 +1,7 @@
void
togglenomodbuttons(const Arg *arg)
{
nomodbuttons = !nomodbuttons;
if (selmon->sel)
grabbuttons(selmon->sel, 1);
}

1
patch/nomodbuttons.h Normal file
View File

@ -0,0 +1 @@
static void togglenomodbuttons(const Arg *arg);

View File

@ -646,6 +646,20 @@
*/
#define NODMENU_PATCH 0
/* This patch allows for toggleable client button bindings that have no modifiers.
* This can, for example, allow you to move or resize using the mouse alone without holding
* down a modifier key. This can be practical if you have extra buttons on your mouse.
* While you can use button bindings with no modifiers without this patch in a bare dwm,
* those buttons are then unavailable for use within the application itself so being able to
* toggle these on and off can be necessary in certain situations (e.g. being able to use
* back and forward buttons in a browser).
* Example bindings:
* { ClkClientWin, 0, Button8, movemouse, {0} },
* { ClkClientWin, 0, Button9, resizemouse, {0} },
*/
#define NO_MOD_BUTTONS_PATCH 0
/* When terminals have transparency then their borders also become transparent.
* This patch ensures that borders have no transparency. Note that this patch is
* only relevant if you are not using the alpha patch.