20#include <sys/resource.h>
21#include <sys/socket.h>
27#include <xcb/xcb_atom.h>
28#include <xcb/xinerama.h>
29#include <xcb/bigreq.h>
32#include <sanitizer/lsan_interface.h>
110#define xmacro(atom) xcb_atom_t A_##atom;
133 xcb_generic_event_t *event;
135 while ((event = xcb_poll_for_event(
conn)) != NULL) {
136 if (event->response_type == 0) {
138 DLOG(
"Expected X11 Error received for sequence %x\n", event->sequence);
140 xcb_generic_error_t *error = (xcb_generic_error_t *)event;
141 DLOG(
"X11 Error received (probably harmless)! sequence 0x%x, error_code = %d\n",
142 error->sequence, error->error_code);
149 int type = (
event->response_type & 0x7F);
167 DLOG(
"Setting main X11 callback to enabled=%d\n", enable);
184 fprintf(stderr,
"Closing SHM log \"%s\"\n",
shmlogname);
193 xcb_disconnect(
conn);
202#if EV_VERSION_MAJOR >= 4
206#ifdef I3_ASAN_ENABLED
207 __lsan_do_leak_check();
233 exit(128 + signal->signum);
241 static struct ev_signal signal_watchers[6];
242 const size_t num_watchers =
sizeof(signal_watchers) /
sizeof(signal_watchers[0]);
256 for (
size_t i = 0; i < num_watchers; i++) {
257 ev_signal_start(
main_loop, &signal_watchers[i]);
266 const char *restart_fd = getenv(
"_I3_RESTART_FD");
267 if (restart_fd == NULL) {
273 ELOG(
"Malformed _I3_RESTART_FD \"%s\"\n", restart_fd);
279int main(
int argc,
char *argv[]) {
282 static const char *_i3_version
__attribute__((used)) = I3_VERSION;
283 char *override_configpath = NULL;
284 bool autostart =
true;
285 char *layout_path = NULL;
286 bool delete_layout_path =
false;
287 bool disable_randr15 =
false;
288 char *fake_outputs = NULL;
289 bool disable_signalhandler =
false;
291 bool replace_wm =
false;
292 static struct option long_options[] = {
293 {
"no-autostart", no_argument, 0,
'a'},
294 {
"config", required_argument, 0,
'c'},
295 {
"version", no_argument, 0,
'v'},
296 {
"moreversion", no_argument, 0,
'm'},
297 {
"more-version", no_argument, 0,
'm'},
298 {
"more_version", no_argument, 0,
'm'},
299 {
"help", no_argument, 0,
'h'},
300 {
"layout", required_argument, 0,
'L'},
301 {
"restart", required_argument, 0, 0},
302 {
"force-xinerama", no_argument, 0, 0},
303 {
"force_xinerama", no_argument, 0, 0},
304 {
"disable-randr15", no_argument, 0, 0},
305 {
"disable_randr15", no_argument, 0, 0},
306 {
"disable-signalhandler", no_argument, 0, 0},
307 {
"shmlog-size", required_argument, 0, 0},
308 {
"shmlog_size", required_argument, 0, 0},
309 {
"get-socketpath", no_argument, 0, 0},
310 {
"get_socketpath", no_argument, 0, 0},
311 {
"fake_outputs", required_argument, 0, 0},
312 {
"fake-outputs", required_argument, 0, 0},
313 {
"force-old-config-parser-v4.4-only", no_argument, 0, 0},
314 {
"replace", no_argument, 0,
'r'},
316 int option_index = 0, opt;
318 setlocale(LC_ALL,
"");
325 if (!isatty(fileno(stdout))) {
326 setbuf(stdout, NULL);
340 while ((opt = getopt_long(argc, argv,
"c:CvmaL:hld:Vr", long_options, &option_index)) != -1) {
343 LOG(
"Autostart disabled using -a\n");
349 delete_layout_path =
false;
352 FREE(override_configpath);
353 override_configpath =
sstrdup(optarg);
356 LOG(
"Checking configuration file only (-C)\n");
360 printf(
"i3 version %s © 2009 Michael Stapelberg and contributors\n",
i3_version);
364 printf(
"Binary i3 version: %s © 2009 Michael Stapelberg and contributors\n",
i3_version);
372 LOG(
"Enabling debug logging\n");
382 if (strcmp(long_options[option_index].name,
"force-xinerama") == 0 ||
383 strcmp(long_options[option_index].name,
"force_xinerama") == 0) {
385 ELOG(
"Using Xinerama instead of RandR. This option should be "
386 "avoided at all cost because it does not refresh the list "
387 "of screens, so you cannot configure displays at runtime. "
388 "Please check if your driver really does not support RandR "
389 "and disable this option as soon as you can.\n");
391 }
else if (strcmp(long_options[option_index].name,
"disable-randr15") == 0 ||
392 strcmp(long_options[option_index].name,
"disable_randr15") == 0) {
393 disable_randr15 =
true;
395 }
else if (strcmp(long_options[option_index].name,
"disable-signalhandler") == 0) {
396 disable_signalhandler =
true;
398 }
else if (strcmp(long_options[option_index].name,
"get-socketpath") == 0 ||
399 strcmp(long_options[option_index].name,
"get_socketpath") == 0) {
402 printf(
"%s\n", socket_path);
412 }
else if (strcmp(long_options[option_index].name,
"shmlog-size") == 0 ||
413 strcmp(long_options[option_index].name,
"shmlog_size") == 0) {
420 }
else if (strcmp(long_options[option_index].name,
"restart") == 0) {
423 delete_layout_path =
true;
425 }
else if (strcmp(long_options[option_index].name,
"fake-outputs") == 0 ||
426 strcmp(long_options[option_index].name,
"fake_outputs") == 0) {
427 LOG(
"Initializing fake outputs: %s\n", optarg);
428 fake_outputs =
sstrdup(optarg);
430 }
else if (strcmp(long_options[option_index].name,
"force-old-config-parser-v4.4-only") == 0) {
431 ELOG(
"You are passing --force-old-config-parser-v4.4-only, but that flag was removed by now.\n");
436 fprintf(stderr,
"Usage: %s [-c configfile] [-d all] [-a] [-v] [-V] [-C]\n", argv[0]);
437 fprintf(stderr,
"\n");
438 fprintf(stderr,
"\t-a disable autostart ('exec' lines in config)\n");
439 fprintf(stderr,
"\t-c <file> use the provided configfile instead\n");
440 fprintf(stderr,
"\t-C validate configuration file and exit\n");
441 fprintf(stderr,
"\t-d all enable debug output\n");
442 fprintf(stderr,
"\t-L <file> path to the serialized layout during restarts\n");
443 fprintf(stderr,
"\t-v display version and exit\n");
444 fprintf(stderr,
"\t-V enable verbose mode\n");
445 fprintf(stderr,
"\n");
446 fprintf(stderr,
"\t--force-xinerama\n"
447 "\tUse Xinerama instead of RandR.\n"
448 "\tThis option should only be used if you are stuck with the\n"
449 "\told nVidia closed source driver (older than 302.17), which does\n"
450 "\tnot support RandR.\n");
451 fprintf(stderr,
"\n");
452 fprintf(stderr,
"\t--get-socketpath\n"
453 "\tRetrieve the i3 IPC socket path from X11, print it, then exit.\n");
454 fprintf(stderr,
"\n");
455 fprintf(stderr,
"\t--shmlog-size <limit>\n"
456 "\tLimits the size of the i3 SHM log to <limit> bytes. Setting this\n"
457 "\tto 0 disables SHM logging entirely.\n"
458 "\tThe default is %d bytes.\n",
460 fprintf(stderr,
"\n");
461 fprintf(stderr,
"\t--replace\n"
462 "\tReplace an existing window manager.\n");
463 fprintf(stderr,
"\n");
464 fprintf(stderr,
"If you pass plain text arguments, i3 will interpret them as a command\n"
465 "to send to a currently running i3 (like i3-msg). This allows you to\n"
466 "use nice and logical commands, such as:\n"
469 "\ti3 floating toggle\n"
472 exit(opt ==
'h' ? EXIT_SUCCESS : EXIT_FAILURE);
489 LOG(
"Additional arguments passed. Sending them as a command to i3.\n");
490 char *payload = NULL;
491 while (optind < argc) {
493 payload =
sstrdup(argv[optind]);
496 sasprintf(&both,
"%s %s", payload, argv[optind]);
502 DLOG(
"Command is: %s (%zd bytes)\n", payload, strlen(payload));
505 ELOG(
"Could not get i3 IPC socket path\n");
509 int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
511 err(EXIT_FAILURE,
"Could not create socket");
514 struct sockaddr_un addr;
515 memset(&addr, 0,
sizeof(
struct sockaddr_un));
516 addr.sun_family = AF_LOCAL;
517 strncpy(addr.sun_path, socket_path,
sizeof(addr.sun_path) - 1);
519 if (connect(sockfd, (
const struct sockaddr *)&addr,
sizeof(
struct sockaddr_un)) < 0) {
520 err(EXIT_FAILURE,
"Could not connect to i3");
523 if (
ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_RUN_COMMAND,
524 (uint8_t *)payload) == -1) {
525 err(EXIT_FAILURE,
"IPC: write()");
529 uint32_t reply_length;
533 if ((ret =
ipc_recv_message(sockfd, &reply_type, &reply_length, &reply)) != 0) {
535 err(EXIT_FAILURE,
"IPC: read()");
539 if (reply_type != I3_IPC_REPLY_TYPE_COMMAND) {
540 errx(EXIT_FAILURE,
"IPC: received reply of type %d but expected %d (COMMAND)", reply_type, I3_IPC_REPLY_TYPE_COMMAND);
542 printf(
"%.*s\n", reply_length, reply);
552 struct rlimit limit = {RLIM_INFINITY, RLIM_INFINITY};
553 setrlimit(RLIMIT_CORE, &limit);
557 LOG(
"CORE DUMPS: You are running a development version of i3, so coredumps were automatically enabled (ulimit -c unlimited).\n");
558 size_t cwd_size = 1024;
561 while ((cwd_ret = getcwd(cwd, cwd_size)) == NULL && errno == ERANGE) {
562 cwd_size = cwd_size * 2;
565 if (cwd_ret != NULL) {
566 LOG(
"CORE DUMPS: Your current working directory is \"%s\".\n", cwd);
569 if ((patternfd = open(
"/proc/sys/kernel/core_pattern", O_RDONLY)) >= 0) {
570 memset(cwd,
'\0', cwd_size);
571 if (read(patternfd, cwd, cwd_size) > 0) {
573 LOG(
"CORE DUMPS: Your core_pattern is: %s", cwd);
583 if (xcb_connection_has_error(
conn)) {
584 errx(EXIT_FAILURE,
"Cannot open display");
598 die(
"Could not initialize libev. Bad LIBEV_FLAGS?\n");
605 xcb_prefetch_extension_data(
conn, &xcb_xkb_id);
606 xcb_prefetch_extension_data(
conn, &xcb_shape_id);
608 xcb_prefetch_extension_data(
conn, &xcb_big_requests_id);
610 xcb_prefetch_extension_data(
conn, &xcb_xinerama_id);
612 xcb_prefetch_extension_data(
conn, &xcb_randr_id);
616 xcb_change_window_attributes(
conn,
root, XCB_CW_EVENT_MASK, (uint32_t[]){XCB_EVENT_MASK_PROPERTY_CHANGE});
617 xcb_change_property(
conn, XCB_PROP_MODE_APPEND,
root, XCB_ATOM_SUPERSCRIPT_X, XCB_ATOM_CARDINAL, 32, 0,
"");
620#define xmacro(atom) \
621 xcb_intern_atom_cookie_t atom##_cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom);
633 xcb_void_cookie_t cm_cookie = xcb_create_colormap_checked(
conn,
634 XCB_COLORMAP_ALLOC_NONE,
639 xcb_generic_error_t *error = xcb_request_check(
conn, cm_cookie);
641 ELOG(
"Could not create colormap. Error code: %d\n", error->error_code);
648 xcb_prefetch_maximum_request_length(
conn);
653 DLOG(
"root_screen->height_in_pixels = %d, root_screen->height_in_millimeters = %d\n",
655 DLOG(
"One logical pixel corresponds to %d physical pixels on this display.\n",
logical_px(1));
657 xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(
conn,
root);
658 xcb_query_pointer_cookie_t pointercookie = xcb_query_pointer(
conn,
root);
663 xcb_generic_event_t *event;
664 DLOG(
"waiting for PropertyNotify event\n");
665 while ((event = xcb_wait_for_event(
conn)) != NULL) {
666 if (event->response_type == XCB_PROPERTY_NOTIFY) {
677#define xmacro(name) \
679 xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, name##_cookie, NULL); \
681 ELOG("Could not get atom " #name "\n"); \
684 A_##name = reply->atom; \
703 if (ipc_socket == -1) {
714 char *atom_name = xcb_atom_name_by_screen(
"WM",
conn_screen);
717 if (atom_name == NULL) {
718 ELOG(
"xcb_atom_name_by_screen(\"WM\", %d) failed, exiting\n",
conn_screen);
722 xcb_intern_atom_reply_t *atom_reply;
723 atom_reply = xcb_intern_atom_reply(
conn,
724 xcb_intern_atom_unchecked(
conn,
730 if (atom_reply == NULL) {
731 ELOG(
"Failed to intern the WM_Sn atom, exiting\n");
734 wm_sn = atom_reply->atom;
738 xcb_get_selection_owner_reply_t *selection_reply =
739 xcb_get_selection_owner_reply(
conn,
742 if (selection_reply && selection_reply->owner != XCB_NONE && !replace_wm) {
743 ELOG(
"Another window manager is already running (WM_Sn is owned)");
748 xcb_create_window(
conn,
754 XCB_WINDOW_CLASS_INPUT_OUTPUT,
757 xcb_change_property(
conn,
758 XCB_PROP_MODE_REPLACE,
763 (strlen(
"i3-WM_Sn") + 1) * 2,
764 "i3-WM_Sn\0i3-WM_Sn\0");
768 if (selection_reply && selection_reply->owner != XCB_NONE) {
769 unsigned int usleep_time = 100000;
770 int check_rounds = 150;
771 xcb_get_geometry_reply_t *geom_reply = NULL;
773 DLOG(
"waiting for old WM_Sn selection owner to exit");
777 if (check_rounds-- == 0) {
778 ELOG(
"The old window manager is not exiting");
781 geom_reply = xcb_get_geometry_reply(
conn,
782 xcb_get_geometry(
conn, selection_reply->owner),
784 }
while (geom_reply != NULL);
786 free(selection_reply);
793 xcb_client_message_event_t message;
796 memset(&event, 0,
sizeof(event));
797 event.message.response_type = XCB_CLIENT_MESSAGE;
799 event.message.format = 32;
800 event.message.type = A_MANAGER;
802 event.message.data.data32[1] =
wm_sn;
805 xcb_send_event(
conn, 0,
root_screen->root, XCB_EVENT_MASK_STRUCTURE_NOTIFY, event.storage);
808 xcb_void_cookie_t cookie;
810 xcb_generic_error_t *error = xcb_request_check(
conn, cookie);
812 ELOG(
"Another window manager seems to be running (X error %d)\n", error->error_code);
813#ifdef I3_ASAN_ENABLED
814 __lsan_do_leak_check();
819 xcb_get_geometry_reply_t *greply = xcb_get_geometry_reply(
conn, gcookie, NULL);
820 if (greply == NULL) {
821 ELOG(
"Could not get geometry of the root window, exiting\n");
824 DLOG(
"root geometry reply: (%d, %d) %d x %d\n", greply->x, greply->y, greply->width, greply->height);
832 const xcb_query_extension_reply_t *extreply;
833 extreply = xcb_get_extension_data(
conn, &xcb_xkb_id);
835 if (!extreply->present) {
836 DLOG(
"xkb is not present on this server\n");
838 DLOG(
"initializing xcb-xkb\n");
839 xcb_xkb_use_extension(
conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION);
840 xcb_xkb_select_events(
conn,
841 XCB_XKB_ID_USE_CORE_KBD,
842 XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY,
844 XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY,
859 const uint32_t mask = XCB_XKB_PER_CLIENT_FLAG_GRABS_USE_XKB_STATE |
860 XCB_XKB_PER_CLIENT_FLAG_LOOKUP_STATE_WHEN_GRABBED |
861 XCB_XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT;
862 xcb_xkb_per_client_flags_reply_t *pcf_reply;
867 pcf_reply = xcb_xkb_per_client_flags_reply(
869 xcb_xkb_per_client_flags(
871 XCB_XKB_ID_USE_CORE_KBD,
879#define PCF_REPLY_ERROR(_value) \
881 if (pcf_reply == NULL || !(pcf_reply->value & (_value))) { \
882 ELOG("Could not set " #_value "\n"); \
896 extreply = xcb_get_extension_data(
conn, &xcb_shape_id);
897 if (extreply->present) {
899 xcb_shape_query_version_cookie_t cookie = xcb_shape_query_version(
conn);
900 xcb_shape_query_version_reply_t *version =
901 xcb_shape_query_version_reply(
conn, cookie, NULL);
908 DLOG(
"shape 1.1 is not present on this server\n");
922 die(
"Could not load keymap\n");
928 bool needs_tree_init =
true;
929 if (layout_path != NULL) {
930 LOG(
"Trying to restore the layout from \"%s\".\n", layout_path);
932 if (delete_layout_path) {
934 const char *dir = dirname(layout_path);
940 if (needs_tree_init) {
951 if (fake_outputs != NULL) {
961 DLOG(
"Checking for XRandR...\n");
981 if (output->
con == NULL) {
995 xcb_query_pointer_reply_t *pointerreply;
997 if (!(pointerreply = xcb_query_pointer_reply(
conn, pointercookie, NULL))) {
998 ELOG(
"Could not query pointer position, using first screen\n");
1000 DLOG(
"Pointer at %d, %d\n", pointerreply->root_x, pointerreply->root_y);
1003 ELOG(
"ERROR: No screen at (%d, %d), starting on the first screen\n",
1004 pointerreply->root_x, pointerreply->root_y);
1016 struct ev_io *ipc_io =
scalloc(1,
sizeof(
struct ev_io));
1023 free(log_stream_socket_path);
1024 struct ev_io *log_io = NULL;
1025 if (log_socket == -1) {
1026 ELOG(
"Could not create the log socket, i3-dump-log -f will not work\n");
1028 log_io =
scalloc(1,
sizeof(
struct ev_io));
1036 struct ev_io *socket_ipc_io = NULL;
1039 ELOG(
"socket activation: Error in sd_listen_fds\n");
1041 DLOG(
"socket activation: no sockets passed\n");
1047 DLOG(
"socket activation: also listening on fd %d\n", fd);
1052 if ((flags = fcntl(fd, F_GETFD)) < 0 ||
1053 fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) < 0) {
1054 ELOG(
"Could not disable FD_CLOEXEC on fd %d\n", fd);
1057 socket_ipc_io =
scalloc(1,
sizeof(
struct ev_io));
1065 if (restart_fd != -1) {
1066 DLOG(
"serving restart fd %d", restart_fd);
1069 unsetenv(
"_I3_RESTART_FD");
1080 struct ev_io *xcb_watcher =
scalloc(1,
sizeof(
struct ev_io));
1104 xcb_grab_server(
conn);
1107 xcb_generic_event_t *event;
1108 while ((event = xcb_poll_for_event(
conn)) != NULL) {
1109 if (event->response_type == 0) {
1115 int type = (
event->response_type & 0x7F);
1120 if (type == XCB_MAP_REQUEST) {
1128 xcb_ungrab_server(
conn);
1139 LOG(
"This is not an in-place restart, checking if a wallpaper is set.\n");
1143 LOG(
"A wallpaper is set, so no screenshot is necessary.\n");
1145 LOG(
"No wallpaper set, copying root window contents to a pixmap\n");
1150 if (!disable_signalhandler) {
1153 struct sigaction action;
1156 action.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
1157 sigemptyset(&action.sa_mask);
1160 if (sigaction(SIGQUIT, &action, NULL) == -1 ||
1161 sigaction(SIGILL, &action, NULL) == -1 ||
1162 sigaction(SIGABRT, &action, NULL) == -1 ||
1163 sigaction(SIGFPE, &action, NULL) == -1 ||
1164 sigaction(SIGSEGV, &action, NULL) == -1) {
1165 ELOG(
"Could not setup signal handler.\n");
1172 signal(SIGPIPE, SIG_IGN);
1192 LOG(
"auto-starting (always!) %s\n", exec_always->
command);
1206 barconfig->
verbose ?
"-V" :
"",
1226 (void)raise(SIGCHLD);
1233 FREE(socket_ipc_io);
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
void grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
pid_t command_error_nagbar_pid
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
void con_activate(Con *con)
Sets input focus to the given container and raises it to the top.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
bool load_configuration(const char *override_configpath, config_load_t load_type)
(Re-)loads the configuration file (sets useful defaults before).
struct barconfig_head barconfigs
pid_t config_error_nagbar_pid
void display_running_version(void)
Connects to i3 to find out the currently running version.
void ewmh_setup_hints(void)
Set up the EWMH hints on the root window.
void ewmh_update_desktop_properties(void)
Updates all the EWMH desktop properties.
void ewmh_update_workarea(void)
i3 currently does not support _NET_WORKAREA, because it does not correspond to i3’s concept of worksp...
void fake_outputs_init(const char *output_spec)
Creates outputs according to the given specification.
void handle_event(int type, xcb_generic_event_t *event)
Takes an xcb_generic_event_t and calls the appropriate handler, based on the event type.
bool event_is_ignored(const int sequence, const int response_type)
Checks if the given sequence is ignored and returns true if so.
void property_handlers_init(void)
Sets the appropriate atoms for the property handlers after the atoms were received from X11.
void manage_existing_windows(xcb_window_t root)
Go through all existing windows (if the window manager is restarted) and manage them.
char * output_primary_name(Output *output)
Retrieves the primary name of an output.
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Output * get_output_containing(unsigned int x, unsigned int y)
Returns the active (!) output which contains the coordinates x, y or NULL if there is no output which...
void output_init_con(Output *output)
Initializes a CT_OUTPUT Con (searches existing ones from inplace restart before) to use for the given...
struct outputs_head outputs
void randr_init(int *event_base, const bool disable_randr15)
We have just established a connection to the X server and need the initial XRandR information to setu...
Output * get_first_output(void)
Returns the first output which is active.
void randr_disable_output(Output *output)
Disables the output and moves its content.
void restore_connect(void)
Opens a separate connection to X11 for placeholder windows when restoring layouts.
void scratchpad_fix_resolution(void)
When starting i3 initially (and after each change to the connected outputs), this function fixes the ...
int sd_notify(int unset_environment, const char *state)
int sd_listen_fds(int unset_environment)
void setup_signal_handler(void)
Configured a signal handler to gracefully handle crashes and allow the user to generate a backtrace a...
void start_application(const char *command, bool no_startup_id)
Starts the given application by passing it through a shell.
bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry)
Loads tree from ~/.i3/_restart.json (used for in-place restarts).
void tree_init(xcb_get_geometry_reply_t *geometry)
Initializes the tree by creating the root node, adding all RandR outputs to the tree (that means rand...
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
void kill_nagbar(pid_t nagbar_pid, bool wait_for_it)
Kills the i3-nagbar process, if nagbar_pid != -1.
bool parse_long(const char *str, long *out, int base)
Converts a string into a long using strtol().
const char * i3_version
Git commit identifier, from version.c.
void x_set_i3_atoms(void)
Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
unsigned int xcb_numlock_mask
void xcursor_load_cursors(void)
void xcursor_set_root_cursor(int cursor_id)
Sets the cursor of the root window to the 'pointer' cursor.
void xinerama_init(void)
We have just established a connection to the X server and need the initial Xinerama information to se...
void ipc_confirm_restart(ipc_client *client)
Sends a restart reply to the IPC client on the specified fd.
ipc_client * ipc_new_client_on_fd(EV_P_ int fd)
ipc_new_client_on_fd() only sets up the event handler for activity on the new connection and inserts ...
char * current_socketpath
void ipc_shutdown(shutdown_reason_t reason, int exempt_fd)
Calls shutdown() on each socket and closes it.
void ipc_new_client(EV_P_ struct ev_io *w, int revents)
Handler for activity on the listening socket, meaning that a new client has just connected and we sho...
void log_new_client(EV_P_ struct ev_io *w, int revents)
void init_logging(void)
Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filenam...
void set_debug_logging(const bool _debug_logging)
Set debug logging.
char * current_log_stream_socket_path
void set_verbosity(bool _verbose)
Set verbosity of i3.
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
int main(int argc, char *argv[])
const int default_shmlog_size
#define PCF_REPLY_ERROR(_value)
static void handle_term_signal(struct ev_loop *loop, ev_signal *signal, int revents)
xcb_connection_t * conn
XCB connection and root screen.
int listen_fds
The number of file descriptors passed via socket activation.
xcb_key_symbols_t * keysyms
xcb_window_t wm_sn_selection_owner
struct autostarts_always_head autostarts_always
I3_NET_SUPPORTED_ATOMS_XMACRO static I3_REST_ATOMS_XMACRO void xcb_got_event(EV_P_ struct ev_io *w, int revents)
static struct ev_prepare * xcb_prepare
static void i3_exit(void)
struct rlimit original_rlimit_core
The original value of RLIMIT_CORE when i3 was started.
xcb_screen_t * root_screen
const char * current_binding_mode
static void setup_term_handlers(void)
xcb_visualtype_t * visual_type
static void handle_core_signal(int sig, siginfo_t *info, void *data)
void main_set_x11_cb(bool enable)
Enable or disable the main X11 event handling function.
struct autostarts_head autostarts
static int parse_restart_fd(void)
struct ev_loop * main_loop
static void xcb_prepare_cb(EV_P_ ev_prepare *w, int revents)
struct assignments_head assignments
struct ws_assignments_head ws_assignments
struct bindings_head * bindings
#define I3_NET_SUPPORTED_ATOMS_XMACRO
#define I3_REST_ATOMS_XMACRO
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
void set_screenshot_as_wallpaper(xcb_connection_t *conn, xcb_screen_t *screen)
Grab a screenshot of the screen's root window and set it as the wallpaper.
int create_socket(const char *filename, char **out_socketpath)
Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s and listen()s...
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
int ipc_recv_message(int sockfd, uint32_t *message_type, uint32_t *reply_length, uint8_t **reply)
Reads a message from the given socket file descriptor and stores its length (reply_length) as well as...
uint32_t aio_get_mod_mask_for(uint32_t keysym, xcb_key_symbols_t *symbols)
All-in-one function which returns the modifier mask (XCB_MOD_MASK_*) for the given keysymbol,...
void * scalloc(size_t num, size_t size)
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory a...
int sasprintf(char **strp, const char *fmt,...)
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory avail...
void * srealloc(void *ptr, size_t size)
Safe-wrapper around realloc which exits if realloc returns NULL (meaning that there is no more memory...
char * root_atom_contents(const char *atomname, xcb_connection_t *provided_conn, int screen)
Try to get the contents of the given atom (for example I3_SOCKET_PATH) from the X11 root window and r...
char * get_process_filename(const char *prefix)
Returns the name of a temporary file with the specified prefix.
int ipc_send_message(int sockfd, const uint32_t message_size, const uint32_t message_type, const uint8_t *payload)
Formats a message (payload) of the given size and type and sends it to i3 via the given socket file d...
bool is_background_set(xcb_connection_t *conn, xcb_screen_t *screen)
Test whether the screen's root window has a background set.
bool is_debug_build(void) __attribute__((const))
Returns true if this version of i3 is a debug build (anything which is not a release version),...
void init_dpi(void)
Initialize the DPI setting.
xcb_visualtype_t * get_visualtype(xcb_screen_t *screen)
Returns the visual type associated with the given screen.
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_FIRST(head)
#define TAILQ_REMOVE(head, elm, field)
#define TAILQ_HEAD_INITIALIZER(head)
#define TAILQ_EMPTY(head)
#define SD_LISTEN_FDS_START
char * fake_outputs
Overwrites output detection (for testing), see src/fake_outputs.c.
bool disable_randr15
Don’t use RandR 1.5 for querying outputs.
bool force_xinerama
By default, use the RandR API for multi-monitor setups.
Holds the status bar configuration (i3bar).
char * i3bar_command
Command that should be run to execute i3bar, give a full path if i3bar is not in your $PATH.
char * id
Automatically generated ID for this bar config.
bool verbose
Enable verbose mode? Useful for debugging purposes.
Holds a command specified by either an:
bool no_startup_id
no_startup_id flag for start_application().
char * command
Command, like in command mode.
An Output is a physical output on your graphics driver.
Con * con
Pointer to the Con which represents this output.
bool changed
Internal flags, necessary for querying RandR screens (happens in two stages)
bool active
Whether the output is currently active (has a CRTC attached with a valid mode)
A 'Con' represents everything from the X11 root window down to a single X11 window.