#include "xcb.h"
#include "xinerama.h"
#include "manage.h"
+#include "ipc.h"
+
+xcb_connection_t *global_conn;
/* This is the path to i3, copied from argv[0] when starting up */
char **start_argv;
xcb_event_handlers_t evenths;
xcb_atom_t atoms[NUM_ATOMS];
+xcb_window_t root;
int num_screens = 0;
/* The depth of the root screen (used e.g. for creating new pixmaps later) */
bool autostart = true;
xcb_connection_t *conn;
xcb_property_handlers_t prophs;
- xcb_window_t root;
xcb_intern_atom_cookie_t atom_cookies[NUM_ATOMS];
setlocale(LC_ALL, "");
memset(&evenths, 0, sizeof(xcb_event_handlers_t));
memset(&prophs, 0, sizeof(xcb_property_handlers_t));
- conn = xcb_connect(NULL, &screens);
+ conn = global_conn = xcb_connect(NULL, &screens);
if (xcb_connection_has_error(conn))
die("Cannot open display\n");
- load_configuration(conn, override_configpath);
+ load_configuration(conn, override_configpath, false);
/* Place requests for the atoms we need as soon as possible */
#define REQUEST_ATOM(name) atom_cookies[name] = xcb_intern_atom(conn, 0, strlen(#name), #name);
xcb_get_numlock_mask(conn);
- /* Grab the bound keys */
- Binding *bind;
- TAILQ_FOREACH(bind, &bindings, bindings) {
- LOG("Grabbing %d\n", bind->keycode);
- if (bind->mods & BIND_MODE_SWITCH)
- xcb_grab_key(conn, 0, root, 0, bind->keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
- else {
- /* Grab the key in all combinations */
- #define GRAB_KEY(modifier) xcb_grab_key(conn, 0, root, modifier, bind->keycode, \
- XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC)
- GRAB_KEY(bind->mods);
- GRAB_KEY(bind->mods | xcb_numlock_mask);
- GRAB_KEY(bind->mods | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
- }
- }
+ grab_all_keys(conn);
/* Autostarting exec-lines */
struct Autostart *exec;
c_ws = &workspaces[screen->current_workspace];
}
+ /* Create the UNIX domain socket for IPC */
+ int ipc_socket = ipc_create_socket("/tmp/i3.s");
+ if (ipc_socket == -1) {
+ LOG("Could not create the IPC socket, IPC disabled\n");
+ } else {
+ struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
+ ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ);
+ ev_io_start(loop, ipc_io);
+ }
+
/* Handle the events which arrived until now */
xcb_check_cb(NULL, NULL, 0);