Set the I3_SOCKET_PATH atom to the expanded path.

next
Fernando Tarlá Cardoso Lemos 2011-03-20 11:34:34 -03:00 committed by Michael Stapelberg
parent 99ce340fea
commit 6d8784af98
4 changed files with 14 additions and 6 deletions

View File

@ -22,6 +22,8 @@
#include "i3/ipc.h"
extern char *current_socketpath;
typedef struct ipc_client {
int fd;

View File

@ -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;
}

View File

@ -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));

View File

@ -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);
}