* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009-2013 Michael Stapelberg and contributors (see also: LICENSE)
*
* main.c: Initialization, main loop
*
#include <sys/mman.h>
#include <sys/stat.h>
#include "all.h"
+#include "shmlog.h"
#include "sd-daemon.h"
/* Those are our connections to X11 for use with libXcursor and XKB */
Display *xlibdpy, *xkbdpy;
+/* Default shmlog size if not set by user. */
+const int default_shmlog_size = 25 * 1024 * 1024;
+
/* The list of key bindings */
struct bindings_head *bindings;
* (file) logging. */
init_logging();
- /* On non-release builds, disable SHM logging by default. */
- shmlog_size = (is_debug_build() ? 25 * 1024 * 1024 : 0);
+ /* On release builds, disable SHM logging by default. */
+ shmlog_size = (is_debug_build() ? default_shmlog_size : 0);
start_argv = argv;
only_check_config = true;
break;
case 'v':
- printf("i3 version " I3_VERSION " © 2009-2012 Michael Stapelberg and contributors\n");
+ printf("i3 version " I3_VERSION " © 2009-2013 Michael Stapelberg and contributors\n");
exit(EXIT_SUCCESS);
break;
case 'm':
- printf("Binary i3 version: " I3_VERSION " © 2009-2012 Michael Stapelberg and contributors\n");
+ printf("Binary i3 version: " I3_VERSION " © 2009-2013 Michael Stapelberg and contributors\n");
display_running_version();
exit(EXIT_SUCCESS);
break;
break;
} else if (strcmp(long_options[option_index].name, "get-socketpath") == 0 ||
strcmp(long_options[option_index].name, "get_socketpath") == 0) {
- char *socket_path = root_atom_contents("I3_SOCKET_PATH");
+ char *socket_path = root_atom_contents("I3_SOCKET_PATH", NULL, 0);
if (socket_path) {
printf("%s\n", socket_path);
exit(EXIT_SUCCESS);
optind++;
}
DLOG("Command is: %s (%zd bytes)\n", payload, strlen(payload));
- char *socket_path = root_atom_contents("I3_SOCKET_PATH");
+ char *socket_path = root_atom_contents("I3_SOCKET_PATH", NULL, 0);
if (!socket_path) {
ELOG("Could not get i3 IPC socket path\n");
return 1;
err(EXIT_FAILURE, "IPC: write()");
uint32_t reply_length;
+ uint32_t reply_type;
uint8_t *reply;
int ret;
- if ((ret = ipc_recv_message(sockfd, I3_IPC_MESSAGE_TYPE_COMMAND,
- &reply_length, &reply)) != 0) {
+ if ((ret = ipc_recv_message(sockfd, &reply_type, &reply_length, &reply)) != 0) {
if (ret == -1)
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);
printf("%.*s\n", reply_length, reply);
return 0;
}
config.ipc_socket_path = sstrdup(config.ipc_socket_path);
}
- uint32_t mask = XCB_CW_EVENT_MASK;
- uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
- XCB_EVENT_MASK_BUTTON_PRESS |
- XCB_EVENT_MASK_STRUCTURE_NOTIFY | /* when the user adds a screen (e.g. video
- projector), the root window gets a
- ConfigureNotify */
- XCB_EVENT_MASK_POINTER_MOTION |
- XCB_EVENT_MASK_PROPERTY_CHANGE |
- XCB_EVENT_MASK_ENTER_WINDOW };
xcb_void_cookie_t cookie;
- cookie = xcb_change_window_attributes_checked(conn, root, mask, values);
+ 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);
int i1;
if (!XkbQueryExtension(xkbdpy,&i1,&xkb_event_base,&errBase,&major,&minor)) {
fprintf(stderr, "XKB not supported by X-server\n");
- return 1;
+ xkb_supported = false;
}
/* end of ugliness */
- if (!XkbSelectEvents(xkbdpy, XkbUseCoreKbd,
- XkbMapNotifyMask | XkbStateNotifyMask,
- XkbMapNotifyMask | XkbStateNotifyMask)) {
+ if (xkb_supported && !XkbSelectEvents(xkbdpy, XkbUseCoreKbd,
+ XkbMapNotifyMask | XkbStateNotifyMask,
+ XkbMapNotifyMask | XkbStateNotifyMask)) {
fprintf(stderr, "Could not set XKB event mask\n");
return 1;
}
/* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */
x_set_i3_atoms();
+ ewmh_update_workarea();
struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io));
struct ev_io *xkb = scalloc(sizeof(struct ev_io));