i3
|
#include "all.h"
#include "yajl_utils.h"
#include <libev/ev.h>
#include <fcntl.h>
#include <libgen.h>
#include <locale.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_parse.h>
Go to the source code of this file.
Data Structures | |
struct | sync_state |
Macros | |
#define | DUMP_PROPERTY(key, prop_name) |
#define | DUMP_REGEX(re_name) |
#define | YSTR_IF_SET(name) |
#define | YSTR_IF_SET(name) |
Functions | |
TAILQ_HEAD (ipc_client_head, ipc_client) | |
static void | ipc_push_pending (ipc_client *client) |
static void | ipc_send_client_message (ipc_client *client, size_t size, const uint32_t message_type, const uint8_t *payload) |
static void | free_ipc_client (ipc_client *client, int exempt_fd) |
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. | |
static void | ipc_send_shutdown_event (shutdown_reason_t reason) |
void | ipc_shutdown (shutdown_reason_t reason, int exempt_fd) |
Calls shutdown() on each socket and closes it. | |
IPC_HANDLER (run_command) | |
static void | dump_rect (yajl_gen gen, const char *name, Rect r) |
static void | dump_gaps (yajl_gen gen, const char *name, gaps_t gaps) |
static void | dump_event_state_mask (yajl_gen gen, Binding *bind) |
static void | dump_binding (yajl_gen gen, Binding *bind) |
void | dump_node (yajl_gen gen, struct Con *con, bool inplace_restart) |
static void | dump_bar_bindings (yajl_gen gen, Barconfig *config) |
static char * | canonicalize_output_name (char *name) |
static void | dump_bar_config (yajl_gen gen, Barconfig *config) |
IPC_HANDLER (tree) | |
IPC_HANDLER (get_workspaces) | |
IPC_HANDLER (get_outputs) | |
IPC_HANDLER (get_marks) | |
IPC_HANDLER (get_version) | |
IPC_HANDLER (get_bar_config) | |
IPC_HANDLER (get_binding_modes) | |
static int | add_subscription (void *extra, const unsigned char *s, ylength len) |
IPC_HANDLER (subscribe) | |
IPC_HANDLER (get_config) | |
IPC_HANDLER (send_tick) | |
static int | _sync_json_key (void *extra, const unsigned char *val, size_t len) |
static int | _sync_json_int (void *extra, long long val) |
IPC_HANDLER (sync) | |
IPC_HANDLER (get_binding_state) | |
static void | ipc_receive_message (EV_P_ struct ev_io *w, int revents) |
static void | ipc_client_timeout (EV_P_ ev_timer *w, int revents) |
static void | ipc_socket_writeable_cb (EV_P_ ev_io *w, int revents) |
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. | |
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_confirm_restart (ipc_client *client) |
Sends a restart reply to the IPC client on the specified fd. | |
Variables | |
char * | current_socketpath = NULL |
handler_t | handlers [13] |
#define DUMP_PROPERTY | ( | key, | |
prop_name ) |
Referenced by dump_node().
#define DUMP_REGEX | ( | re_name | ) |
Referenced by dump_node().
#define YSTR_IF_SET | ( | name | ) |
Referenced by dump_bar_config().
#define YSTR_IF_SET | ( | name | ) |
|
static |
|
static |
|
static |
Definition at line 1209 of file ipc.c.
References DLOG, ipc_client::events, ipc_client::num_events, scalloc(), and srealloc().
Referenced by IPC_HANDLER().
|
static |
Definition at line 750 of file ipc.c.
References get_output_by_name(), and output_primary_name().
Referenced by dump_bar_config().
|
static |
Definition at line 725 of file ipc.c.
References bindings, Barbinding::command, config, Barbinding::input_code, Barbinding::release, TAILQ_EMPTY, TAILQ_FOREACH, y, and ystr.
Referenced by dump_bar_config().
|
static |
Definition at line 759 of file ipc.c.
References canonicalize_output_name(), config, dump_bar_bindings(), dump_rect(), tray_output_t::output, TAILQ_EMPTY, TAILQ_FOREACH, y, ystr, and YSTR_IF_SET.
Referenced by IPC_HANDLER(), and ipc_send_barconfig_update_event().
|
static |
Definition at line 333 of file ipc.c.
References B_KEYBOARD, Binding::command, dump_event_state_mask(), Binding::input_type, Binding::keycode, Binding::symbol, y, and ystr.
Referenced by ipc_send_binding_event().
|
static |
Definition at line 271 of file ipc.c.
References Binding::event_state_mask, I3_XKB_GROUP_MASK_1, I3_XKB_GROUP_MASK_2, I3_XKB_GROUP_MASK_3, I3_XKB_GROUP_MASK_4, y, and ystr.
Referenced by dump_binding().
|
static |
Definition at line 249 of file ipc.c.
References gaps_t::bottom, gaps_t::inner, gaps_t::left, gaps_t::right, gaps_t::top, y, and ystr.
Referenced by dump_node().
void dump_node | ( | yajl_gen | gen, |
struct 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().
|
static |
Definition at line 235 of file ipc.c.
References Rect::height, Rect::width, Rect::x, Rect::y, y, and ystr.
Referenced by dump_bar_config(), and dump_node().
|
static |
Definition at line 117 of file ipc.c.
References ipc_client::buffer, DLOG, ipc_client::events, ipc_client::fd, FREE, main_loop, ipc_client::num_events, ipc_client::read_callback, TAILQ_REMOVE, ipc_client::timeout, and ipc_client::write_callback.
Referenced by ipc_client_timeout(), ipc_receive_message(), and ipc_shutdown().
|
static |
Definition at line 1487 of file ipc.c.
References ELOG, ipc_client::fd, free_ipc_client(), and sasprintf().
Referenced by ipc_push_pending().
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().
IPC_HANDLER | ( | get_bar_config | ) |
Definition at line 1125 of file ipc.c.
References barconfigs, config, dump_bar_config(), Barconfig::id, ipc_send_client_message(), LOG, sasprintf(), TAILQ_FOREACH, y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_binding_modes | ) |
Definition at line 1187 of file ipc.c.
References ipc_send_client_message(), modes, Mode::name, SLIST_FOREACH, y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_binding_state | ) |
Definition at line 1408 of file ipc.c.
References current_binding_mode, ipc_send_client_message(), y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_config | ) |
Definition at line 1287 of file ipc.c.
References included_files, ipc_send_client_message(), IncludedFile::path, IncludedFile::raw_contents, TAILQ_FIRST, TAILQ_FOREACH, IncludedFile::variable_replaced_contents, y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_marks | ) |
Definition at line 1054 of file ipc.c.
References all_cons, ipc_send_client_message(), marks, mark_t::name, TAILQ_FOREACH, y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_outputs | ) |
Definition at line 999 of file ipc.c.
References CF_OUTPUT, con_get_fullscreen_con(), ipc_send_client_message(), Con::name, tray_output_t::output, output_primary_name(), outputs, TAILQ_FOREACH, y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_version | ) |
Definition at line 1080 of file ipc.c.
References current_configpath, i3_version, included_files, ipc_send_client_message(), IncludedFile::path, TAILQ_FIRST, TAILQ_FOREACH, y, ygenalloc, and ystr.
IPC_HANDLER | ( | get_workspaces | ) |
Definition at line 931 of file ipc.c.
References con_get_workspace(), con_is_internal(), croot, focused, ipc_send_client_message(), tray_output_t::output, output_get_content(), TAILQ_FOREACH, Con::type, workspace_is_visible(), y, ygenalloc, and ystr.
IPC_HANDLER | ( | run_command | ) |
Definition at line 209 of file ipc.c.
References command_result_free(), ipc_send_client_message(), LOG, CommandResult::needs_tree_render, parse_command(), sstrndup(), and tree_render().
IPC_HANDLER | ( | send_tick | ) |
Definition at line 1324 of file ipc.c.
References DLOG, ipc_send_client_message(), ipc_send_event(), y, ygenalloc, and ystr.
IPC_HANDLER | ( | subscribe | ) |
Definition at line 1237 of file ipc.c.
References add_subscription(), ELOG, ipc_send_client_message(), and yalloc.
IPC_HANDLER | ( | sync | ) |
Definition at line 1373 of file ipc.c.
References _sync_json_int(), _sync_json_key(), DLOG, ELOG, FREE, ipc_send_client_message(), state, sync_respond(), and yalloc.
IPC_HANDLER | ( | tree | ) |
Definition at line 912 of file ipc.c.
References croot, dump_node(), ipc_send_client_message(), y, and ygenalloc.
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().
|
static |
Definition at line 45 of file ipc.c.
References ipc_client::buffer, ipc_client::buffer_size, ipc_client::fd, FREE, ipc_client_timeout(), main_loop, scalloc(), srealloc(), ipc_client::timeout, ipc_client::write_callback, and writeall_nonblock().
Referenced by ipc_confirm_restart(), ipc_send_client_message(), and ipc_socket_writeable_cb().
|
static |
Definition at line 1454 of file ipc.c.
References DLOG, ipc_client::fd, FREE, free_ipc_client(), handlers, and ipc_recv_message().
Referenced by ipc_new_client_on_fd().
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().
|
static |
Definition at line 98 of file ipc.c.
References ipc_client::buffer, ipc_client::buffer_size, header, ipc_push_pending(), and srealloc().
Referenced by ipc_confirm_restart(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), IPC_HANDLER(), and 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 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().
|
static |
Definition at line 162 of file ipc.c.
References ipc_send_event(), SHUTDOWN_REASON_EXIT, SHUTDOWN_REASON_RESTART, y, ygenalloc, and ystr.
Referenced by ipc_shutdown().
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_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().
|
static |
Definition at line 1533 of file ipc.c.
References DLOG, ipc_push_pending(), and ipc_client::timeout.
Referenced by ipc_new_client_on_fd().
TAILQ_HEAD | ( | ipc_client_head | , |
ipc_client | ) |
char* current_socketpath = NULL |
Definition at line 26 of file ipc.c.
Referenced by main(), start_application(), and x_set_i3_atoms().
handler_t handlers[13] |
Definition at line 1428 of file ipc.c.
Referenced by ipc_receive_message().