From 6d8784af9851cd6cfab89b12d58fb34fe683f05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sun, 20 Mar 2011 11:34:34 -0300 Subject: [PATCH] Set the I3_SOCKET_PATH atom to the expanded path. --- include/ipc.h | 2 ++ src/ipc.c | 8 +++++++- src/main.c | 6 +++--- src/x.c | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/ipc.h b/include/ipc.h index 7f92ee61..a5de487a 100644 --- a/include/ipc.h +++ b/include/ipc.h @@ -22,6 +22,8 @@ #include "i3/ipc.h" +extern char *current_socketpath; + typedef struct ipc_client { int fd; diff --git a/src/ipc.c b/src/ipc.c index a6f0dd5c..b76d2bb1 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -20,6 +20,8 @@ #include "all.h" +char *current_socketpath = NULL; + /* Shorter names for all those yajl_gen_* functions */ #define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__) #define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str)) @@ -626,6 +628,9 @@ void ipc_new_client(EV_P_ struct ev_io *w, int revents) { int ipc_create_socket(const char *filename) { int sockfd; + FREE(current_socketpath); + current_socketpath = NULL; + char *resolved = resolve_tilde(filename); DLOG("Creating IPC-socket at %s\n", resolved); char *copy = sstrdup(resolved); @@ -655,13 +660,14 @@ int ipc_create_socket(const char *filename) { return -1; } - free(resolved); set_nonblock(sockfd); if (listen(sockfd, 5) < 0) { perror("listen()"); + free(resolved); return -1; } + current_socketpath = resolved; return sockfd; } diff --git a/src/main.c b/src/main.c index 2f632dd6..d1b1a532 100644 --- a/src/main.c +++ b/src/main.c @@ -350,9 +350,6 @@ int main(int argc, char *argv[]) { xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, A_WINDOW, 32, 1, &root); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3"); - /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */ - x_set_i3_atoms(); - keysyms = xcb_key_symbols_alloc(conn); xcb_get_numlock_mask(conn); @@ -396,6 +393,9 @@ int main(int argc, char *argv[]) { } } + /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */ + x_set_i3_atoms(); + struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io)); struct ev_io *xkb = scalloc(sizeof(struct ev_io)); struct ev_check *xcb_check = scalloc(sizeof(struct ev_check)); diff --git a/src/x.c b/src/x.c index c21ff739..826d2134 100644 --- a/src/x.c +++ b/src/x.c @@ -783,8 +783,8 @@ void x_set_name(Con *con, const char *name) { */ void x_set_i3_atoms() { xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_SOCKET_PATH, A_UTF8_STRING, 8, - (config.ipc_socket_path != NULL ? strlen(config.ipc_socket_path) : 0), - config.ipc_socket_path); + (current_socketpath == NULL ? 0 : strlen(current_socketpath)), + current_socketpath); xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_CONFIG_PATH, A_UTF8_STRING, 8, strlen(current_configpath), current_configpath); }