]> git.lizzy.rs Git - bspwm.git/blob - helpers.h
New setting: `history_aware_focus`
[bspwm.git] / helpers.h
1 #ifndef _HELPERS_H
2 #define _HELPERS_H
3
4 #include <xcb/xcb.h>
5 #include <stdarg.h>
6 #include <stdio.h>
7 #include <stdint.h>
8
9 #define LENGTH(x)         (sizeof(x) / sizeof(*x))
10 #define MAX(A, B)         ((A) > (B) ? (A) : (B))
11 #define MIN(A, B)         ((A) < (B) ? (A) : (B))
12 #define ABS(A)            ((A) < 0 ? -(A) : (A))
13 #define BOOLSTR(A)        ((A) ? "true" : "false")
14
15 #define XCB_CONFIG_WINDOW_X_Y               XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
16 #define XCB_CONFIG_WINDOW_WIDTH_HEIGHT      XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT
17 #define XCB_CONFIG_WINDOW_X_Y_WIDTH_HEIGHT  XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT
18 #define MAXLEN 256
19
20 #define REMLEN(x)         (BUFSIZ - strlen(x) - 1)
21
22 #ifdef DEBUG
23 #  define PUTS(x)         puts(x)
24 #  define PRINTF(x,...)   printf(x, __VA_ARGS__)
25 #else
26 #  define PUTS(x)         ((void)0)
27 #  define PRINTF(x,...)   ((void)0)
28 #endif
29
30 void warn(char *, ...);
31 __attribute__((noreturn))
32 void err(char *, ...);
33 uint32_t get_color(char *);
34 double distance(xcb_point_t, xcb_point_t);
35
36 #endif