|
i3
|
#include "all.h"#include <sys/wait.h>#include <stdarg.h>#include <fcntl.h>#include <pwd.h>#include <yajl/yajl_version.h>#include <libgen.h>#include <ctype.h>#include <libsn/sn-launcher.h>
Go to the source code of this file.
Macros | |
| #define | I3__FILE__ "util.c" |
| #define | SN_API_NOT_YET_FROZEN 1 |
| #define | y(x,...) yajl_gen_##x(gen, ##__VA_ARGS__) |
| #define | ystr(str) yajl_gen_string(gen, (unsigned char *)str, strlen(str)) |
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) |
| Rect | rect_sub (Rect a, Rect b) |
| __attribute__ ((pure)) | |
| long | ws_name_to_number (const char *name) |
| Parses the workspace name as a number. More... | |
| 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. More... | |
| void | exec_i3_utility (char *name, char *argv[]) |
| exec()s an i3 utility, for example the config file migration script or i3-nagbar. More... | |
| 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. More... | |
| bool | path_exists (const char *path) |
| Checks if the given path exists by calling stat(). More... | |
| static char ** | add_argument (char **original, char *opt_char, char *opt_arg, char *opt_name) |
| char * | store_restart_layout (void) |
| void | i3_restart (bool forget_layout) |
| Restart i3 in-place appends -a to argument list to disable autostart. More... | |
| char * | pango_escape_markup (char *input) |
| Escapes the given string if a pango font is currently used. More... | |
| static void | nagbar_exited (EV_P_ ev_child *watcher, int revents) |
| static void | nagbar_cleanup (EV_P_ ev_cleanup *watcher, int revent) |
| void | start_nagbar (pid_t *nagbar_pid, char *argv[]) |
| Starts an i3-nagbar instance with the given parameters. More... | |
| void | kill_nagbar (pid_t *nagbar_pid, bool wait_for_it) |
| Kills the i3-nagbar process, if *nagbar_pid != -1. More... | |
| #define ystr | ( | str | ) | yajl_gen_string(gen, (unsigned char *)str, strlen(str)) |
|
static |
Definition at line 175 of file util.c.
References scalloc().
Referenced by i3_restart().

| 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 116 of file util.c.
References sasprintf(), sstrdup(), and start_argv.
Referenced by migrate_config(), and start_nagbar().

| void i3_restart | ( | bool | forget_layout | ) |
Restart i3 in-place appends -a to argument list to disable autostart.
Definition at line 270 of file util.c.
References add_argument(), command_error_nagbar_pid, config_error_nagbar_pid, get_debug_logging(), ipc_shutdown(), kill_nagbar(), LOG, restore_geometry(), start_argv, and store_restart_layout().
Referenced by cmd_restart(), and sig_handle_key_press().

| void kill_nagbar | ( | pid_t * | nagbar_pid, |
| bool | wait_for_it | ||
| ) |
Kills the i3-nagbar process, if *nagbar_pid != -1.
If wait_for_it is set (restarting i3), this function will waitpid(), otherwise, ev is assumed to handle it (reloading).
Definition at line 433 of file util.c.
Referenced by cmd_reload(), and i3_restart().
| int max | ( | int | a, |
| int | b | ||
| ) |
Definition at line 33 of file util.c.
Referenced by con_minimum_size(), DRAGGING_CB(), floating_check_size(), floating_enable(), and json_end_map().
| int min | ( | int | a, |
| int | b | ||
| ) |
Definition at line 29 of file util.c.
Referenced by con_minimum_size(), fake_outputs_init(), floating_check_size(), open_logbuffer(), query_screens(), and randr_query_outputs().
|
static |
|
static |
| char* pango_escape_markup | ( | char * | input | ) |
Escapes the given string if a pango font is currently used.
If the string has to be escaped, the input string will be free'd.
Definition at line 340 of file util.c.
References font_is_pango(), and FREE.
Referenced by con_parse_title_format().

| bool path_exists | ( | const char * | path | ) |
Checks if the given path exists by calling stat().
Definition at line 166 of file util.c.
Referenced by ipc_create_socket(), and tree_restore().
Definition at line 44 of file util.c.
References Rect::height, Rect::width, Rect::x, and Rect::y.
Referenced by con_set_border_style(), and render_con().
| bool rect_contains | ( | Rect | rect, |
| uint32_t | x, | ||
| uint32_t | y | ||
| ) |
Definition at line 37 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().
Definition at line 51 of file util.c.
References Rect::height, Rect::width, Rect::x, and Rect::y.
Referenced by con_set_border_style().
| void start_nagbar | ( | pid_t * | nagbar_pid, |
| char * | argv[] | ||
| ) |
Starts an i3-nagbar instance with the given parameters.
Takes care of handling SIGCHLD and killing i3-nagbar when i3 exits.
The resulting PID will be stored in *nagbar_pid and can be used with kill_nagbar() to kill the bar later on.
Definition at line 393 of file util.c.
References DLOG, exec_i3_utility(), main_loop, nagbar_cleanup(), nagbar_exited(), and smalloc().
Referenced by run_binding(), and start_config_error_nagbar().

| char* store_restart_layout | ( | void | ) |
Definition at line 208 of file util.c.
References config, croot, DEFAULT_DIR_MODE, DLOG, dump_node(), ELOG, get_process_filename(), mkdirp(), resolve_tilde(), Config::restart_state_path, sstrdup(), writeall(), and y.
Referenced by i3_restart().

| 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 95 of file util.c.
Referenced by handle_output(), and randr_query_outputs().
| long ws_name_to_number | ( | const char * | name | ) |
Parses the workspace name as a number.
Returns -1 if the workspace should be interpreted as a "named workspace".
Definition at line 76 of file util.c.
Referenced by cmd_move_con_to_workspace_number(), cmd_rename_workspace(), cmd_workspace_number(), create_workspace_on_output(), json_end_map(), and workspace_get().
1.8.5