aboutsummaryrefslogtreecommitdiff
path: root/config.h
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-25 23:41:08 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-25 23:41:08 +0100
commit67df7a09ed3eb39cb22fb39b70f1691f9d67b23d (patch)
treedf99f10370da1c03e510451b905a2678d5c7698a /config.h
parent5f9fcc88d1578fe47b7e6e7a3166b8e8b0f0c9e9 (diff)
downloaddwm-67df7a09ed3eb39cb22fb39b70f1691f9d67b23d.tar.gz
dwm-67df7a09ed3eb39cb22fb39b70f1691f9d67b23d.tar.bz2
dwm-67df7a09ed3eb39cb22fb39b70f1691f9d67b23d.zip
Two arrays of gaps are stored in pertag, switchable by toggle_gaps
With this commit, each tag has two gap values (indexes at `gaps_previous`, `gaps_current`) that can be interchanged via `toggle_gaps`. At initialisation, `gaps_previous` is set to `default_gaps` and `gaps_current` is set to all 0.
Diffstat (limited to 'config.h')
-rw-r--r--config.h22
1 files changed, 11 insertions, 11 deletions
diff --git a/config.h b/config.h
index 5b914bf..13cde8d 100644
--- a/config.h
+++ b/config.h
@@ -8,8 +8,7 @@
/* appearance */
static const unsigned int borderpx = 0; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
-static const unsigned int optional_gaps = 20; /* optional gaps between windows */
-static const unsigned int default_gaps = 0; /* default gaps between windows */
+static const int default_gaps = 20; /* default value of gaps_previous */
static const int showbar = true; /* 0 means no bar */
static const int topbar = 0; /* 0 means bottom bar */
static const char *fonts[] = { "Noto Sans Mono:size=13" };
@@ -173,14 +172,15 @@ static const Button buttons[] = {
void
togglegaps(const Arg *arg)
{
- if (!selmon)
- return;
- int *gap_size = &selmon->pertag->gaps[selmon->pertag->curtag];
- if (*gap_size == default_gaps)
- selmon->pertag->gaps[selmon->pertag->curtag] = optional_gaps;
- else
- selmon->pertag->gaps[selmon->pertag->curtag] = default_gaps;
- arrange(selmon);
+ if (!selmon)
+ return;
+ int *gaps_current = selmon->pertag->gaps_current + selmon->pertag->curtag;
+ int *gaps_previous = selmon->pertag->gaps_previous + selmon->pertag->curtag;
+ // Swap the current gaps and the previous gaps
+ int temp = *gaps_current;
+ *gaps_current = *gaps_previous;
+ *gaps_previous = temp;
+ arrange(selmon);
}
void
@@ -190,7 +190,7 @@ printgaps(const Arg *arg)
return;
char *cmd = malloc(sizeof(*cmd) * 38);
sprintf(cmd, "notify-send -u low \"Gaps=%d\"",
- selmon->pertag->gaps[selmon->pertag->curtag]);
+ selmon->pertag->gaps_current[selmon->pertag->curtag]);
system(cmd);
free(cmd);
}