summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruint23 <[email protected]>2025-04-19 18:52:38 +0100
committeruint23 <[email protected]>2025-04-19 18:52:38 +0100
commit2c65fd8577d87a7dc90c33f1e4d42839282278aa (patch)
tree79e6fdeec4e33edd03f9c47a1098698ca109a191 /src
parent80e72a1975a93dac1a601dfb976ac0a43e2c941e (diff)
update tile function + update colours
Diffstat (limited to 'src')
-rw-r--r--src/defs.h6
-rw-r--r--src/sxwm.c91
-rw-r--r--src/usercfg.h24
3 files changed, 59 insertions, 62 deletions
diff --git a/src/defs.h b/src/defs.h
index 95d17e7..27a1a9e 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -12,9 +12,11 @@
#define SUPER Mod4Mask
#define SHIFT ShiftMask
+#define MARGIN (gaps + BORDER_WIDTH)
+#define OUT_IN (2 * BORDER_WIDTH)
#define LENGTH(X) (sizeof X / sizeof X[0])
-#define BIND(mod, key, cmdstr) { (mod), XK_##key, { cmdstr }, 0 }
-#define CALL(mod, key, fnptr) { (mod), XK_##key, { .fn = fnptr }, 1 }
+#define BIND(mod, key, cmdstr) { (mod), XK_##key, { cmdstr }, 0 }
+#define CALL(mod, key, fnptr) { (mod), XK_##key, { .fn = fnptr }, 1 }
#define CMD(name, ...) \
static const char *name[] = { __VA_ARGS__, NULL }
diff --git a/src/sxwm.c b/src/sxwm.c
index ab65c4f..99b959a 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -565,68 +565,63 @@ tile(void)
for (Client *c = clients; c; c = c->next)
if (!c->floating)
++n;
- if (n == 0)
- return;
+ if (n == 0) return;
- int masterx = gaps + BORDER_WIDTH;
- int mastery = gaps + BORDER_WIDTH;
- int availableh = scr_height - (gaps * 2);
- int masterw, masterh;
- int stackw = 0, stackwinh = 0;
int stack_count = n - 1;
- if (n == 1) {
- masterw = scr_width - (gaps * 2 + BORDER_WIDTH * 2);
- masterh = availableh - (BORDER_WIDTH * 2);
- } else {
- int total_gapsw = gaps * 4;
- int total_bordersw = BORDER_WIDTH * 4;
- int total_space = scr_width - total_gapsw - total_bordersw;
-
- /* use MASTER_WIDTH here: */
- masterw = (int)(total_space * MASTER_WIDTH);
- stackw = total_space - masterw;
- masterh = availableh - (BORDER_WIDTH * 2);
-
- /* compute stack height as before… */
- int total_gapsh = (stack_count > 0 ? gaps * (stack_count - 1) : 0);
- int total_bordersh = BORDER_WIDTH * 2 * stack_count;
- int total_stackh = availableh - total_gapsh - total_bordersh;
- stackwinh = (stack_count > 0 ? total_stackh / stack_count : 0);
- }
- int stackx = masterx + masterw + gaps + (BORDER_WIDTH * 2);
- int stacky = gaps;
- int i = 0;
+ int outer_x0 = gaps;
+ int outer_y0 = gaps;
+ int outer_w = scr_width - 2*gaps;
+ int outer_h = scr_height - 2*gaps;
+
+ int inter_x = (stack_count > 0 ? gaps : 0);
+ int master_ow = (stack_count > 0)
+ ? (int)(outer_w * MASTER_WIDTH)
+ : outer_w;
+ int stack_ow = (stack_count > 0)
+ ? (outer_w - master_ow - inter_x)
+ : 0;
+
+ int master_x0 = outer_x0;
+ int stack_x0 = outer_x0 + master_ow + inter_x;
+
+ int inter_y_total = (stack_count > 1 ? gaps * (stack_count - 1) : 0);
+ int each_oh = (stack_count > 0)
+ ? (outer_h - inter_y_total) / stack_count
+ : 0;
+
+ int used_h = each_oh * (stack_count > 0 ? stack_count - 1 : 0)
+ + inter_y_total;
+ int last_oh = (stack_count > 0)
+ ? (outer_h - used_h)
+ : outer_h;
+ int i = 0;
for (Client *c = clients; c; c = c->next) {
- if (c->floating)
- continue;
+ if (c->floating) continue;
+ XWindowChanges ch = { .border_width = BORDER_WIDTH };
- XWindowChanges changes = { .border_width = BORDER_WIDTH };
if (i == 0) {
- /* master */
- changes.x = masterx;
- changes.y = mastery;
- changes.width = masterw;
- changes.height = masterh;
+ ch.x = master_x0;
+ ch.y = outer_y0;
+ ch.width = master_ow - 2*BORDER_WIDTH;
+ ch.height = outer_h - 2*BORDER_WIDTH;
} else {
- /* stack */
- changes.x = stackx;
- changes.y = stacky + BORDER_WIDTH;
- changes.width = stackw;
- changes.height = stackwinh;
- if (i == n - 1) {
- int used = stacky - gaps + stackwinh + (BORDER_WIDTH * 2);
- changes.height += (availableh - used);
- }
- stacky += stackwinh + (BORDER_WIDTH * 2) + gaps;
+ int row = i - 1;
+ int outer_y = outer_y0 + row * (each_oh + gaps);
+ int outer_hh = (row < stack_count - 1 ? each_oh : last_oh);
+
+ ch.x = stack_x0;
+ ch.y = outer_y;
+ ch.width = stack_ow - 2*BORDER_WIDTH;
+ ch.height = outer_hh - 2*BORDER_WIDTH;
}
XSetWindowBorder(dpy, c->win,
(i == 0 ? border_foc_col : border_ufoc_col));
XConfigureWindow(dpy, c->win,
CWX|CWY|CWWidth|CWHeight|CWBorderWidth,
- &changes);
+ &ch);
++i;
}
}
diff --git a/src/usercfg.h b/src/usercfg.h
index 85aeefa..0d6e500 100644
--- a/src/usercfg.h
+++ b/src/usercfg.h
@@ -42,16 +42,16 @@
#define GAPS 10
-#define BORDER_WIDTH 5
-#define BORDER_FOC_COL "#AAFFFA"
-#define BORDER_UFOC_COL "#FF4439"
+#define BORDER_WIDTH 1
+#define BORDER_FOC_COL "#005577"
+#define BORDER_UFOC_COL "#444444"
#define MASTER_WIDTH 0.6
#define MOTION_THROTTLE 144
-#define SNAP_DISTANCE 10
+#define SNAP_DISTANCE 5
/*
- * ———————————< Keys & Bindins >————————————— *
+ * ————————————< Keys & Bindins >—————————————*
*
* This is where you set your keybinds to
* execute apps. You can use the CMD macro
@@ -67,14 +67,14 @@
* commands given to execvp, the function
* that executes these programs.
*
- * ——————————— —————————————————————————————— *
+ * ———————————————————————————————————————————*
*
*/
CMD(terminal, "st");
CMD(browser, "firefox");
-/*< This is your modifier key (MOD/SUPER) >*/
+/*< This is your modifier key (ALT/SUPER) >*/
#define MOD ALT
/*
@@ -123,14 +123,14 @@ CMD(browser, "firefox");
* End the line with a comma, as this is
* an array.
*
- * ——————————— —————————————————————————————— *
+ * ———————————————————————————————————————————*
*/
static const Binding binds[] =
{
-/*——< MODIFIER(S) >——— < KEY >—————< FUNCTION >——*/
+/*——< MODIFIER(S) >—————< KEY >—————< FUNCTION >——*/
-/*——— ——< Here are your functions calls > ———— — */
+/*———————< Here are your functions calls >————— — */
CALL(MOD|SHIFT, e, quit),
CALL(MOD|SHIFT, q, close_focused),
@@ -143,8 +143,8 @@ static const Binding binds[] =
CALL(MOD, equal, inc_gaps),
CALL(MOD, minus, dec_gaps),
- CALL(MOD, f, toggle_floating),
- CALL(MOD, space, toggle_floating_global),
+ CALL(MOD, space, toggle_floating),
+ CALL(MOD|SHIFT, space, toggle_floating_global),
/*—————< Here are your executable functions >—————*/
BIND(MOD, Return, terminal),