X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fmain.c;h=4c5b5f18ced0aff76ae7b2838c89039dfe49673d;hb=94a09b3cac98a3bc1ed580fce16aa9869f83bbaa;hp=b696e031a2dfc60c34cc8c4eda5b4af17575d26f;hpb=3b4ae812e3543681a331bb72e6ae50038c4ab7bc;p=i3%2Fi3 diff --git a/src/main.c b/src/main.c index b696e031..4c5b5f18 100644 --- a/src/main.c +++ b/src/main.c @@ -4,7 +4,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * * main.c: Initialization, main loop * @@ -188,7 +188,7 @@ static void handle_signal(int sig, siginfo_t *info, void *data) { int main(int argc, char *argv[]) { /* Keep a symbol pointing to the I3_VERSION string constant so that we have * it in gdb backtraces. */ - const char *i3_version __attribute__((unused)) = I3_VERSION; + const char *_i3_version __attribute__((unused)) = i3_version; char *override_configpath = NULL; bool autostart = true; char *layout_path = NULL; @@ -261,11 +261,11 @@ int main(int argc, char *argv[]) { only_check_config = true; break; case 'v': - printf("i3 version " I3_VERSION " © 2009-2014 Michael Stapelberg and contributors\n"); + printf("i3 version %s © 2009 Michael Stapelberg and contributors\n", i3_version); exit(EXIT_SUCCESS); break; case 'm': - printf("Binary i3 version: " I3_VERSION " © 2009-2014 Michael Stapelberg and contributors\n"); + printf("Binary i3 version: %s © 2009 Michael Stapelberg and contributors\n", i3_version); display_running_version(); exit(EXIT_SUCCESS); break; @@ -450,13 +450,13 @@ int main(int argc, char *argv[]) { memset(cwd, '\0', cwd_size); if (read(patternfd, cwd, cwd_size) > 0) /* a trailing newline is included in cwd */ - LOG("CORE DUMPS: Your core_pattern is: %s", cwd); + LOG("CORE DUMPS: Your core_pattern is: \"%s\".\n", cwd); close(patternfd); } free(cwd); } - LOG("i3 " I3_VERSION " starting\n"); + LOG("i3 %s starting\n", i3_version); conn = xcb_connect(NULL, &conn_screen); if (xcb_connection_has_error(conn)) @@ -474,6 +474,12 @@ int main(int argc, char *argv[]) { root_screen = xcb_aux_get_screen(conn, conn_screen); root = root_screen->root; +/* Place requests for the atoms we need as soon as possible */ +#define xmacro(atom) \ + xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); +#include "atoms.xmacro" +#undef xmacro + /* By default, we use the same depth and visual as the root window, which * usually is TrueColor (24 bit depth) and the corresponding visual. * However, we also check if a 32 bit depth and visual are available (for @@ -491,6 +497,20 @@ int main(int argc, char *argv[]) { xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(conn, root); xcb_query_pointer_cookie_t pointercookie = xcb_query_pointer(conn, root); +/* Setup NetWM atoms */ +#define xmacro(name) \ + do { \ + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, name##_cookie, NULL); \ + if (!reply) { \ + ELOG("Could not get atom " #name "\n"); \ + exit(-1); \ + } \ + A_##name = reply->atom; \ + free(reply); \ + } while (0); +#include "atoms.xmacro" +#undef xmacro + load_configuration(conn, override_configpath, false); if (config.ipc_socket_path == NULL) { @@ -502,7 +522,7 @@ int main(int argc, char *argv[]) { } xcb_void_cookie_t cookie; - cookie = xcb_change_window_attributes_checked(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]) {ROOT_EVENT_MASK}); + cookie = xcb_change_window_attributes_checked(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){ROOT_EVENT_MASK}); check_error(conn, cookie, "Another window manager seems to be running"); xcb_get_geometry_reply_t *greply = xcb_get_geometry_reply(conn, gcookie, NULL); @@ -512,12 +532,6 @@ int main(int argc, char *argv[]) { } DLOG("root geometry reply: (%d, %d) %d x %d\n", greply->x, greply->y, greply->width, greply->height); -/* Place requests for the atoms we need as soon as possible */ -#define xmacro(atom) \ - xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom); -#include "atoms.xmacro" -#undef xmacro - xcursor_load_cursors(); /* Set a cursor for the root window (otherwise the root window will show no @@ -536,9 +550,9 @@ int main(int argc, char *argv[]) { xcb_xkb_use_extension(conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION); xcb_xkb_select_events(conn, XCB_XKB_ID_USE_CORE_KBD, - XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY, + XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY, 0, - XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY, + XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY, 0xff, 0xff, NULL); @@ -547,20 +561,6 @@ int main(int argc, char *argv[]) { restore_connect(); -/* Setup NetWM atoms */ -#define xmacro(name) \ - do { \ - xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, name##_cookie, NULL); \ - if (!reply) { \ - ELOG("Could not get atom " #name "\n"); \ - exit(-1); \ - } \ - A_##name = reply->atom; \ - free(reply); \ - } while (0); -#include "atoms.xmacro" -#undef xmacro - property_handlers_init(); ewmh_setup_hints(); @@ -574,7 +574,7 @@ int main(int argc, char *argv[]) { bool needs_tree_init = true; if (layout_path) { - LOG("Trying to restore the layout from %s...", layout_path); + LOG("Trying to restore the layout from \"%s\".\n", layout_path); needs_tree_init = !tree_restore(layout_path, greply); if (delete_layout_path) { unlink(layout_path); @@ -621,6 +621,8 @@ int main(int argc, char *argv[]) { ELOG("ERROR: No screen at (%d, %d), starting on the first screen\n", pointerreply->root_x, pointerreply->root_y); output = get_first_output(); + if (!output) + die("No usable outputs available.\n"); } con_focus(con_descend_focused(output_get_content(output->con))); @@ -742,10 +744,10 @@ int main(int argc, char *argv[]) { xcb_create_gc(conn, gc, root->root, XCB_GC_FUNCTION | XCB_GC_PLANE_MASK | XCB_GC_FILL_STYLE | XCB_GC_SUBWINDOW_MODE, - (uint32_t[]) {XCB_GX_COPY, ~0, XCB_FILL_STYLE_SOLID, XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS}); + (uint32_t[]){XCB_GX_COPY, ~0, XCB_FILL_STYLE_SOLID, XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS}); xcb_copy_area(conn, root->root, pixmap, gc, 0, 0, 0, 0, width, height); - xcb_change_window_attributes_checked(conn, root->root, XCB_CW_BACK_PIXMAP, (uint32_t[]) {pixmap}); + xcb_change_window_attributes_checked(conn, root->root, XCB_CW_BACK_PIXMAP, (uint32_t[]){pixmap}); xcb_flush(conn); xcb_free_gc(conn, gc); xcb_free_pixmap(conn, pixmap); @@ -766,7 +768,7 @@ int main(int argc, char *argv[]) { sigaction(SIGABRT, &action, NULL) == -1 || sigaction(SIGFPE, &action, NULL) == -1 || sigaction(SIGSEGV, &action, NULL) == -1) - ELOG("Could not setup signal handler"); + ELOG("Could not setup signal handler.\n"); } /* Catch all signals with default action "Term", see signal(7) */ @@ -775,10 +777,10 @@ int main(int argc, char *argv[]) { sigaction(SIGALRM, &action, NULL) == -1 || sigaction(SIGUSR1, &action, NULL) == -1 || sigaction(SIGUSR2, &action, NULL) == -1) - ELOG("Could not setup signal handler"); + ELOG("Could not setup signal handler.\n"); /* Ignore SIGPIPE to survive errors when an IPC client disconnects - * while we are sending him a message */ + * while we are sending them a message */ signal(SIGPIPE, SIG_IGN); /* Autostarting exec-lines */