mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
dwmc: Adding external control to set gaps
This commit is contained in:
parent
2b332f7199
commit
d7814e3a3e
@ -514,6 +514,9 @@ static Signal signals[] = {
|
||||
{ "toggleverticalexpand", toggleverticalexpand },
|
||||
{ "togglemaximize", togglemaximize },
|
||||
#endif // EXRESIZE_PATCH
|
||||
#if KEYMODES_PATCH
|
||||
{ "setkeymode", setkeymode },
|
||||
#endif // KEYMODES_PATCH
|
||||
#if TRANSFER_PATCH
|
||||
{ "transfer", transfer },
|
||||
#endif // TRANSFER_PATCH
|
||||
@ -532,6 +535,7 @@ static Signal signals[] = {
|
||||
{ "incrovgaps", incrovgaps },
|
||||
{ "togglegaps", togglegaps },
|
||||
{ "defaultgaps", defaultgaps },
|
||||
{ "setgaps", setgapsex },
|
||||
#endif // VANITYGAPS_PATCH
|
||||
{ "view", view },
|
||||
{ "viewall", viewallex },
|
||||
|
25
patch/dwmc
25
patch/dwmc
@ -47,7 +47,7 @@ case $# in
|
||||
signal $1
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command or missing one argument."
|
||||
echo "Unknown command ($1) or missing one argument."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@ -58,6 +58,7 @@ case $# in
|
||||
explace) ;&
|
||||
moveplace) ;&
|
||||
mpdchange) ;&
|
||||
setkeymode) ;&
|
||||
switchtag) ;&
|
||||
togglescratch) ;&
|
||||
view)
|
||||
@ -70,6 +71,7 @@ case $# in
|
||||
tagex) ;&
|
||||
toggletagex) ;&
|
||||
setborderpx) ;&
|
||||
setgaps) ;&
|
||||
setlayoutex) ;&
|
||||
setlayoutaxisex) ;&
|
||||
swapfocus) ;&
|
||||
@ -99,13 +101,30 @@ case $# in
|
||||
signal $1 f $2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command or one too many arguments."
|
||||
echo "Unknown command ($1) or too many arguments"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
5)
|
||||
case $1 in
|
||||
setgaps)
|
||||
# Expects "setgaps oh ov ih iv" where -1 means to keep existing values
|
||||
[ $2 = -1 ] && oh=128 || oh=$2
|
||||
[ $3 = -1 ] && ov=128 || ov=$3
|
||||
[ $4 = -1 ] && ih=128 || ih=$4
|
||||
[ $5 = -1 ] && iv=128 || iv=$5
|
||||
echo $(((oh << 24) + (ov << 16) + (ih << 8) + iv))
|
||||
signal $1 i $(((oh << 24) + (ov << 16) + (ih << 8) + iv))
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command ($1) or too many arguments"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Too many arguments."
|
||||
echo "Unknown command ($1) or too many arguments"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -18,6 +18,60 @@ setgaps(int oh, int ov, int ih, int iv)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
#if DWMC_PATCH
|
||||
/* External function that takes one integer and splits it
|
||||
* into four gap values:
|
||||
* - outer horizontal (oh)
|
||||
* - outer vertical (ov)
|
||||
* - inner horizontal (ih)
|
||||
* - inner vertical (iv)
|
||||
*
|
||||
* Each value is represented as one byte with the uppermost
|
||||
* bit of each byte indicating whether or not to keep the
|
||||
* current value.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* 10000000 10000000 00001111 00001111
|
||||
* | | | |
|
||||
* + keep oh + keep ov + ih 15px + iv 15px
|
||||
*
|
||||
* This gives an int of:
|
||||
* 10000000100000000000111100001111 = 2155876111
|
||||
*
|
||||
* Thus this command should set inner gaps to 15:
|
||||
* xsetroot -name "fsignal:setgaps i 2155876111"
|
||||
*/
|
||||
static void
|
||||
setgapsex(const Arg *arg)
|
||||
{
|
||||
int oh = selmon->gappoh;
|
||||
int ov = selmon->gappov;
|
||||
int ih = selmon->gappih;
|
||||
int iv = selmon->gappiv;
|
||||
|
||||
if (!(arg->i & (1 << 31)))
|
||||
oh = (arg->i & 0x7f000000) >> 24;
|
||||
if (!(arg->i & (1 << 23)))
|
||||
ov = (arg->i & 0x7f0000) >> 16;
|
||||
if (!(arg->i & (1 << 15)))
|
||||
ih = (arg->i & 0x7f00) >> 8;
|
||||
if (!(arg->i & (1 << 7)))
|
||||
iv = (arg->i & 0x7f);
|
||||
|
||||
/* Auto enable gaps if disabled */
|
||||
#if PERTAG_PATCH
|
||||
if (!selmon->pertag->enablegaps[selmon->pertag->curtag])
|
||||
selmon->pertag->enablegaps[selmon->pertag->curtag] = 1;
|
||||
#else
|
||||
if (!enablegaps)
|
||||
enablegaps = 1;
|
||||
#endif // PERTAG_PATCH
|
||||
|
||||
setgaps(oh, ov, ih, iv);
|
||||
}
|
||||
#endif // DWMC_PATCH
|
||||
|
||||
static void
|
||||
togglegaps(const Arg *arg)
|
||||
{
|
||||
|
@ -13,4 +13,7 @@ static void togglegaps(const Arg *arg);
|
||||
#if DRAGMFACT_PATCH || CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT || (VANITYGAPS_MONOCLE_PATCH && MONOCLE_LAYOUT)
|
||||
static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
|
||||
#endif
|
||||
static void setgaps(int oh, int ov, int ih, int iv);
|
||||
static void setgaps(int oh, int ov, int ih, int iv);
|
||||
#if DWMC_PATCH
|
||||
static void setgapsex(const Arg *arg);
|
||||
#endif // DWMC_PATCH
|
Loading…
Reference in New Issue
Block a user