i3
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ipc.h File Reference
#include <config.h>
#include <ev.h>
#include <stdbool.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_parse.h>
#include "data.h"
#include "tree.h"
#include "configuration.h"
#include "i3/ipc.h"
Include dependency graph for ipc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ipc_client
 

Macros

#define IPC_HANDLER(name)
 

Typedefs

typedef struct ipc_client ipc_client
 
typedef void(* handler_t) (int, uint8_t *, int, uint32_t, uint32_t)
 

Enumerations

enum  shutdown_reason_t { SHUTDOWN_REASON_RESTART, SHUTDOWN_REASON_EXIT }
 Calls to ipc_shutdown() should provide a reason for the shutdown. More...
 

Functions

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 should accept() him. More...
 
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 on it. More...
 
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 kind of event. More...
 
void ipc_shutdown (shutdown_reason_t reason)
 Calls shutdown() on each socket and closes it. More...
 
void dump_node (yajl_gen gen, Con *con, bool inplace_restart)
 
yajl_gen ipc_marshal_workspace_event (const char *change, Con *current, Con *old)
 Generates a json workspace event. More...
 
void ipc_send_workspace_event (const char *change, Con *current, Con *old)
 For the workspace events we send, along with the usual "change" field, also the workspace container in "current". More...
 
void ipc_send_window_event (const char *property, Con *con)
 For the window events we send, along the usual "change" field, also the window container, in "container". More...
 
void ipc_send_barconfig_update_event (Barconfig *barconfig)
 For the barconfig update events, we send the serialized barconfig. More...
 
void ipc_send_binding_event (const char *event_type, Binding *bind)
 For the binding events, we send the serialized binding struct. More...
 
void ipc_set_kill_timeout (ev_tstamp new)
 Set the maximum duration that we allow for a connection with an unwriteable socket. More...
 

Variables

char * current_socketpath
 

Macro Definition Documentation

◆ IPC_HANDLER

#define IPC_HANDLER (   name)
Value:
static void handle_##name(int fd, uint8_t *message, \
int size, uint32_t message_size, \
uint32_t message_type)
char * name
Definition: data.h:379

Definition at line 60 of file ipc.h.

Typedef Documentation

◆ handler_t

typedef void(* handler_t) (int, uint8_t *, int, uint32_t, uint32_t)

Definition at line 57 of file ipc.h.

◆ ipc_client

typedef struct ipc_client ipc_client

Enumeration Type Documentation

◆ shutdown_reason_t

Calls to ipc_shutdown() should provide a reason for the shutdown.

Enumerator
SHUTDOWN_REASON_RESTART 
SHUTDOWN_REASON_EXIT 

Definition at line 91 of file ipc.h.

Function Documentation

◆ dump_node()

void dump_node ( yajl_gen  gen,
Con con,
bool  inplace_restart 
)

◆ ipc_create_socket()

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 on it.

Definition at line 1488 of file ipc.c.

References current_socketpath, DEFAULT_DIR_MODE, DLOG, FREE, mkdirp(), path_exists(), resolve_tilde(), set_nonblock(), and sstrdup().

Referenced by main().

Here is the call graph for this function:

◆ ipc_marshal_workspace_event()

yajl_gen ipc_marshal_workspace_event ( const char *  change,
Con current,
Con old 
)

Generates a json workspace event.

Returns a dynamically allocated yajl generator. Free with yajl_gen_free().

Definition at line 1538 of file ipc.c.

References dump_node(), y, ygenalloc, and ystr.

Referenced by con_on_remove_child(), ipc_send_workspace_event(), and workspace_show().

Here is the call graph for this function:

◆ ipc_new_client()

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 should accept() him.

Sets up the event handler for activity on the new connection and inserts the file descriptor into the list of clients.

Definition at line 1448 of file ipc.c.

References all_clients, DLOG, ipc_receive_message(), ipc_socket_writeable_cb(), scalloc(), set_nonblock(), and TAILQ_INSERT_TAIL.

Referenced by main().

Here is the call graph for this function:

◆ ipc_send_barconfig_update_event()

void ipc_send_barconfig_update_event ( Barconfig barconfig)

For the barconfig update events, we send the serialized barconfig.

Definition at line 1616 of file ipc.c.

References DLOG, dump_bar_config(), Barconfig::id, ipc_send_event(), y, and ygenalloc.

Referenced by update_barconfig().

Here is the call graph for this function:

◆ ipc_send_binding_event()

void ipc_send_binding_event ( const char *  event_type,
Binding bind 
)

For the binding events, we send the serialized binding struct.

Definition at line 1635 of file ipc.c.

References DLOG, dump_binding(), ipc_send_event(), Binding::keycode, Binding::symbol, y, ygenalloc, and ystr.

Referenced by run_binding().

Here is the call graph for this function:

◆ ipc_send_event()

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 kind of event.

Definition at line 148 of file ipc.c.

References all_clients, append_payload(), ipc_client::buffer_size, ipc_client::events, ipc_push_pending(), ipc_client::num_events, and TAILQ_FOREACH.

Referenced by con_on_remove_child(), handle_screen_change(), IPC_HANDLER(), ipc_send_barconfig_update_event(), ipc_send_binding_event(), ipc_send_shutdown_event(), ipc_send_window_event(), ipc_send_workspace_event(), switch_mode(), and workspace_show().

Here is the call graph for this function:

◆ ipc_send_window_event()

void ipc_send_window_event ( const char *  property,
Con con 
)

For the window events we send, along the usual "change" field, also the window container, in "container".

Definition at line 1587 of file ipc.c.

References DLOG, dump_node(), Window::id, ipc_send_event(), Con::window, y, ygenalloc, and ystr.

Referenced by _con_move_to_con(), con_focus(), con_mark(), con_set_fullscreen_mode(), con_set_urgency(), con_unmark(), floating_disable(), floating_enable(), handle_windowname_change(), handle_windowname_change_legacy(), manage_window(), move_to_output_directed(), tree_close_internal(), tree_move(), workspace_defer_update_urgent_hint_cb(), and x_push_changes().

Here is the call graph for this function:

◆ ipc_send_workspace_event()

void ipc_send_workspace_event ( const char *  change,
Con current,
Con old 
)

For the workspace events we send, along with the usual "change" field, also the workspace container in "current".

For focus events, we send the previously focused workspace in "old".

Definition at line 1571 of file ipc.c.

References ipc_marshal_workspace_event(), ipc_send_event(), and y.

Referenced by cmd_append_layout(), cmd_reload(), cmd_rename_workspace(), workspace_get(), workspace_move_to_output(), workspace_show(), and workspace_update_urgent_flag().

Here is the call graph for this function:

◆ ipc_set_kill_timeout()

void ipc_set_kill_timeout ( ev_tstamp  new)

Set the maximum duration that we allow for a connection with an unwriteable socket.

Definition at line 86 of file ipc.c.

References kill_timeout.

Referenced by CFGFUN().

◆ ipc_shutdown()

void ipc_shutdown ( shutdown_reason_t  reason)

Calls shutdown() on each socket and closes it.

Definition at line 201 of file ipc.c.

References all_clients, ipc_client::fd, free_ipc_client(), ipc_send_shutdown_event(), TAILQ_EMPTY, and TAILQ_FIRST.

Referenced by cmd_exit(), cmd_restart(), i3_exit(), and i3_restart().

Here is the call graph for this function:

Variable Documentation

◆ current_socketpath

char* current_socketpath

Definition at line 23 of file ipc.c.

Referenced by ipc_create_socket(), main(), and x_set_i3_atoms().