summaryrefslogtreecommitdiff
path: root/src/defs.h
blob: b8dd19deecae8753ba808dff047b64891c6f37a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* See LICENSE for more information on use */
#pragma once
#include <X11/Xlib.h>
#define SXWM_VERSION "sxwm ver. 1.7"
#define SXWM_AUTHOR "(C) Abhinav Prasai 2025"
#define SXWM_LICINFO "See LICENSE for more info"

#define ALT Mod1Mask
#define SUPER Mod4Mask
#define SHIFT ShiftMask

#define MARGIN (gaps + BORDER_WIDTH)
#define OUT_IN (2 * BORDER_WIDTH)
#define MF_MIN 0.05f
#define MF_MAX 0.95f
#define MAX_MONITORS 32
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define UDIST(a, b) abs((int)(a) - (int)(b))
#define CLAMP(x, lo, hi) (((x) < (lo)) ? (lo) : ((x) > (hi)) ? (hi) : (x))
#define MAX_CLIENTS 99
#define MAX_SCRATCHPADS 32
#define MIN_WINDOW_SIZE 20
#define MAX_ITEMS 256
#define BIND(mod, key, cmdstr) {(mod), XK_##key, {cmdstr}, False}
#define CALL(mod, key, fnptr) {(mod), XK_##key, {.fn = fnptr}, True}
#define CMD(name, ...) const char *name[] = {__VA_ARGS__, NULL}

/* workspaces */
#define TYPE_FUNC 2
#define TYPE_WS_CHANGE 0
#define TYPE_WS_MOVE 1
/* fn/cmd */
#define TYPE_FUNC 2
#define TYPE_CMD 3
/* scratchpads*/
#define TYPE_SP_REMOVE 4
#define TYPE_SP_TOGGLE 5
#define TYPE_SP_CREATE 6

#define NUM_WORKSPACES		9
#define WORKSPACE_NAMES		\
	"1"					"\0"\
	"2"					"\0"\
	"3"					"\0"\
	"4"					"\0"\
	"5"					"\0"\
	"6"					"\0"\
	"7"					"\0"\
	"8"					"\0"\
	"9"					"\0"

#define MAX_BINDS 256

typedef enum { DRAG_NONE, DRAG_MOVE, DRAG_RESIZE, DRAG_SWAP } DragMode;
typedef void (*EventHandler)(XEvent *);

typedef union {
	const char **cmd;
	void (*fn)(void);
	int ws; /* workspace */
	int sp; /* scratchpad */
} Action;

typedef struct {
	int mods;
	KeySym keysym;
	KeyCode keycode;
	Action action;
	int type;
} Binding;

typedef struct Client {
	Window win;
	int x, y, h, w;
	int orig_x, orig_y, orig_w, orig_h;
	int custom_stack_height;
	int mon;
	int ws;
	Bool fixed;
	Bool floating;
	Bool fullscreen;
	Bool mapped;
	pid_t pid;
	struct Client *next;
	struct Client *swallowed;
	struct Client *swallower;
} Client;

typedef struct {
	int modkey;
	int gaps;
	int border_width;
	long border_foc_col;
	long border_ufoc_col;
	long border_swap_col;
	float master_width[MAX_MONITORS];
	int motion_throttle;
	int resize_master_amt;
	int resize_stack_amt;
	int snap_distance;
	int n_binds;
	int move_window_amt;
	int resize_window_amt;
	Bool new_win_focus;
	Bool warp_cursor;
	Bool floating_on_top;
	Bool new_win_master;
	Binding binds[MAX_ITEMS];
	char **should_float[MAX_ITEMS];
	char **start_fullscreen[MAX_ITEMS];
	char **can_swallow[MAX_ITEMS];
	char **can_be_swallowed[MAX_ITEMS];
	char **scratchpads[MAX_SCRATCHPADS];
	char **open_in_workspace[MAX_ITEMS];
	char *to_run[MAX_ITEMS];
} Config;

typedef struct {
	int x, y;
	int w, h;
	int reserve_left, reserve_right,
		reserve_top, reserve_bottom;
} Monitor;

typedef struct {
	Client *client;
	Bool enabled;
} Scratchpad;

typedef struct {
	const char *name;
	void (*fn)(void);
} CommandEntry;

extern void centre_window(void);
extern void close_focused(void);
extern void dec_gaps(void);
extern void focus_next(void);
extern void focus_prev(void);
extern void focus_next_mon(void);
extern void focus_prev_mon(void);
extern void move_next_mon(void);
extern void move_prev_mon(void);
extern void inc_gaps(void);
extern void move_master_next(void);
extern void move_master_prev(void);
extern void move_win_down(void);
extern void move_win_left(void);
extern void move_win_right(void);
extern void move_win_up(void);
extern long parse_col(const char *hex);
extern void quit(void);
extern void reload_config(void);
extern void resize_master_add(void);
extern void resize_master_sub(void);
extern void resize_stack_add(void);
extern void resize_stack_sub(void);
extern void resize_win_down(void);
extern void resize_win_left(void);
extern void resize_win_right(void);
extern void resize_win_up(void);
extern void switch_previous_workspace(void);
extern void toggle_floating(void);
extern void toggle_floating_global(void);
extern void toggle_fullscreen(void);