DLOG("Done\n");
}
+/*
+ * Exit handler which destroys the main_loop. Will trigger cleanup handlers.
+ *
+ */
+static void i3_exit() {
+ ev_loop_destroy(main_loop);
+}
+
int main(int argc, char *argv[]) {
//parse_cmd("[ foo ] attach, attach ; focus");
int screens;
root = root_screen->root;
root_depth = root_screen->root_depth;
xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(conn, root);
+ xcb_query_pointer_cookie_t pointercookie = xcb_query_pointer(conn, root);
load_configuration(conn, override_configpath, false);
if (only_check_config) {
#include "atoms.xmacro"
#undef xmacro
};
- xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, A_ATOM, 32, 16, supported_atoms);
+ xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 16, supported_atoms);
/* Set up the window manager’s name */
- xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, A_WINDOW, 32, 1, &root);
+ xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &root);
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
keysyms = xcb_key_symbols_alloc(conn);
free(greply);
- if (force_xinerama) {
+ /* Force Xinerama (for drivers which don't support RandR yet, esp. the
+ * nVidia binary graphics driver), when specified either in the config
+ * file or on command-line */
+ if (force_xinerama || config.force_xinerama) {
xinerama_init();
} else {
DLOG("Checking for XRandR...\n");
randr_init(&randr_base);
}
+ xcb_query_pointer_reply_t *pointerreply;
+ Output *output = NULL;
+ if (!(pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL))) {
+ ELOG("Could not query pointer position, using first screen\n");
+ output = get_first_output();
+ } else {
+ DLOG("Pointer at %d, %d\n", pointerreply->root_x, pointerreply->root_y);
+ output = get_output_containing(pointerreply->root_x, pointerreply->root_y);
+ if (!output) {
+ ELOG("ERROR: No screen at (%d, %d), starting on the first screen\n",
+ pointerreply->root_x, pointerreply->root_y);
+ output = get_first_output();
+ }
+
+ con_focus(con_descend_focused(output_get_content(output->con)));
+ }
+
tree_render();
/* Create the UNIX domain socket for IPC */
start_application(exec_always->command);
}
+ /* Make sure to destroy the event loop to invoke the cleeanup callbacks
+ * when calling exit() */
+ atexit(i3_exit);
+
ev_loop(main_loop, 0);
}