-#undef I3__FILE__
-#define I3__FILE__ "main.c"
/*
* vim:ts=4:sw=4:expandtab
*
* main.c: Initialization, main loop
*
*/
+#include "all.h"
+
#include <ev.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <libgen.h>
-#include "all.h"
#include "shmlog.h"
+#ifdef I3_ASAN_ENABLED
+#include <sanitizer/lsan_interface.h>
+#endif
+
#include "sd-daemon.h"
/* The original value of RLIMIT_CORE when i3 was started. We need to restore
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;
+ static const char *_i3_version __attribute__((used)) = I3_VERSION;
char *override_configpath = NULL;
bool autostart = true;
char *layout_path = NULL;
bool delete_layout_path = false;
bool force_xinerama = false;
+ bool disable_randr15 = false;
char *fake_outputs = NULL;
bool disable_signalhandler = false;
bool only_check_config = false;
{"restart", required_argument, 0, 0},
{"force-xinerama", no_argument, 0, 0},
{"force_xinerama", no_argument, 0, 0},
+ {"disable-randr15", no_argument, 0, 0},
+ {"disable_randr15", no_argument, 0, 0},
{"disable-signalhandler", no_argument, 0, 0},
{"shmlog-size", required_argument, 0, 0},
{"shmlog_size", required_argument, 0, 0},
"Please check if your driver really does not support RandR "
"and disable this option as soon as you can.\n");
break;
+ } else if (strcmp(long_options[option_index].name, "disable-randr15") == 0 ||
+ strcmp(long_options[option_index].name, "disable_randr15") == 0) {
+ disable_randr15 = true;
+ break;
} else if (strcmp(long_options[option_index].name, "disable-signalhandler") == 0) {
disable_signalhandler = true;
break;
memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_LOCAL;
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
+ FREE(socket_path);
if (connect(sockfd, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0)
err(EXIT_FAILURE, "Could not connect to i3");
- if (ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_COMMAND,
+ if (ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_RUN_COMMAND,
(uint8_t *)payload) == -1)
err(EXIT_FAILURE, "IPC: write()");
+ FREE(payload);
uint32_t reply_length;
uint32_t reply_type;
err(EXIT_FAILURE, "IPC: read()");
return 1;
}
- if (reply_type != I3_IPC_MESSAGE_TYPE_COMMAND)
- errx(EXIT_FAILURE, "IPC: received reply of type %d but expected %d (COMMAND)", reply_type, I3_IPC_MESSAGE_TYPE_COMMAND);
+ if (reply_type != I3_IPC_REPLY_TYPE_COMMAND)
+ errx(EXIT_FAILURE, "IPC: received reply of type %d but expected %d (COMMAND)", reply_type, I3_IPC_REPLY_TYPE_COMMAND);
printf("%.*s\n", reply_length, reply);
+ FREE(reply);
return 0;
}
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\".\n", cwd);
+ LOG("CORE DUMPS: Your core_pattern is: %s", cwd);
close(patternfd);
}
free(cwd);
visual_type = get_visualtype(root_screen);
}
+ init_dpi();
+
DLOG("root_depth = %d, visual_id = 0x%08x.\n", root_depth, visual_type->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("root_screen->height_in_pixels = %d, root_screen->height_in_millimeters = %d\n",
+ root_screen->height_in_pixels, 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_generic_error_t *error = xcb_request_check(conn, cookie);
if (error != NULL) {
ELOG("Another window manager seems to be running (X error %d)\n", error->error_code);
+#ifdef I3_ASAN_ENABLED
+ __lsan_do_leak_check();
+#endif
return 1;
}
xcb_xkb_per_client_flags_reply_t *pcf_reply;
/* The last three parameters are unset because they are only relevant
* when using a feature called “automatic reset of boolean controls”:
- * http://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Automatic_Reset_of_Boolean_Controls
+ * https://www.x.org/releases/X11R7.7/doc/kbproto/xkbproto.html#Automatic_Reset_of_Boolean_Controls
* */
pcf_reply = xcb_xkb_per_client_flags_reply(
conn,
xinerama_init();
} else {
DLOG("Checking for XRandR...\n");
- randr_init(&randr_base);
+ randr_init(&randr_base, disable_randr15 || config.disable_randr15);
}
/* We need to force disabling outputs which have been loaded from the
TAILQ_FOREACH(con, &(croot->nodes_head), nodes) {
Output *output;
TAILQ_FOREACH(output, &outputs, outputs) {
- if (output->active || strcmp(con->name, output->name) != 0)
+ if (output->active || strcmp(con->name, output_primary_name(output)) != 0)
continue;
/* This will correctly correlate the output with its content
(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(conn, root->root, XCB_CW_BACK_PIXMAP, (uint32_t[]){pixmap});
xcb_flush(conn);
xcb_free_gc(conn, gc);
xcb_free_pixmap(conn, pixmap);