|
i3
|
#include "all.h"#include "yajl_utils.h"#include <sys/socket.h>#include <sys/un.h>#include <fcntl.h>#include <libgen.h>#include <ev.h>#include <yajl/yajl_gen.h>#include <yajl/yajl_parse.h>
Go to the source code of this file.
Macros | |
| #define | I3__FILE__ "ipc.c" |
| #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) | |
| 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 (void) |
| Calls shutdown() on each socket and closes it. More... | |
| IPC_HANDLER (command) | |
| static void | dump_rect (yajl_gen gen, const char *name, Rect r) |
| 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 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) | |
| static int | add_subscription (void *extra, const unsigned char *s, ylength len) |
| IPC_HANDLER (subscribe) | |
| static void | ipc_receive_message (EV_P_ struct 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. 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... | |
| 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... | |
Variables | |
| char * | current_socketpath = NULL |
| handler_t | handlers [8] |
| #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 |
Definition at line 964 of file ipc.c.
References DLOG, ipc_client::events, ipc_client::num_events, scalloc(), and srealloc().
Referenced by IPC_HANDLER().

|
static |
Definition at line 526 of file ipc.c.
References bindings, Barbinding::command, Barbinding::input_code, TAILQ_EMPTY, TAILQ_FOREACH, y, and ystr.
Referenced by dump_bar_config().
|
static |
Definition at line 548 of file ipc.c.
References dump_bar_bindings(), Barconfig::hidden_state, Barconfig::hide_binding_mode_indicator, Barconfig::hide_workspace_buttons, Barconfig::id, Barconfig::mode, Barconfig::modifier, Barconfig::num_outputs, tray_output_t::output, Barconfig::outputs, Barconfig::position, Barconfig::separator_symbol, Barconfig::strip_workspace_numbers, TAILQ_EMPTY, TAILQ_FOREACH, Barconfig::tray_padding, Barconfig::verbose, y, ystr, and YSTR_IF_SET.
Referenced by IPC_HANDLER(), and ipc_send_barconfig_update_event().

|
static |
Definition at line 189 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 127 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().
| void dump_node | ( | yajl_gen | gen, |
| struct Con * | con, | ||
| bool | inplace_restart | ||
| ) |
Definition at line 217 of file ipc.c.
References BS_NONE, BS_NORMAL, BS_PIXEL, con_is_split(), con_orientation(), DLOG, Match::dock, dump_node(), DUMP_PROPERTY, dump_rect(), DUMP_REGEX, focused, HORIZ, i3string_as_utf8(), Match::insert_where, L_DEFAULT, L_DOCKAREA, L_OUTPUT, L_SPLITH, L_SPLITV, L_STACKED, L_TABBED, mark_t::name, Match::restart_mode, TAILQ_EMPTY, TAILQ_FOREACH, 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 113 of file ipc.c.
References Rect::height, Rect::width, Rect::x, y, Rect::y, and ystr.
Referenced by dump_node().
| 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 1150 of file ipc.c.
References current_socketpath, DEFAULT_DIR_MODE, DLOG, FREE, mkdirp(), path_exists(), resolve_tilde(), and sstrdup().
Referenced by main().

| IPC_HANDLER | ( | command | ) |
Definition at line 87 of file ipc.c.
References command_result_free(), ipc_send_message(), LOG, CommandResult::needs_tree_render, parse_command(), scalloc(), and tree_render().

| IPC_HANDLER | ( | tree | ) |
Definition at line 706 of file ipc.c.
References croot, dump_node(), ipc_send_message(), y, and ygenalloc.

| IPC_HANDLER | ( | get_workspaces | ) |
Definition at line 725 of file ipc.c.
References con_get_workspace(), con_is_internal(), croot, focused, Rect::height, ipc_send_message(), Con::name, Con::num, tray_output_t::output, output_get_content(), Con::rect, TAILQ_FOREACH, Con::type, Con::urgent, Rect::width, workspace_is_visible(), Rect::x, y, Rect::y, ygenalloc, and ystr.

| IPC_HANDLER | ( | get_outputs | ) |
Definition at line 789 of file ipc.c.
References xoutput::active, CF_OUTPUT, xoutput::con, con_get_fullscreen_con(), Rect::height, ipc_send_message(), xoutput::name, Con::name, tray_output_t::output, outputs, xoutput::primary, xoutput::rect, TAILQ_FOREACH, Rect::width, Rect::x, y, Rect::y, ygenalloc, and ystr.

| IPC_HANDLER | ( | get_marks | ) |
Definition at line 843 of file ipc.c.
References all_cons, ipc_send_message(), mark_t::name, TAILQ_FOREACH, y, ygenalloc, and ystr.

| IPC_HANDLER | ( | get_version | ) |
Definition at line 869 of file ipc.c.
References current_configpath, i3_version, ipc_send_message(), y, ygenalloc, and ystr.

| IPC_HANDLER | ( | get_bar_config | ) |
Definition at line 903 of file ipc.c.
References barconfigs, config, dump_bar_config(), Barconfig::id, ipc_send_message(), LOG, sasprintf(), TAILQ_FOREACH, y, ygenalloc, and ystr.

| IPC_HANDLER | ( | subscribe | ) |
Definition at line 991 of file ipc.c.
References add_subscription(), ELOG, ipc_client::fd, ipc_send_message(), TAILQ_FOREACH, and yalloc.

Generates a json workspace event.
Returns a dynamically allocated yajl generator. Free with yajl_gen_free().
Definition at line 1200 of file ipc.c.
References dump_node(), y, ygenalloc, and ystr.
Referenced by _workspace_show(), con_on_remove_child(), and ipc_send_workspace_event().

| 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 1116 of file ipc.c.
References DLOG, ipc_receive_message(), scalloc(), and TAILQ_INSERT_TAIL.
Referenced by main().

|
static |
Definition at line 1057 of file ipc.c.
References DLOG, ipc_client::events, ipc_client::fd, FREE, handlers, ipc_recv_message(), ipc_client::num_events, TAILQ_FOREACH, and TAILQ_REMOVE.
Referenced by ipc_new_client().

| void ipc_send_barconfig_update_event | ( | Barconfig * | barconfig | ) |
For the barconfig update events, we send the serialized barconfig.
Definition at line 1278 of file ipc.c.
References DLOG, dump_bar_config(), Barconfig::id, ipc_send_event(), y, and ygenalloc.
Referenced by update_barconfig().

| void ipc_send_binding_event | ( | const char * | event_type, |
| Binding * | bind | ||
| ) |
For the binding events, we send the serialized binding struct.
Definition at line 1297 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 45 of file ipc.c.
References ipc_client::events, ipc_client::fd, ipc_send_message(), ipc_client::num_events, and TAILQ_FOREACH.
Referenced by _workspace_show(), con_on_remove_child(), handle_screen_change(), ipc_send_barconfig_update_event(), ipc_send_binding_event(), ipc_send_window_event(), ipc_send_workspace_event(), and switch_mode().

| 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 1249 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_set_fullscreen_mode(), con_set_urgency(), floating_disable(), floating_enable(), handle_windowname_change(), handle_windowname_change_legacy(), manage_window(), 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 1233 of file ipc.c.
References ipc_marshal_workspace_event(), ipc_send_event(), and y.
Referenced by _workspace_show(), cmd_append_layout(), cmd_reload(), cmd_rename_workspace(), move_to_output_directed(), workspace_get(), workspace_move_to_output(), and workspace_update_urgent_flag().

| void ipc_shutdown | ( | void | ) |
Calls shutdown() on each socket and closes it.
This function to be called when exiting or restarting only!
Definition at line 68 of file ipc.c.
References ipc_client::events, ipc_client::fd, ipc_client::num_events, TAILQ_EMPTY, TAILQ_FIRST, and TAILQ_REMOVE.
Referenced by cmd_exit(), cmd_restart(), and i3_restart().
| TAILQ_HEAD | ( | ipc_client_head | , |
| ipc_client | |||
| ) |
| char* current_socketpath = NULL |
Definition at line 23 of file ipc.c.
Referenced by ipc_create_socket(), and x_set_i3_atoms().
| handler_t handlers[8] |
Definition at line 1036 of file ipc.c.
Referenced by ipc_receive_message().
1.8.5