i3
|
#include <config.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/stat.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
#include <xcb/xcb_keysyms.h>
#include <pango/pango.h>
#include <cairo/cairo-xcb.h>
Go to the source code of this file.
Data Structures | |
struct | Font |
Data structure for cached font information: More... | |
struct | color_t |
struct | placeholder_t |
Helper structure for usage in format_placeholders(). More... | |
struct | surface_t |
Macros | |
#define | DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) |
#define | XCB_BUTTON_CLICK_LEFT XCB_BUTTON_INDEX_1 |
Mouse buttons. | |
#define | XCB_BUTTON_CLICK_MIDDLE XCB_BUTTON_INDEX_2 |
#define | XCB_BUTTON_CLICK_RIGHT XCB_BUTTON_INDEX_3 |
#define | XCB_BUTTON_SCROLL_UP XCB_BUTTON_INDEX_4 |
#define | XCB_BUTTON_SCROLL_DOWN XCB_BUTTON_INDEX_5 |
#define | XCB_BUTTON_SCROLL_LEFT 6 |
#define | XCB_BUTTON_SCROLL_RIGHT 7 |
#define | LOG(fmt, ...) |
#define | ELOG(fmt, ...) |
#define | DLOG(fmt, ...) |
#define | I3STRING_FREE(str) |
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory. | |
#define | HAS_G_UTF8_MAKE_VALID GLIB_CHECK_VERSION(2, 52, 0) |
#define | COLOR_TRANSPARENT ((color_t){.red = 0.0, .green = 0.0, .blue = 0.0, .colorpixel = 0}) |
#define | CAIRO_SURFACE_FLUSH(surface) |
Typedefs | |
typedef struct _i3String | i3String |
Opaque data structure for storing strings. | |
typedef struct Font | i3Font |
typedef struct color_t | color_t |
typedef struct placeholder_t | placeholder_t |
Helper structure for usage in format_placeholders(). | |
typedef struct surface_t | surface_t |
Functions | |
void | verboselog (char *fmt,...) __attribute__((format(printf |
void | errorlog (char *fmt,...) __attribute__((format(printf |
void | debuglog (char *fmt,...) __attribute__((format(printf |
char * | root_atom_contents (const char *atomname, xcb_connection_t *provided_conn, int screen) |
Try to get the contents of the given atom (for example I3_SOCKET_PATH) from the X11 root window and return NULL if it doesn’t work. | |
void * | smalloc (size_t size) |
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory available) | |
void * | scalloc (size_t num, size_t size) |
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory available) | |
void * | srealloc (void *ptr, size_t size) |
Safe-wrapper around realloc which exits if realloc returns NULL (meaning that there is no more memory available). | |
char * | sstrdup (const char *str) |
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory available) | |
char * | sstrndup (const char *str, size_t size) |
Safe-wrapper around strndup which exits if strndup returns NULL (meaning that there is no more memory available) | |
int | sasprintf (char **strp, const char *fmt,...) |
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory available) | |
ssize_t | writeall (int fd, const void *buf, size_t count) |
Wrapper around correct write which returns -1 (meaning that write failed) or count (meaning that all bytes were written) | |
ssize_t | writeall_nonblock (int fd, const void *buf, size_t count) |
Like writeall, but instead of retrying upon EAGAIN (returned when a write would block), the function stops and returns the total number of bytes written so far. | |
ssize_t | swrite (int fd, const void *buf, size_t count) |
Safe-wrapper around writeall which exits if it returns -1 (meaning that write failed) | |
int | strcasecmp_nullable (const char *a, const char *b) |
Like strcasecmp but considers the case where either string is NULL. | |
i3String * | i3string_from_utf8 (const char *from_utf8) |
Build an i3String from an UTF-8 encoded string. | |
i3String * | i3string_from_markup (const char *from_markup) |
Build an i3String from an UTF-8 encoded string in Pango markup. | |
i3String * | i3string_from_utf8_with_length (const char *from_utf8, ssize_t num_bytes) |
Build an i3String from an UTF-8 encoded string with fixed length. | |
i3String * | i3string_from_markup_with_length (const char *from_markup, size_t num_bytes) |
Build an i3String from an UTF-8 encoded string in Pango markup with fixed length. | |
i3String * | i3string_from_ucs2 (const xcb_char2b_t *from_ucs2, size_t num_glyphs) |
Build an i3String from an UCS-2 encoded string. | |
i3String * | i3string_copy (i3String *str) |
Copies the given i3string. | |
void | i3string_free (i3String *str) |
Free an i3String. | |
const char * | i3string_as_utf8 (i3String *str) |
Returns the UTF-8 encoded version of the i3String. | |
const xcb_char2b_t * | i3string_as_ucs2 (i3String *str) |
Returns the UCS-2 encoded version of the i3String. | |
size_t | i3string_get_num_bytes (i3String *str) |
Returns the number of bytes (UTF-8 encoded) in an i3String. | |
bool | i3string_is_markup (i3String *str) |
Whether the given i3String is in Pango markup. | |
void | i3string_set_markup (i3String *str, bool pango_markup) |
Set whether the i3String should use Pango markup. | |
i3String * | i3string_escape_markup (i3String *str) |
Escape pango markup characters in the given string. | |
size_t | i3string_get_num_glyphs (i3String *str) |
Returns the number of glyphs in an i3String. | |
int | ipc_connect (const char *socket_path) |
Connects to the i3 IPC socket and returns the file descriptor for the socket. | |
int | ipc_connect_impl (const char *socket_path) |
Connects to the socket at the given path with no fallback paths. | |
int | ipc_send_message (int sockfd, const uint32_t message_size, const uint32_t message_type, const uint8_t *payload) |
Formats a message (payload) of the given size and type and sends it to i3 via the given socket file descriptor. | |
int | ipc_recv_message (int sockfd, uint32_t *message_type, uint32_t *reply_length, uint8_t **reply) |
Reads a message from the given socket file descriptor and stores its length (reply_length) as well as a pointer to its contents (reply). | |
void | fake_configure_notify (xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width) |
Generates a configure_notify event and sends it to the given window Applications need this to think they’ve configured themselves correctly. | |
gchar * | g_utf8_make_valid (const gchar *str, gssize len) |
uint32_t | get_colorpixel (const char *hex) __attribute__((const)) |
Returns the colorpixel to use for the given hex color (think of HTML). | |
char * | strndup (const char *str, size_t n) |
Taken from FreeBSD Returns a pointer to a new string which is a duplicate of the string, but only copies at most n characters. | |
uint32_t | aio_get_mod_mask_for (uint32_t keysym, xcb_key_symbols_t *symbols) |
All-in-one function which returns the modifier mask (XCB_MOD_MASK_*) for the given keysymbol, for example for XCB_NUM_LOCK (usually configured to mod2). | |
uint32_t | get_mod_mask_for (uint32_t keysym, xcb_key_symbols_t *symbols, xcb_get_modifier_mapping_reply_t *modmap_reply) |
Returns the modifier mask (XCB_MOD_MASK_*) for the given keysymbol, for example for XCB_NUM_LOCK (usually configured to mod2). | |
i3Font | load_font (const char *pattern, const bool fallback) |
Loads a font for usage, also getting its height. | |
void | set_font (i3Font *font) |
Defines the font to be used for the forthcoming calls. | |
void | free_font (void) |
Frees the resources taken by the current font. | |
char * | convert_ucs2_to_utf8 (xcb_char2b_t *text, size_t num_glyphs) |
Converts the given string to UTF-8 from UCS-2 big endian. | |
xcb_char2b_t * | convert_utf8_to_ucs2 (char *input, size_t *real_strlen) |
Converts the given string to UCS-2 big endian for use with xcb_image_text_16(). | |
void | set_font_colors (xcb_gcontext_t gc, color_t foreground, color_t background) |
Defines the colors to be used for the forthcoming draw_text calls. | |
bool | font_is_pango (void) |
Returns true if and only if the current font is a pango font. | |
void | draw_text (i3String *text, xcb_drawable_t drawable, xcb_gcontext_t gc, cairo_surface_t *surface, int x, int y, int max_width) |
Draws text onto the specified X drawable (normally a pixmap) at the specified coordinates (from the top left corner of the leftmost, uppermost glyph) and using the provided gc. | |
int | predict_text_width (i3String *text) |
Predict the text width in pixels for the given text. | |
xcb_visualtype_t * | get_visualtype (xcb_screen_t *screen) |
Returns the visual type associated with the given screen. | |
bool | is_debug_build (void) __attribute__((const)) |
Returns true if this version of i3 is a debug build (anything which is not a release version), based on the git version number. | |
char * | get_process_filename (const char *prefix) |
Returns the name of a temporary file with the specified prefix. | |
char * | get_exe_path (const char *argv0) |
This function returns the absolute path to the executable it is running in. | |
void | init_dpi (void) |
Initialize the DPI setting. | |
long | get_dpi_value (void) |
This function returns the value of the DPI setting. | |
int | logical_px (const int logical) |
Convert a logical amount of pixels (e.g. | |
char * | resolve_tilde (const char *path) |
This function resolves ~ in pathnames. | |
char * | get_config_path (const char *override_configpath, bool use_system_paths) |
Get the path of the first configuration file found. | |
int | mkdirp (const char *path, mode_t mode) |
Emulates mkdir -p (creates any missing folders) | |
char * | format_placeholders (char *format, placeholder_t *placeholders, int num) |
Replaces occurrences of the defined placeholders in the format string. | |
void | draw_util_surface_init (xcb_connection_t *conn, surface_t *surface, xcb_drawable_t drawable, xcb_visualtype_t *visual, int width, int height) |
Initialize the surface to represent the given drawable. | |
void | draw_util_surface_set_size (surface_t *surface, int width, int height) |
Resize the surface to the given size. | |
void | draw_util_surface_free (xcb_connection_t *conn, surface_t *surface) |
Destroys the surface. | |
color_t | draw_util_hex_to_color (const char *color) |
Parses the given color in hex format to an internal color representation. | |
void | draw_util_text (i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width) |
Draw the given text using libi3. | |
void | draw_util_image (cairo_surface_t *image, surface_t *surface, int x, int y, int width, int height) |
Draw the given image using libi3. | |
void | draw_util_rectangle (surface_t *surface, color_t color, double x, double y, double w, double h) |
Draws a filled rectangle. | |
void | draw_util_clear_surface (surface_t *surface, color_t color) |
Clears a surface with the given color. | |
void | draw_util_copy_surface (surface_t *src, surface_t *dest, double src_x, double src_y, double dest_x, double dest_y, double width, double height) |
Copies a surface onto another surface. | |
void | set_nonblock (int sockfd) |
Puts the given socket file descriptor into non-blocking mode or dies if setting O_NONBLOCK failed. | |
int | create_socket (const char *filename, char **out_socketpath) |
Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s and listen()s on it. | |
bool | path_exists (const char *path) |
Checks if the given path exists by calling stat(). | |
void | set_screenshot_as_wallpaper (xcb_connection_t *conn, xcb_screen_t *screen) |
Grab a screenshot of the screen's root window and set it as the wallpaper. | |
bool | is_background_set (xcb_connection_t *conn, xcb_screen_t *screen) |
Test whether the screen's root window has a background set. | |
bool | boolstr (const char *str) |
Reports whether str represents the enabled state (1, yes, true, …). | |
uint16_t | get_visual_depth (xcb_visualid_t visual_id) |
Get depth of visual specified by visualid. | |
Variables | |
xcb_connection_t * | conn |
XCB connection and root screen. | |
xcb_screen_t * | root_screen |
#define CAIRO_SURFACE_FLUSH | ( | surface | ) |
#define COLOR_TRANSPARENT ((color_t){.red = 0.0, .green = 0.0, .blue = 0.0, .colorpixel = 0}) |
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) |
Definition at line 26 of file libi3.h.
Referenced by store_restart_layout().
#define DLOG | ( | fmt, | |
... ) |
Definition at line 105 of file libi3.h.
Referenced by _con_attach(), _con_move_to_con(), _create___i3(), _workspace_apply_default_orientation(), add_keycode_if_matches(), add_subscription(), assignment_for(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), cmd_append_layout(), cmd_bar_hidden_state(), cmd_bar_mode(), cmd_border(), cmd_criteria_match_windows(), cmd_exec(), cmd_floating(), cmd_focus(), cmd_focus_level(), cmd_focus_window_mode(), cmd_fullscreen(), cmd_kill(), cmd_layout(), cmd_layout_toggle(), cmd_mark(), cmd_mode(), cmd_move_con_to_mark(), cmd_move_con_to_workspace(), cmd_move_direction(), cmd_move_scratchpad(), cmd_move_window_to_center(), cmd_move_window_to_mouse(), cmd_move_window_to_position(), cmd_resize(), cmd_resize_set(), cmd_scratchpad_show(), cmd_split(), cmd_sticky(), cmd_swap(), cmd_title_format(), cmd_title_window_icon(), cmd_workspace(), cmd_workspace_name(), con_accepts_window(), con_border_style(), con_border_style_rect_without_title(), con_close(), con_descend_direction(), con_disable_fullscreen(), con_enable_fullscreen(), con_find_transient_for_window(), con_focus(), con_free(), con_mark(), con_mark_toggle(), con_minimum_size(), con_move_to_mark(), con_move_to_output(), con_move_to_target(), con_move_to_workspace(), con_new_skeleton(), con_next_focused(), con_on_remove_child(), con_parent_with_orientation(), con_set_fullscreen_mode(), con_set_layout(), con_set_urgency(), con_swap(), con_toggle_fullscreen(), con_toggle_layout(), con_unmark(), configure_binding(), configure_notify(), create_gaps_assignment(), create_workspace_on_output(), dlog_padding(), DRAGGING_CB(), drain_drag_events(), dump_node(), ewmh_update_focused(), ewmh_update_sticky(), ewmh_update_wm_desktop_recursively(), expose_event(), extract_workspace_names_from_bindings(), fake_absolute_configure_notify(), fake_outputs_init(), fill_rmlvo_from_root(), floating_check_size(), floating_drag_window(), floating_enable(), floating_fix_coordinates(), floating_maybe_reassign_ws(), floating_mod_on_tiled_client(), floating_raise_con(), floating_resize(), floating_resize_window(), free_ipc_client(), gaps_reapply_workspace_assignments(), gaps_update(), get_assigned_output(), get_binding(), get_binding_from_xcb_event(), get_output_containing(), get_output_next(), get_output_next_wrap(), get_output_with_dimensions(), get_tree_next_workspace(), grab_all_keys(), grab_keycode_for_binding(), handle_button_press(), handle_client_message(), handle_configure_notify(), handle_configure_request(), handle_destroy_notify_event(), handle_enter_notify(), handle_event(), handle_expose_event(), handle_focus_in(), handle_focus_out(), handle_i3_floating(), handle_key_press(), handle_map_request(), handle_mapping_notify(), handle_motif_hints_change(), handle_motion_notify(), handle_net_wm_state_change(), handle_output(), handle_screen_change(), handle_selection_clear(), handle_signal(), handle_strut_partial_change(), handle_unmap_notify_event(), init_ws_for_output(), insert_con_into(), ipc_confirm_restart(), IPC_HANDLER(), IPC_HANDLER(), ipc_new_client_on_fd(), ipc_receive_message(), ipc_send_barconfig_update_event(), ipc_send_binding_event(), ipc_send_window_event(), ipc_socket_writeable_cb(), json_determine_content_string(), json_end_map(), json_int(), json_string(), level_down(), main(), main_set_x11_cb(), manage_window(), match_parse_property(), maybe_auto_back_and_forth_workspace(), maybe_back_and_forth(), move_content(), move_matches_to_workspace(), move_to_output_directed(), nagbar_exited(), open_placeholder_window(), output_change_mode(), output_containing_rect(), output_init_con(), parse_command(), parse_config(), parse_file(), property_notify(), query_screens(), randr_disable_output(), randr_init(), randr_query_outputs(), randr_query_outputs_14(), randr_query_outputs_15(), remanage_window(), render_con(), render_output(), render_root(), resize_find_tiling_participants(), resize_graphical_handler(), restore_geometry(), restore_handle_event(), restore_kill_placeholder(), restore_xcb_prepare_cb(), route_click(), run_assignments(), scratchpad_fix_resolution(), scratchpad_move(), scratchpad_show(), send_take_focus(), set_hidden_state(), set_maximized_state(), sighandler_handle_key_press(), start_nagbar(), startup_monitor_event(), startup_sequence_delete(), startup_sequence_get(), startup_sequence_rename_workspace(), startup_workspace_for_window(), store_restart_layout(), switch_mode(), sync_respond(), TAILQ_HEAD(), tiling_drag(), tiling_resize(), tiling_resize_for_border(), translate_keysyms(), tree_append_json(), tree_close_internal(), tree_flatten(), tree_move(), tree_open_con(), tree_render(), tree_restore(), tree_split(), ungrab_all_keys(), update_placeholder_contents(), upsert_variable(), window_update_class(), window_update_hints(), window_update_icon(), window_update_leader(), window_update_machine(), window_update_name(), window_update_name_legacy(), window_update_normal_hints(), window_update_role(), window_update_strut_partial(), window_update_transient_for(), window_update_type(), workspace_attach_to(), workspace_back_and_forth(), workspace_back_and_forth_get(), workspace_defer_update_urgent_hint_cb(), workspace_encapsulate(), workspace_move_to_output(), workspace_prev_on_output(), workspace_show(), workspace_update_urgent_flag(), ws_force_orientation(), x_con_init(), x_draw_decoration(), x_move_win(), x_push_changes(), x_push_node(), x_push_node_unmaps(), x_reinit(), xcb_prepare_cb(), and xinerama_init().
#define ELOG | ( | fmt, | |
... ) |
Definition at line 100 of file libi3.h.
Referenced by _con_move_to_con(), bar_configure_binding(), binding_in_current_group(), bindings_get_buttons_to_grab(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), check_crossing_screen_boundary(), check_for_duplicate_bindings(), cmd_append_layout(), cmd_bar_hidden_state(), cmd_bar_mode(), cmd_focus(), cmd_focus_level(), cmd_gaps(), cmd_layout(), cmd_move_window_to_center(), cmd_move_window_to_position(), cmd_restart(), cmd_split(), cmd_sticky(), con_get_tree_representation(), con_minimum_size(), con_move_to_output_name(), con_orientation(), con_swap(), con_toggle_layout(), configure_binding(), configure_notify(), create_window(), drag_pointer(), DRAGGING_CB(), ewmh_update_wm_desktop_recursively(), expose_event(), fake_outputs_init(), floating_maybe_reassign_ws(), floating_move_to_pointer(), floating_reposition(), gaps_scope_to_mask(), gaps_update(), get_resource(), handle_button_press(), handle_client_message(), handle_screen_change(), insert_con_into(), ipc_client_timeout(), IPC_HANDLER(), IPC_HANDLER(), json_determine_content(), json_end_map(), json_int(), json_string(), json_validate(), level_up(), load_configuration(), load_keymap(), main(), match_parse_property(), nagbar_exited(), parse_command(), parse_config(), parse_direction(), parse_file(), parse_restart_fd(), print_config_path(), query_screens(), randr_init(), randr_query_outputs_14(), randr_query_outputs_15(), regex_matches(), regex_new(), set_shape_state(), setup_signal_handler(), slurp(), store_restart_layout(), switch_mode(), tiling_drag(), tiling_resize_for_border(), toggle_floating_mode(), translate_keysyms(), tree_append_json(), workspace_encapsulate(), x_draw_decoration(), x_move_win(), x_push_changes(), x_reinit(), x_reparent_child(), x_set_name(), and x_set_shape().
#define I3STRING_FREE | ( | str | ) |
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory.
Definition at line 243 of file libi3.h.
Referenced by cmd_title_format(), window_update_name(), window_update_name_legacy(), and x_draw_decoration().
#define LOG | ( | fmt, | |
... ) |
Definition at line 95 of file libi3.h.
Referenced by _con_move_to_con(), CFGFUN(), cmd_append_layout(), cmd_debuglog(), cmd_exec(), cmd_exit(), cmd_focus(), cmd_move_con_to_workspace_name(), cmd_move_con_to_workspace_number(), cmd_nop(), cmd_open(), cmd_reload(), cmd_rename_workspace(), cmd_resize_tiling_width_height(), cmd_restart(), cmd_shmlog(), cmd_split(), cmd_swap(), cmd_workspace_number(), con_on_remove_child(), con_set_urgency(), extract_workspace_names_from_bindings(), floating_disable(), floating_enable(), handle_client_message(), handle_enter_notify(), handle_event(), handle_expose_event(), handle_selection_clear(), handle_unmap_notify_event(), i3_restart(), init_ws_for_output(), IPC_HANDLER(), IPC_HANDLER(), json_bool(), json_double(), json_end_array(), json_end_map(), json_int(), json_key(), json_string(), load_configuration(), load_keymap(), main(), manage_window(), match_matches_window(), parse_file(), regex_matches(), scratchpad_move(), scratchpad_show(), start_application(), toggle_floating_mode(), tree_move(), tree_restore(), window_update_class(), window_update_hints(), window_update_machine(), window_update_name(), window_update_name_legacy(), window_update_role(), window_update_type(), workspace_get(), workspace_reassign_sticky(), workspace_show(), and x_window_kill().
#define XCB_BUTTON_CLICK_LEFT XCB_BUTTON_INDEX_1 |
#define XCB_BUTTON_CLICK_RIGHT XCB_BUTTON_INDEX_3 |
Definition at line 31 of file libi3.h.
Referenced by route_click().
#define XCB_BUTTON_SCROLL_DOWN XCB_BUTTON_INDEX_5 |
Definition at line 33 of file libi3.h.
Referenced by route_click().
#define XCB_BUTTON_SCROLL_LEFT 6 |
Definition at line 35 of file libi3.h.
Referenced by route_click().
#define XCB_BUTTON_SCROLL_RIGHT 7 |
Definition at line 36 of file libi3.h.
Referenced by route_click().
#define XCB_BUTTON_SCROLL_UP XCB_BUTTON_INDEX_4 |
Definition at line 32 of file libi3.h.
Referenced by route_click().
typedef struct color_t color_t |
typedef struct _i3String i3String |
typedef struct placeholder_t placeholder_t |
Helper structure for usage in format_placeholders().
typedef struct surface_t surface_t |
uint32_t aio_get_mod_mask_for | ( | uint32_t | keysym, |
xcb_key_symbols_t * | symbols ) |
All-in-one function which returns the modifier mask (XCB_MOD_MASK_*) for the given keysymbol, for example for XCB_NUM_LOCK (usually configured to mod2).
This function initiates one round-trip. Use get_mod_mask_for() directly if you already have the modifier mapping and key symbols.
Referenced by handle_mapping_notify(), and main().
bool boolstr | ( | const char * | str | ) |
char * convert_ucs2_to_utf8 | ( | xcb_char2b_t * | text, |
size_t | num_glyphs ) |
Converts the given string to UTF-8 from UCS-2 big endian.
The return value must be freed after use.
xcb_char2b_t * convert_utf8_to_ucs2 | ( | char * | input, |
size_t * | real_strlen ) |
Converts the given string to UCS-2 big endian for use with xcb_image_text_16().
The amount of real glyphs is stored in real_strlen, a buffer containing the UCS-2 encoded string (16 bit per glyph) is returned. It has to be freed when done.
int create_socket | ( | const char * | filename, |
char ** | out_socketpath ) |
Creates the UNIX domain socket at the given path, sets it to non-blocking mode, bind()s and listen()s on it.
The full path to the socket is stored in the char* that out_socketpath points to.
Referenced by main().
void debuglog | ( | char * | fmt, |
... ) |
void draw_text | ( | i3String * | text, |
xcb_drawable_t | drawable, | ||
xcb_gcontext_t | gc, | ||
cairo_surface_t * | surface, | ||
int | x, | ||
int | y, | ||
int | max_width ) |
Draws text onto the specified X drawable (normally a pixmap) at the specified coordinates (from the top left corner of the leftmost, uppermost glyph) and using the provided gc.
The given cairo surface must refer to the specified X drawable.
Text must be specified as an i3String.
Clears a surface with the given color.
Referenced by sighandler_draw_dialog(), update_placeholder_contents(), x_draw_decoration(), and x_push_node().
void draw_util_copy_surface | ( | surface_t * | src, |
surface_t * | dest, | ||
double | src_x, | ||
double | src_y, | ||
double | dest_x, | ||
double | dest_y, | ||
double | width, | ||
double | height ) |
Copies a surface onto another surface.
Referenced by handle_expose_event(), x_deco_recurse(), x_draw_decoration(), and x_push_node().
color_t draw_util_hex_to_color | ( | const char * | color | ) |
Parses the given color in hex format to an internal color representation.
Note that the input must begin with a hash sign, e.g., "#3fbc59".
Referenced by CFGFUN(), load_configuration(), and sighandler_draw_dialog().
void draw_util_image | ( | cairo_surface_t * | image, |
surface_t * | surface, | ||
int | x, | ||
int | y, | ||
int | width, | ||
int | height ) |
Draw the given image using libi3.
Referenced by x_draw_decoration().
void draw_util_rectangle | ( | surface_t * | surface, |
color_t | color, | ||
double | x, | ||
double | y, | ||
double | w, | ||
double | h ) |
Draws a filled rectangle.
This function is a convenience wrapper and takes care of flushing the surface as well as restoring the cairo state.
Referenced by sighandler_draw_dialog(), x_draw_decoration(), x_draw_decoration_after_title(), and x_draw_title_border().
void draw_util_surface_free | ( | xcb_connection_t * | conn, |
surface_t * | surface ) |
Destroys the surface.
Referenced by _x_con_kill(), restore_kill_placeholder(), sighandler_destroy_dialogs(), and x_push_node().
void draw_util_surface_init | ( | xcb_connection_t * | conn, |
surface_t * | surface, | ||
xcb_drawable_t | drawable, | ||
xcb_visualtype_t * | visual, | ||
int | width, | ||
int | height ) |
Initialize the surface to represent the given drawable.
Referenced by open_placeholder_window(), sighandler_create_dialogs(), x_con_init(), and x_push_node().
void draw_util_surface_set_size | ( | surface_t * | surface, |
int | width, | ||
int | height ) |
Resize the surface to the given size.
Referenced by configure_notify(), and x_push_node().
void draw_util_text | ( | i3String * | text, |
surface_t * | surface, | ||
color_t | fg_color, | ||
color_t | bg_color, | ||
int | x, | ||
int | y, | ||
int | max_width ) |
Draw the given text using libi3.
This function also marks the surface dirty which is needed if other means of drawing are used. This will be the case when using XCB to draw text.
Referenced by sighandler_draw_dialog(), update_placeholder_contents(), and x_draw_decoration().
void errorlog | ( | char * | fmt, |
... ) |
void fake_configure_notify | ( | xcb_connection_t * | conn, |
xcb_rectangle_t | r, | ||
xcb_window_t | window, | ||
int | border_width ) |
Generates a configure_notify event and sends it to the given window Applications need this to think they’ve configured themselves correctly.
The truth is, however, that we will manage them.
Referenced by fake_absolute_configure_notify().
bool font_is_pango | ( | void | ) |
Returns true if and only if the current font is a pango font.
Referenced by con_parse_title_format(), pango_escape_markup(), and x_draw_decoration_after_title().
char * format_placeholders | ( | char * | format, |
placeholder_t * | placeholders, | ||
int | num ) |
Replaces occurrences of the defined placeholders in the format string.
Referenced by con_parse_title_format().
void free_font | ( | void | ) |
Frees the resources taken by the current font.
If no font was previously loaded, it simply returns.
Referenced by free_configuration().
gchar * g_utf8_make_valid | ( | const gchar * | str, |
gssize | len ) |
uint32_t get_colorpixel | ( | const char * | hex | ) | const |
Returns the colorpixel to use for the given hex color (think of HTML).
Only works for true-color (vast majority of cases) at the moment, avoiding a roundtrip to X11.
The hex_color has to start with #, for example #FF00FF.
NOTE that get_colorpixel() does NOT check the given color code for validity. This has to be done by the caller.
NOTE that this function may in the future rely on a global xcb_connection_t variable called 'conn' to be present.
char * get_config_path | ( | const char * | override_configpath, |
bool | use_system_paths ) |
Get the path of the first configuration file found.
If override_configpath is specified, that path is returned and saved for further calls. Otherwise, checks the home directory first, then the system directory, always taking into account the XDG Base Directory Specification ($XDG_CONFIG_HOME, $XDG_CONFIG_DIRS).
Referenced by load_configuration().
long get_dpi_value | ( | void | ) |
This function returns the value of the DPI setting.
char * get_exe_path | ( | const char * | argv0 | ) |
This function returns the absolute path to the executable it is running in.
The implementation follows https://stackoverflow.com/a/933996/712014
Returned value must be freed by the caller.
uint32_t get_mod_mask_for | ( | uint32_t | keysym, |
xcb_key_symbols_t * | symbols, | ||
xcb_get_modifier_mapping_reply_t * | modmap_reply ) |
Returns the modifier mask (XCB_MOD_MASK_*) for the given keysymbol, for example for XCB_NUM_LOCK (usually configured to mod2).
This function does not initiate any round-trips.
char * get_process_filename | ( | const char * | prefix | ) |
Returns the name of a temporary file with the specified prefix.
Referenced by init_logging(), main(), and store_restart_layout().
uint16_t get_visual_depth | ( | xcb_visualid_t | visual_id | ) |
Get depth of visual specified by visualid.
Referenced by manage_window().
xcb_visualtype_t * get_visualtype | ( | xcb_screen_t * | screen | ) |
Returns the visual type associated with the given screen.
Referenced by main(), and open_placeholder_window().
const xcb_char2b_t * i3string_as_ucs2 | ( | i3String * | str | ) |
Returns the UCS-2 encoded version of the i3String.
const char * i3string_as_utf8 | ( | i3String * | str | ) |
Returns the UTF-8 encoded version of the i3String.
Referenced by cmd_title_format(), con_parse_title_format(), dump_node(), handle_windowname_change(), handle_windowname_change_legacy(), window_name_changed(), window_update_name(), and window_update_name_legacy().
Copies the given i3string.
Note that this will not free the source string.
Escape pango markup characters in the given string.
void i3string_free | ( | i3String * | str | ) |
Free an i3String.
Referenced by update_placeholder_contents(), window_free(), window_update_name(), and window_update_name_legacy().
i3String * i3string_from_markup | ( | const char * | from_markup | ) |
Build an i3String from an UTF-8 encoded string in Pango markup.
i3String * i3string_from_markup_with_length | ( | const char * | from_markup, |
size_t | num_bytes ) |
Build an i3String from an UTF-8 encoded string in Pango markup with fixed length.
i3String * i3string_from_ucs2 | ( | const xcb_char2b_t * | from_ucs2, |
size_t | num_glyphs ) |
Build an i3String from an UCS-2 encoded string.
Returns the newly-allocated i3String.
i3String * i3string_from_utf8 | ( | const char * | from_utf8 | ) |
Build an i3String from an UTF-8 encoded string.
Returns the newly-allocated i3String.
Referenced by con_parse_title_format(), sighandler_setup(), update_placeholder_contents(), window_update_name(), window_update_name_legacy(), and x_draw_decoration().
i3String * i3string_from_utf8_with_length | ( | const char * | from_utf8, |
ssize_t | num_bytes ) |
Build an i3String from an UTF-8 encoded string with fixed length.
To be used when no proper NULL-termination is available. Returns the newly-allocated i3String.
size_t i3string_get_num_bytes | ( | i3String * | str | ) |
Returns the number of bytes (UTF-8 encoded) in an i3String.
size_t i3string_get_num_glyphs | ( | i3String * | str | ) |
Returns the number of glyphs in an i3String.
bool i3string_is_markup | ( | i3String * | str | ) |
Whether the given i3String is in Pango markup.
void i3string_set_markup | ( | i3String * | str, |
bool | pango_markup ) |
Set whether the i3String should use Pango markup.
Referenced by con_parse_title_format().
void init_dpi | ( | void | ) |
Initialize the DPI setting.
This will use the 'Xft.dpi' X resource if available and fall back to guessing the correct value otherwise.
Referenced by main().
int ipc_connect | ( | const char * | socket_path | ) |
Connects to the i3 IPC socket and returns the file descriptor for the socket.
die()s if anything goes wrong.
Referenced by display_running_version().
int ipc_connect_impl | ( | const char * | socket_path | ) |
Connects to the socket at the given path with no fallback paths.
Returns -1 if connect() fails and die()s for other errors.
int ipc_recv_message | ( | int | sockfd, |
uint32_t * | message_type, | ||
uint32_t * | reply_length, | ||
uint8_t ** | reply ) |
Reads a message from the given socket file descriptor and stores its length (reply_length) as well as a pointer to its contents (reply).
Returns -1 when read() fails, errno will remain. Returns -2 when the IPC protocol is violated (invalid magic, unexpected message type, EOF instead of a message). Additionally, the error will be printed to stderr. Returns 0 on success.
Referenced by display_running_version(), ipc_receive_message(), and main().
int ipc_send_message | ( | int | sockfd, |
const uint32_t | message_size, | ||
const uint32_t | message_type, | ||
const uint8_t * | payload ) |
Formats a message (payload) of the given size and type and sends it to i3 via the given socket file descriptor.
Returns -1 when write() fails, errno will remain. Returns 0 on success.
Referenced by display_running_version(), and main().
bool is_background_set | ( | xcb_connection_t * | conn, |
xcb_screen_t * | screen ) |
Test whether the screen's root window has a background set.
This opens & closes a window and test whether the root window still shows the content of the window.
Referenced by main().
bool is_debug_build | ( | void | ) | const |
Returns true if this version of i3 is a debug build (anything which is not a release version), based on the git version number.
Referenced by main().
i3Font load_font | ( | const char * | pattern, |
const bool | fallback ) |
Loads a font for usage, also getting its height.
If fallback is true, the fonts 'fixed' or '-misc-*' will be loaded instead of exiting. If any font was previously loaded, it will be freed.
Referenced by CFGFUN(), and load_configuration().
int logical_px | ( | const int | logical | ) |
Convert a logical amount of pixels (e.g.
2 pixels on a “standard” 96 DPI screen) to a corresponding amount of physical pixels on a standard or retina screen, e.g. 5 pixels on a 227 DPI MacBook Pro 13" Retina screen.
Referenced by border_width_from_style(), CFGFUN(), CFGFUN(), cmd_gaps(), DRAGGING_CB(), load_configuration(), main(), resize_graphical_handler(), sighandler_setup(), threshold_exceeded(), window_update_icon(), x_draw_decoration(), and x_draw_decoration_after_title().
int mkdirp | ( | const char * | path, |
mode_t | mode ) |
Emulates mkdir -p (creates any missing folders)
Referenced by store_restart_layout().
bool path_exists | ( | const char * | path | ) |
Checks if the given path exists by calling stat().
Referenced by tree_restore().
int predict_text_width | ( | i3String * | text | ) |
Predict the text width in pixels for the given text.
Text must be specified as an i3String.
Referenced by sighandler_setup(), update_placeholder_contents(), and x_draw_decoration().
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.
Referenced by cmd_append_layout(), store_restart_layout(), and tree_restore().
char * root_atom_contents | ( | const char * | atomname, |
xcb_connection_t * | provided_conn, | ||
int | screen ) |
Try to get the contents of the given atom (for example I3_SOCKET_PATH) from the X11 root window and return NULL if it doesn’t work.
If the provided XCB connection is NULL, a new connection will be established.
The memory for the contents is dynamically allocated and has to be free()d by the caller.
Referenced by display_running_version(), and main().
int sasprintf | ( | char ** | strp, |
const char * | fmt, | ||
... ) |
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory available)
Referenced by CFGFUN(), cmd_restart(), con_get_tree_representation(), create_workspace_on_output(), display_running_version(), exec_i3_utility(), fake_outputs_init(), fill_rmlvo_from_root(), floating_enable(), handle_output(), ipc_client_timeout(), IPC_HANDLER(), json_end_map(), json_string(), main(), manage_window(), open_logbuffer(), output_init_con(), parse_command(), parse_config(), push_string(), query_screens(), randr_query_outputs_15(), run_assignments(), run_binding(), start_config_error_nagbar(), startup_sequence_get(), switch_mode(), translate_keysyms(), update_placeholder_contents(), version_string(), window_update_role(), workspace_get(), and x_draw_decoration().
void * scalloc | ( | size_t | num, |
size_t | size ) |
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory available)
Referenced by _sync_json_key(), add_argument(), add_subscription(), bar_configure_binding(), bindings_get_buttons_to_grab(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), con_mark(), con_new_skeleton(), configure_binding(), create_gaps_assignment(), create_root_output(), fake_outputs_init(), handle_client_message(), handle_output(), ipc_new_client_on_fd(), ipc_push_pending(), json_int(), json_key(), json_string(), load_configuration(), main(), manage_window(), mode_from_name(), open_placeholder_window(), output_init_con(), parse_command(), parse_config(), parse_file(), parse_string(), query_screens(), randr_query_outputs_15(), regex_new(), reorder_bindings_of_mode(), restore_connect(), send_take_focus(), sighandler_create_dialogs(), slurp(), start_application(), sync_respond(), TAILQ_HEAD(), upsert_variable(), version_string(), workspace_show(), x_con_init(), x_draw_decoration(), and x_window_kill().
void set_font | ( | i3Font * | font | ) |
Defines the font to be used for the forthcoming calls.
Referenced by CFGFUN(), and load_configuration().
Defines the colors to be used for the forthcoming draw_text calls.
void set_nonblock | ( | int | sockfd | ) |
Puts the given socket file descriptor into non-blocking mode or dies if setting O_NONBLOCK failed.
Non-blocking sockets are a good idea for our IPC model because we should by no means block the window manager.
Referenced by ipc_new_client_on_fd().
void set_screenshot_as_wallpaper | ( | xcb_connection_t * | conn, |
xcb_screen_t * | screen ) |
Grab a screenshot of the screen's root window and set it as the wallpaper.
Referenced by main().
void * smalloc | ( | size_t | size | ) |
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory available)
Referenced by binding_copy(), CFGFUN(), con_get_fullscreen_con(), display_running_version(), get_focus_order(), main(), manage_existing_windows(), open_placeholder_window(), parse_command(), parse_config(), precalculate_sizes(), SLIST_HEAD(), start_nagbar(), TAILQ_HEAD(), and window_update_icon().
void * srealloc | ( | void * | ptr, |
size_t | size ) |
Safe-wrapper around realloc which exits if realloc returns NULL (meaning that there is no more memory available).
Referenced by add_subscription(), CFGFUN(), display_running_version(), extract_workspace_names_from_bindings(), ipc_push_pending(), ipc_send_client_message(), json_string(), main(), run_assignments(), and x_push_changes().
char * sstrdup | ( | const char * | str | ) |
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory available)
Referenced by _create___i3(), bar_configure_binding(), binding_copy(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), CFGFUN(), cmd_rename_workspace(), cmd_title_format(), con_get_tree_representation(), con_mark(), con_parse_title_format(), con_toggle_layout(), configure_binding(), create_gaps_assignment(), create_workspace_on_output(), exec_i3_utility(), handle_windowname_change(), handle_windowname_change_legacy(), json_end_map(), json_string(), load_configuration(), main(), match_parse_property(), mode_from_name(), output_init_con(), parse_command(), parse_file(), push_string(), randr_query_outputs_15(), regex_new(), run_binding(), single_line(), start_application(), startup_sequence_rename_workspace(), store_restart_layout(), TAILQ_HEAD(), translate_keysyms(), tree_append_json(), upsert_variable(), workspace_get(), workspace_show(), x_draw_decoration(), and x_set_name().
char * sstrndup | ( | const char * | str, |
size_t | size ) |
Safe-wrapper around strndup which exits if strndup returns NULL (meaning that there is no more memory available)
Referenced by IPC_HANDLER(), json_string(), window_update_class(), window_update_machine(), window_update_name(), and window_update_name_legacy().
int strcasecmp_nullable | ( | const char * | a, |
const char * | b ) |
Like strcasecmp but considers the case where either string is NULL.
Referenced by _con_attach().
char * strndup | ( | const char * | str, |
size_t | n ) |
Taken from FreeBSD Returns a pointer to a new string which is a duplicate of the string, but only copies at most n characters.
ssize_t swrite | ( | int | fd, |
const void * | buf, | ||
size_t | count ) |
Safe-wrapper around writeall which exits if it returns -1 (meaning that write failed)
void verboselog | ( | char * | fmt, |
... ) |
ssize_t writeall | ( | int | fd, |
const void * | buf, | ||
size_t | count ) |
Wrapper around correct write which returns -1 (meaning that write failed) or count (meaning that all bytes were written)
Referenced by log_broadcast_to_clients(), and store_restart_layout().
ssize_t writeall_nonblock | ( | int | fd, |
const void * | buf, | ||
size_t | count ) |
Like writeall, but instead of retrying upon EAGAIN (returned when a write would block), the function stops and returns the total number of bytes written so far.
Referenced by ipc_push_pending().
|
extern |
XCB connection and root screen.
Definition at line 54 of file main.c.
Referenced by _x_con_kill(), allow_replay_pointer(), con_set_fullscreen_mode(), create_drop_indicator(), create_window(), display_running_version(), drag_pointer(), DRAGGING_CB(), DRAGGING_CB(), DRAGGING_CB(), drain_drag_events(), ewmh_setup_hints(), ewmh_update_active_window(), ewmh_update_client_list(), ewmh_update_client_list_stacking(), ewmh_update_current_desktop(), ewmh_update_desktop_names(), ewmh_update_desktop_viewport(), ewmh_update_focused(), ewmh_update_number_of_desktops(), ewmh_update_sticky(), ewmh_update_visible_name(), ewmh_update_wm_desktop_recursively(), ewmh_update_workarea(), fake_absolute_configure_notify(), fill_rmlvo_from_root(), floating_move_to_pointer(), floating_set_hint_atom(), free_configuration(), get_resource(), grab_all_keys(), handle_button_press(), handle_client_message(), handle_configure_request(), handle_event(), handle_expose_event(), handle_map_request(), handle_mapping_notify(), handle_output(), handle_screen_change(), handle_signal(), handle_unmap_notify_event(), i3_exit(), load_configuration(), load_keymap(), main(), manage_existing_windows(), manage_window(), property_notify(), query_screens(), randr_init(), randr_query_outputs(), randr_query_outputs_14(), randr_query_outputs_15(), regrab_all_buttons(), remanage_window(), resize_graphical_handler(), restore_geometry(), route_click(), send_take_focus(), set_hidden_state(), set_maximized_state(), sighandler_create_dialogs(), sighandler_destroy_dialogs(), sighandler_handle_expose(), startup_sequence_delete_by_window(), startup_sequence_get(), switch_mode(), sync_respond(), tiling_drag(), tree_close_internal(), ungrab_all_keys(), update_shmlog_atom(), use_root_output(), window_supports_protocol(), window_update_normal_hints(), x_con_init(), x_con_kill(), x_mask_event_mask(), x_push_changes(), x_push_node(), x_push_node_unmaps(), x_set_i3_atoms(), x_set_shape(), x_shape_frame(), x_unshape_frame(), x_window_kill(), xcb_add_property_atom(), xcb_grab_buttons(), xcb_prepare_cb(), xcb_remove_property_atom(), xcb_set_window_rect(), xcursor_load_cursors(), xcursor_set_root_cursor(), and xinerama_init().
|
extern |
Definition at line 66 of file main.c.
Referenced by create_root_output(), get_visualid_by_depth(), get_visualtype_by_id(), main(), open_placeholder_window(), sighandler_create_dialogs(), total_outputs_dimensions(), x_con_init(), and xcursor_load_cursors().