]> git.sur5r.net Git - i3/i3/blob - include/util.h
a156f0a38944d358648725e3675a8b6941bc268d
[i3/i3] / include / util.h
1 /*
2  * vim:ts=8:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * (c) 2009 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  */
11 #include <xcb/xcb.h>
12
13 #include "data.h"
14
15 #ifndef _UTIL_H
16 #define _UTIL_H
17
18 #define exit_if_null(pointer, ...) { if (pointer == NULL) die(__VA_ARGS__); }
19 #define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)
20 #define CIRCLEQ_NEXT_OR_NULL(head, elm, field) (CIRCLEQ_NEXT(elm, field) != CIRCLEQ_END(head) ? \
21                                                 CIRCLEQ_NEXT(elm, field) : NULL)
22 #define CIRCLEQ_PREV_OR_NULL(head, elm, field) (CIRCLEQ_PREV(elm, field) != CIRCLEQ_END(head) ? \
23                                                 CIRCLEQ_PREV(elm, field) : NULL)
24 #define FOR_TABLE(workspace) \
25                         for (int cols = 0; cols < workspace->cols; cols++) \
26                                 for (int rows = 0; rows < workspace->rows; rows++)
27
28 /* ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that is,
29    delete the preceding comma */
30 #define LOG(fmt, ...) slog("%s:%s:%d - " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
31
32
33 int min(int a, int b);
34 int max(int a, int b);
35 void slog(char *fmt, ...);
36 void die(char *fmt, ...);
37 void *smalloc(size_t size);
38 void *scalloc(size_t size);
39 char *sstrdup(const char *str);
40 void start_application(const char *command);
41 void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_message);
42 char *convert_utf8_to_ucs2(char *input, int *real_strlen);
43 void remove_client_from_container(xcb_connection_t *conn, Client *client, Container *container);
44 void set_focus(xcb_connection_t *conn, Client *client);
45 void leave_stack_mode(xcb_connection_t *conn, Container *container);
46 void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode);
47 void warp_pointer_into(xcb_connection_t *conn, Client *client);
48 void toggle_fullscreen(xcb_connection_t *conn, Client *client);
49 void kill_window(xcb_connection_t *conn, Client *window);
50
51 #endif