i3
|
Go to the source code of this file.
Macros | |
#define | die(...) errx(EXIT_FAILURE, __VA_ARGS__); |
#define | exit_if_null(pointer,...) { if (pointer == NULL) die(__VA_ARGS__); } |
#define | STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0) |
#define | CIRCLEQ_NEXT_OR_NULL(head, elm, field) |
#define | CIRCLEQ_PREV_OR_NULL(head, elm, field) |
#define | FOR_TABLE(workspace) |
#define | NODES_FOREACH(head) |
#define | NODES_FOREACH_REVERSE(head) |
#define | GREP_FIRST(dest, head, condition) |
#define | FREE(pointer) |
#define | CALL(obj, member,...) obj->member(obj, ## __VA_ARGS__) |
Functions | |
int | min (int a, int b) |
int | max (int a, int b) |
bool | rect_contains (Rect rect, uint32_t x, uint32_t y) |
Rect | rect_add (Rect a, Rect b) |
bool | update_if_necessary (uint32_t *destination, const uint32_t new_value) |
Updates *destination with new_value and returns true if it was changed or false if it was the same. | |
void | exec_i3_utility (char *name, char *argv[]) |
exec()s an i3 utility, for example the config file migration script or i3-nagbar. | |
void | check_error (xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_message) |
Checks a generic cookie for errors and quits with the given message if there was an error. | |
char * | resolve_tilde (const char *path) |
This function resolves ~ in pathnames. | |
bool | path_exists (const char *path) |
Checks if the given path exists by calling stat(). | |
char * | get_process_filename (const char *prefix) |
Returns the name of a temporary file with the specified prefix. | |
void | i3_restart (bool forget_layout) |
Restart i3 in-place appends -a to argument list to disable autostart. |
#define CALL | ( | obj, | |
member, | |||
... | |||
) | obj->member(obj, ## __VA_ARGS__) |
Definition at line 55 of file util.h.
Referenced by attach_to_workspace(), con_move_to_workspace(), insert_con_into(), and tree_close().
#define CIRCLEQ_NEXT_OR_NULL | ( | head, | |
elm, | |||
field | |||
) |
#define CIRCLEQ_PREV_OR_NULL | ( | head, | |
elm, | |||
field | |||
) |
#define die | ( | ... | ) | errx(EXIT_FAILURE, __VA_ARGS__); |
Definition at line 18 of file util.h.
Referenced by get_config_path(), main(), parse_file(), randr_query_outputs(), and resolve_tilde().
#define exit_if_null | ( | pointer, | |
... | |||
) | { if (pointer == NULL) die(__VA_ARGS__); } |
#define FOR_TABLE | ( | workspace | ) |
#define FREE | ( | pointer | ) |
Definition at line 47 of file util.h.
Referenced by _create___i3(), _workspace_show(), backtrace(), cmd_mark(), cmd_rename_workspace(), create_workspace_on_output(), drag_pointer(), handle_normal_hints(), handle_output(), ipc_create_socket(), json_key(), load_configuration(), main(), manage_window(), match_free(), migrate_config(), mkdirp(), output_init_con(), parse_configuration(), parse_file(), property_notify(), randr_query_outputs(), regex_free(), startup_workspace_for_window(), translate_keysyms(), tree_close(), tree_init(), tree_move(), tree_split(), window_update_class(), window_update_hints(), window_update_leader(), window_update_name(), window_update_name_legacy(), window_update_role(), window_update_strut_partial(), window_update_transient_for(), workspace_get(), x_con_kill(), x_draw_decoration(), x_push_node(), x_set_name(), xinerama_init(), and yyparse().
#define GREP_FIRST | ( | dest, | |
head, | |||
condition | |||
) |
Definition at line 38 of file util.h.
Referenced by _tree_next(), cmd_focus_output(), cmd_move_con_to_output(), cmd_move_con_to_workspace_number(), cmd_move_workspace_to_output(), cmd_rename_workspace(), cmd_workspace_number(), create_workspace_on_output(), init_ws_for_output(), and workspace_get().
#define NODES_FOREACH | ( | head | ) |
Definition at line 29 of file util.h.
Referenced by workspace_next(), and workspace_next_on_output().
#define NODES_FOREACH_REVERSE | ( | head | ) |
Definition at line 33 of file util.h.
Referenced by workspace_prev(), and workspace_prev_on_output().
#define STARTS_WITH | ( | string, | |
needle | |||
) | (strncasecmp(string, needle, strlen(needle)) == 0) |
void check_error | ( | xcb_connection_t * | conn, |
xcb_void_cookie_t | cookie, | ||
char * | err_message | ||
) |
void exec_i3_utility | ( | char * | name, |
char * | argv[] | ||
) |
exec()s an i3 utility, for example the config file migration script or i3-nagbar.
This function first searches $PATH for the given utility named, then falls back to the dirname() of the i3 executable path and then falls back to the dirname() of the target of /proc/self/exe (on linux).
This function should be called after fork()ing.
The first argument of the given argv vector will be overwritten with the executable name, so pass NULL.
If the utility cannot be found in any of these locations, it exits with return code 2.
Definition at line 76 of file util.c.
References sasprintf(), and start_argv.
Referenced by migrate_config(), start_commanderror_nagbar(), and start_configerror_nagbar().
char* get_process_filename | ( | const char * | prefix | ) |
Returns the name of a temporary file with the specified prefix.
Definition at line 190 of file util.c.
References path_exists(), and sasprintf().
Referenced by init_logging(), main(), start_commanderror_nagbar(), start_configerror_nagbar(), and store_restart_layout().
void i3_restart | ( | bool | forget_layout | ) |
Restart i3 in-place appends -a to argument list to disable autostart.
Definition at line 304 of file util.c.
References append_argument(), ipc_shutdown(), kill_commanderror_nagbar(), kill_configerror_nagbar(), LOG, restore_geometry(), scalloc(), start_argv, and store_restart_layout().
Referenced by cmd_restart(), and sig_handle_key_press().
int max | ( | int | a, |
int | b | ||
) |
Definition at line 32 of file util.c.
Referenced by con_minimum_size(), DRAGGING_CB(), and floating_enable().
int min | ( | int | a, |
int | b | ||
) |
Definition at line 28 of file util.c.
Referenced by con_minimum_size(), fake_outputs_init(), floating_enable(), init_logging(), query_screens(), and randr_query_outputs().
bool path_exists | ( | const char * | path | ) |
Checks if the given path exists by calling stat().
Definition at line 158 of file util.c.
Referenced by get_config_path(), get_process_filename(), ipc_create_socket(), and tree_restore().
Definition at line 43 of file util.c.
References Rect::height, Rect::width, Rect::x, and Rect::y.
Referenced by render_con().
bool rect_contains | ( | Rect | rect, |
uint32_t | x, | ||
uint32_t | y | ||
) |
Definition at line 36 of file util.c.
References Rect::height, Rect::width, Rect::x, and Rect::y.
Referenced by handle_button_press(), handle_enter_notify(), and handle_motion_notify().
char* resolve_tilde | ( | const char * | path | ) |
This function resolves ~ in pathnames.
It may resolve wildcards in the first part of the path, but if no match or multiple matches are found, it just returns a copy of path as given.
Definition at line 128 of file util.c.
References die, scalloc(), and sstrdup().
Referenced by get_config_path(), ipc_create_socket(), store_restart_layout(), and tree_restore().
bool update_if_necessary | ( | uint32_t * | destination, |
const uint32_t | new_value | ||
) |
Updates *destination with new_value and returns true if it was changed or false if it was the same.
Definition at line 55 of file util.c.
Referenced by handle_output(), and randr_query_outputs().