aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.h
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-14 14:25:13 +0200
committeruser <user@clank>2026-08-14 14:25:13 +0200
commit858234c05031a7bffc3ffe2a9b2aa4530d3ff0d7 (patch)
tree951d60c94949dc43c468252142a93006663b9f76 /src/config.h
parentsl0ppty: positional shaders, and a config block to ask for them (diff)
downloadslosh-858234c05031a7bffc3ffe2a9b2aa4530d3ff0d7.tar.gz
slosh-858234c05031a7bffc3ffe2a9b2aa4530d3ff0d7.tar.xz
slosh-858234c05031a7bffc3ffe2a9b2aa4530d3ff0d7.zip
sl0ppty: pane states are a table, not three hardcoded knobs
dim_unfocused, drag_grayscale and drag_dim were three knobs describing two situations, and there was no way to say anything about the third, fourth or fifth. They are replaced by a table: a state names a chain, and the chain is exactly as expressive as the global `shaders` block because it is the same parser. states { dragging { } drop_target { grayscale amount=200; dim amount=140 } suspended { grayscale amount=180; dim amount=90 } scrolled { tint amount=30 color="#ffcc88" } unfocused { dim amount=90 } } A pane is usually in several states at once, so exactly one wins: the first to match, in a fixed order running from the most deliberate to the most ambient. Fixed rather than read from the block, because it is a ranking by urgency rather than a preference — a pane you are holding should not be recoloured by anything, and a mode the whole screen is in outranks an ambient hint about one pane. They do not stack, which is the same call the drag policy already had to make by hand: two reasons to be grey compound into a muddy grey that reads as neither. Defaults are the old drag behaviour and nothing else, so out of the box this changes nothing. drop_hover is now separable from drop_target. The pane under the pointer was already distinguished by its border; it can now differ in colour too, and defaults to the same chain so it does not have to. Two states asked for did not survive contact with the code, and it is worth writing down why: `dead` cannot exist. app_reap() runs every iteration of the server loop, before the paint, and closing the last pane closes the tab — so a pane whose program exits is gone before a frame containing it is ever composed. A `dead` shader would name something that could never draw. Making it real means keeping dead panes until they are dismissed, which is a feature about lifetimes and not about colour. `suspended` could not be seen either, for a much smaller reason: draw_cb drew its "press a key to run" label and returned before reaching the shader pass. It falls through now. A pane that has not started is a state worth colouring, and its label is the only contents it has.
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/config.h b/src/config.h
index a6bd2f2..098c9bc 100644
--- a/src/config.h
+++ b/src/config.h
@@ -14,6 +14,23 @@
#include "shader.h"
#include "sl0ppty.h"
+/* Pane states a shader can be hung off, in the order they are tested. Only
+ * states a pane can actually be seen in: a pane whose program exits is reaped
+ * before the next paint, so there is deliberately no "dead" here — it would
+ * name a shader that could never draw a frame. */
+typedef enum {
+ PSTATE_DRAGGING, /* the pane you have hold of */
+ PSTATE_DROP_HOVER, /* the one under the pointer, where it would land */
+ PSTATE_DROP_TARGET, /* the others, all of them somewhere it could go */
+ PSTATE_SUSPENDED, /* laid out, never started */
+ PSTATE_SCROLLED, /* looking at scrollback rather than the present */
+ PSTATE_UNFOCUSED,
+ PSTATE_COUNT,
+} pane_state_t;
+
+/* The config name for a state, e.g. "drop_target". */
+const char *pane_state_name(pane_state_t s);
+
typedef enum {
ACT_NONE = 0,
ACT_SPLIT_COLS,
@@ -64,15 +81,25 @@ typedef struct {
uint16_t double_click_ms; /* how close two clicks must be to be a double */
/* Shader strengths, 0..255, 0 being off. Ambient dimming is a taste and is
* off by default; the drag greying is transient and on. */
- uint8_t dim_unfocused;
- uint8_t drag_grayscale;
- uint8_t drag_dim;
-
/* Colour passes every pane gets, in the order they were written. Ordinary
* shaders rather than policy: the session has no opinion about these, you
* asked for them. */
shader_t shaders[SHADE_MAX];
size_t nshaders;
+
+ /* What a pane looks like when it is in a particular state. A pane is
+ * usually in several at once — unfocused *and* scrolled, suspended *and*
+ * something you could drop onto — so exactly one wins, the first that
+ * matches in the order below. That order is fixed rather than taken from
+ * the config, because it is a ranking by urgency and not a preference: a
+ * pane you are holding should not be recoloured by anything, and a mode the
+ * whole screen is in outranks an ambient hint about one pane.
+ *
+ * Stacking them instead would let two reasons to be grey compound into one
+ * muddy grey that reads as neither, which is the mistake the drag policy
+ * already had to avoid by hand. */
+ shader_t state_shaders[PSTATE_COUNT][SHADE_MAX];
+ size_t state_n[PSTATE_COUNT];
bool status_bar;
bool focus_follows_mouse;