i3
|
#include <config.h>
#include <libev/ev.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_parse.h>
#include "data.h"
#include "tree.h"
#include "configuration.h"
#include "i3/ipc.h"
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) (ipc_client *, 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. | |
ipc_client * | ipc_new_client_on_fd (EV_P_ int fd) |
ipc_new_client_on_fd() only sets up the event handler for activity on the new connection and inserts the file descriptor into the list of 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 kind of event. | |
void | ipc_shutdown (shutdown_reason_t reason, int exempt_fd) |
Calls shutdown() on each socket and closes it. | |
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. | |
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". | |
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". | |
void | ipc_send_barconfig_update_event (Barconfig *barconfig) |
For the barconfig update events, we send the serialized barconfig. | |
void | ipc_send_binding_event (const char *event_type, Binding *bind, const char *modename) |
For the binding events, we send the serialized binding struct. | |
void | ipc_set_kill_timeout (ev_tstamp new) |
Set the maximum duration that we allow for a connection with an unwriteable socket. | |
void | ipc_confirm_restart (ipc_client *client) |
Sends a restart reply to the IPC client on the specified fd. | |
Variables | |
char * | current_socketpath |
#define IPC_HANDLER | ( | name | ) |
typedef void(* handler_t) (ipc_client *, uint8_t *, int, uint32_t, uint32_t) |
typedef struct ipc_client ipc_client |
enum shutdown_reason_t |
Calls to ipc_shutdown() should provide a reason for the shutdown.
Enumerator | |
---|---|
SHUTDOWN_REASON_RESTART | |
SHUTDOWN_REASON_EXIT |
void dump_node | ( | yajl_gen | gen, |
Con * | con, | ||
bool | inplace_restart ) |
Definition at line 362 of file ipc.c.
References Con::border_style, BS_NONE, BS_NORMAL, BS_PIXEL, con_draw_decoration_into_frame(), con_get_output(), con_is_split(), con_orientation(), Con::current_border_width, Con::deco_rect, Con::depth, DLOG, Match::dock, dump_gaps(), dump_node(), DUMP_PROPERTY, dump_rect(), DUMP_REGEX, Con::floating, focused, Con::fullscreen_mode, Con::gaps, Con::geometry, HORIZ, i3string_as_utf8(), Window::id, Match::insert_where, L_DEFAULT, L_DOCKAREA, L_OUTPUT, L_SPLITH, L_SPLITV, L_STACKED, L_TABBED, Con::layout, marks, Con::name, mark_t::name, Window::name, Con::num, Con::parent, Con::percent, previous_workspace_name, Con::rect, Match::restart_mode, Con::scratchpad_state, Con::sticky, TAILQ_FOREACH, Con::title_format, Window::transient_for, Con::type, Con::urgent, Con::window, Con::window_icon_padding, Con::window_rect, Window::window_type, Con::workspace_layout, Rect::x, Rect::y, y, and ystr.
Referenced by dump_node(), IPC_HANDLER(), ipc_marshal_workspace_event(), ipc_send_window_event(), and store_restart_layout().
void ipc_confirm_restart | ( | ipc_client * | client | ) |
Sends a restart reply to the IPC client on the specified fd.
Definition at line 1735 of file ipc.c.
References DLOG, ipc_client::fd, ipc_push_pending(), and ipc_send_client_message().
Referenced by main().
Generates a json workspace event.
Returns a dynamically allocated yajl generator. Free with yajl_gen_free().
Definition at line 1599 of file ipc.c.
References dump_node(), y, ygenalloc, and ystr.
Referenced by con_on_remove_child(), ipc_send_workspace_event(), and workspace_show().
void ipc_new_client | ( | EV_P_ struct ev_io * | w, |
int | revents ) |
ipc_client * ipc_new_client_on_fd | ( | EV_P_ int | fd | ) |
ipc_new_client_on_fd() only sets up the event handler for activity on the new connection and inserts the file descriptor into the list of clients.
This variant is useful for the inherited IPC connection when restarting.
Definition at line 1575 of file ipc.c.
References DLOG, ipc_client::fd, ipc_receive_message(), ipc_socket_writeable_cb(), ipc_client::read_callback, scalloc(), set_nonblock(), TAILQ_INSERT_TAIL, and ipc_client::write_callback.
Referenced by main().
void ipc_send_barconfig_update_event | ( | Barconfig * | barconfig | ) |
For the barconfig update events, we send the serialized barconfig.
Definition at line 1679 of file ipc.c.
References DLOG, dump_bar_config(), Barconfig::id, ipc_send_event(), y, and ygenalloc.
Referenced by cmd_bar_hidden_state(), cmd_bar_mode(), and cmd_reload().
void ipc_send_binding_event | ( | const char * | event_type, |
Binding * | bind, | ||
const char * | modename ) |
For the binding events, we send the serialized binding struct.
Definition at line 1698 of file ipc.c.
References DLOG, dump_binding(), ipc_send_event(), Binding::keycode, Binding::symbol, y, ygenalloc, and ystr.
Referenced by run_binding().
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 147 of file ipc.c.
References ipc_client::events, ipc_send_client_message(), ipc_client::num_events, and TAILQ_FOREACH.
Referenced by con_on_remove_child(), handle_configure_notify(), 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().
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 1650 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_merge_into(), 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(), tiling_drag(), tree_close_internal(), tree_move(), workspace_defer_update_urgent_hint_cb(), and x_push_changes().
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 1634 of file ipc.c.
References ipc_marshal_workspace_event(), ipc_send_event(), and y.
Referenced by cmd_append_layout(), cmd_reload(), cmd_rename_workspace(), create_workspace_on_output(), workspace_get(), workspace_move_to_output(), workspace_show(), and workspace_update_urgent_flag().
void ipc_set_kill_timeout | ( | ev_tstamp | new | ) |
Set the maximum duration that we allow for a connection with an unwriteable socket.
Referenced by CFGFUN().
void ipc_shutdown | ( | shutdown_reason_t | reason, |
int | exempt_fd ) |
Calls shutdown() on each socket and closes it.
This function is to be called when exiting or restarting only!
exempt_fd is never closed. Set to -1 to close all fds.
Definition at line 192 of file ipc.c.
References ipc_client::fd, free_ipc_client(), ipc_send_shutdown_event(), TAILQ_EMPTY, and TAILQ_FIRST.
Referenced by cmd_restart(), i3_exit(), and i3_restart().
|
extern |
Definition at line 26 of file ipc.c.
Referenced by main(), start_application(), and x_set_i3_atoms().