i3
ipc.h
Go to the documentation of this file.
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * ipc.c: UNIX domain socket IPC (initialization, client handling, protocol).
8  *
9  */
10 #ifndef I3_IPC_H
11 #define I3_IPC_H
12 
13 #include <ev.h>
14 #include <stdbool.h>
15 #include <yajl/yajl_gen.h>
16 #include <yajl/yajl_parse.h>
17 
18 #include "data.h"
19 #include "tree.h"
20 
21 #include "i3/ipc.h"
22 
23 extern char *current_socketpath;
24 
25 typedef struct ipc_client {
26  int fd;
27 
28  /* The events which this client wants to receive */
30  char **events;
31 
32  TAILQ_ENTRY(ipc_client) clients;
33 } ipc_client;
34 
35 /*
36  * Callback type for the different message types.
37  *
38  * message is the raw packet, as received from the UNIX domain socket. size
39  * is the remaining size of bytes for this packet.
40  *
41  * message_size is the size of the message as the sender specified it.
42  * message_type is the type of the message as the sender specified it.
43  *
44  */
45 typedef void(*handler_t)(int, uint8_t*, int, uint32_t, uint32_t);
46 
47 /* Macro to declare a callback */
48 #define IPC_HANDLER(name) \
49  static void handle_ ## name (int fd, uint8_t *message, \
50  int size, uint32_t message_size, \
51  uint32_t message_type)
52 
60 void ipc_new_client(EV_P_ struct ev_io *w, int revents);
61 
67 int ipc_create_socket(const char *filename);
68 
74 void ipc_send_event(const char *event, uint32_t message_type, const char *payload);
75 
81 void ipc_shutdown(void);
82 
83 void dump_node(yajl_gen gen, Con *con, bool inplace_restart);
84 
85 #endif
Definition: ipc.h:25
A &#39;Con&#39; represents everything from the X11 root window down to a single X11 window.
Definition: data.h:457
void(* handler_t)(int, uint8_t *, int, uint32_t, uint32_t)
Definition: ipc.h:45
TAILQ_ENTRY(ipc_client) clients
void ipc_send_event(const char *event, uint32_t message_type, const char *payload)
Sends the specified event to all IPC clients which are currently connected and subscribed to this kin...
Definition: ipc.c:75
int ipc_create_socket(const char *filename)
Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s and listen()s...
Definition: ipc.c:916
char ** events
Definition: ipc.h:30
int num_events
Definition: ipc.h:29
char * current_socketpath
Definition: ipc.c:23
int fd
Definition: ipc.h:26
void ipc_shutdown(void)
Calls shutdown() on each socket and closes it.
Definition: ipc.c:98
void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart)
Definition: ipc.c:150
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...
Definition: ipc.c:883