X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fmain.c;h=8b514178bbbf3283fc9391f11ef5c6f42643ba1a;hb=56f420c3ddc12e9c4bf8c8cca324a8d2da0fb475;hp=67024e6e9aca432444f8f8e6ec4dddab04f91544;hpb=4205973135f28a0ab0e25a63dbc8c6fff0d3539e;p=i3%2Fi3 diff --git a/src/main.c b/src/main.c index 67024e6e..8b514178 100644 --- a/src/main.c +++ b/src/main.c @@ -88,11 +88,6 @@ struct ws_assignments_head ws_assignments = TAILQ_HEAD_INITIALIZER(ws_assignment /* We hope that those are supported and set them to true */ bool xcursor_supported = true; -/* This will be set to true when -C is used so that functions can behave - * slightly differently. We don’t want i3-nagbar to be started when validating - * the config, for example. */ -bool only_check_config = false; - /* * This callback is only a dummy, see xcb_prepare_cb and xcb_check_cb. * See also man libev(3): "ev_prepare" and "ev_check" - customise your event loop @@ -201,6 +196,7 @@ int main(int argc, char *argv[]) { bool force_xinerama = false; char *fake_outputs = NULL; bool disable_signalhandler = false; + bool only_check_config = false; static struct option long_options[] = { {"no-autostart", no_argument, 0, 'a'}, {"config", required_argument, 0, 'c'}, @@ -366,10 +362,14 @@ int main(int argc, char *argv[]) { } } + if (only_check_config) { + exit(parse_configuration(override_configpath, false) ? 0 : 1); + } + /* If the user passes more arguments, we act like i3-msg would: Just send * the arguments as an IPC message to i3. This allows for nice semantic * commands such as 'i3 border none'. */ - if (!only_check_config && optind < argc) { + if (optind < argc) { /* We enable verbose mode so that the user knows what’s going on. * This should make it easier to find mistakes when the user passes * arguments by mistake. */ @@ -483,15 +483,15 @@ int main(int argc, char *argv[]) { colormap = root_screen->default_colormap; DLOG("root_depth = %d, visual_id = 0x%08x.\n", root_depth, visual_id); + DLOG("root_screen->height_in_pixels = %d, root_screen->height_in_millimeters = %d, dpi = %d\n", + root_screen->height_in_pixels, root_screen->height_in_millimeters, + (int)((double)root_screen->height_in_pixels * 25.4 / (double)root_screen->height_in_millimeters)); + DLOG("One logical pixel corresponds to %d physical pixels on this display.\n", logical_px(1)); 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) { - LOG("Done checking configuration file. Exiting.\n"); - exit(0); - } if (config.ipc_socket_path == NULL) { /* Fall back to a file name in /tmp/ based on the PID */ @@ -502,7 +502,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); @@ -536,9 +536,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); @@ -674,6 +674,7 @@ int main(int argc, char *argv[]) { /* Set the ewmh desktop properties. */ ewmh_update_current_desktop(); ewmh_update_number_of_desktops(); + ewmh_update_desktop_names(); ewmh_update_desktop_viewport(); struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io)); @@ -741,10 +742,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); @@ -777,7 +778,7 @@ int main(int argc, char *argv[]) { ELOG("Could not setup signal handler"); /* 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 */