i3
|
00001 /* 00002 * vim:ts=4:sw=4:expandtab 00003 * 00004 * i3 - an improved dynamic tiling window manager 00005 * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) 00006 * 00007 * libi3: contains functions which are used by i3 *and* accompanying tools such 00008 * as i3-msg, i3-config-wizard, … 00009 * 00010 */ 00011 #ifndef _LIBI3_H 00012 #define _LIBI3_H 00013 00014 #include <stdbool.h> 00015 #include <stdarg.h> 00016 #include <stdio.h> 00017 #include <xcb/xcb.h> 00018 #include <xcb/xproto.h> 00019 #include <xcb/xcb_keysyms.h> 00020 00021 typedef struct Font i3Font; 00022 00029 struct Font { 00031 int height; 00033 xcb_font_t id; 00034 }; 00035 00036 /* Since this file also gets included by utilities which don’t use the i3 log 00037 * infrastructure, we define a fallback. */ 00038 #if !defined(ELOG) 00039 #define ELOG(fmt, ...) fprintf(stderr, "ERROR: " fmt, ##__VA_ARGS__) 00040 #endif 00041 00049 char *socket_path_from_x11(); 00050 00056 void *smalloc(size_t size); 00057 00063 void *scalloc(size_t size); 00064 00070 void *srealloc(void *ptr, size_t size); 00071 00077 char *sstrdup(const char *str); 00078 00084 int sasprintf(char **strp, const char *fmt, ...); 00085 00091 int ipc_connect(const char *socket_path); 00092 00101 int ipc_send_message(int sockfd, uint32_t message_size, 00102 uint32_t message_type, const uint8_t *payload); 00103 00115 int ipc_recv_message(int sockfd, uint32_t message_type, 00116 uint32_t *reply_length, uint8_t **reply); 00117 00124 void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width); 00125 00140 uint32_t get_colorpixel(const char *hex) __attribute__((const)); 00141 00142 #if defined(__APPLE__) 00143 00144 /* 00145 * Taken from FreeBSD 00146 * Returns a pointer to a new string which is a duplicate of the 00147 * string, but only copies at most n characters. 00148 * 00149 */ 00150 char *strndup(const char *str, size_t n); 00151 00152 #endif 00153 00162 uint32_t aio_get_mod_mask_for(uint32_t keysym, xcb_key_symbols_t *symbols); 00163 00171 uint32_t get_mod_mask_for(uint32_t keysym, 00172 xcb_key_symbols_t *symbols, 00173 xcb_get_modifier_mapping_reply_t *modmap_reply); 00174 00180 i3Font load_font(const char *pattern, bool fallback); 00181 00182 #endif