From aeee7bd1187ff1654bf271011efd8e42e2bbe527 Mon Sep 17 00:00:00 2001 From: elbachir-one Date: Thu, 26 Jun 2025 15:57:35 +0100 Subject: Refactor keybinding configuration and parsing logic - Added MAX_BINDS macro to replace magic number (256) in alloc_bind - Fixed potential null dereference in strip() on empty strings - Corrected redundant KeySym assignment in parse_combo() - Improved clarity and maintainability of call_table and helper functions - Ensured safe string handling with proper bounds and terminators - Added fallback logic for unknown key symbols using parse_keysym() - Proper bounds checks on buffers and allocations --- src/defs.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/defs.h') diff --git a/src/defs.h b/src/defs.h index 5796214..fc3be0e 100644 --- a/src/defs.h +++ b/src/defs.h @@ -50,6 +50,8 @@ "8" "\0"\ "9" "\0" +#define MAX_BINDS 256 + typedef enum { DRAG_NONE, DRAG_MOVE, DRAG_RESIZE, DRAG_SWAP } DragMode; typedef void (*EventHandler)(XEvent *); @@ -119,6 +121,11 @@ typedef struct { Bool enabled; } Scratchpad; +typedef struct { + const char *name; + void (*fn)(void); +} CommandEntry; + extern void centre_window(); extern void close_focused(void); extern void dec_gaps(void); -- cgit v1.2.3