src/config.c File Reference

#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdlib.h>
#include <glob.h>
#include <wordexp.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <xcb/xcb_keysyms.h>
#include "i3.h"
#include "util.h"
#include "config.h"
#include "xcb.h"
#include "table.h"
#include "workspace.h"
#include "log.h"
Include dependency graph for config.c:

Go to the source code of this file.

Defines

#define GRAB_KEY(modifier)
#define REQUIRED_OPTION(name)
#define INIT_COLOR(x, cborder, cbackground, ctext)

Functions

char * glob_path (const char *path)
 This function resolves ~ in pathnames.
bool path_exists (const char *path)
 Checks if the given path exists by calling stat().
void ungrab_all_keys (xcb_connection_t *conn)
 Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify event or a configuration file reload.
static void grab_keycode_for_binding (xcb_connection_t *conn, Binding *bind, uint32_t keycode)
Bindingget_binding (uint16_t modifiers, xcb_keycode_t keycode)
 Returns a pointer to the Binding with the specified modifiers and keycode or NULL if no such binding exists.
void translate_keysyms ()
 Translates keysymbols to keycodes for all bindings which use keysyms.
void grab_all_keys (xcb_connection_t *conn, bool bind_mode_switch)
 Grab the bound keys (tell X to send us keypress events for those keycodes).
void switch_mode (xcb_connection_t *conn, const char *new_mode)
 Switches the key bindings to the given mode, if the mode exists.
static char * get_config_path ()
static void parse_configuration (const char *override_configpath)
void load_configuration (xcb_connection_t *conn, const char *override_configpath, bool reload)
 Reads the configuration from ~/.i3/config or /etc/i3/config if not found.

Variables

Config config
struct modes_head modes

Define Documentation

#define GRAB_KEY ( modifier   ) 
Value:
do { \
                        xcb_grab_key(conn, 0, root, modifier, keycode, \
                                     XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); \
                } while (0)

Referenced by grab_keycode_for_binding().

#define INIT_COLOR ( x,
cborder,
cbackground,
ctext   ) 
Value:
do { \
                x.border = get_colorpixel(conn, cborder); \
                x.background = get_colorpixel(conn, cbackground); \
                x.text = get_colorpixel(conn, ctext); \
        } while (0)

Referenced by load_configuration().

#define REQUIRED_OPTION ( name   ) 
Value:
if (config.name == NULL) \
                die("You did not specify required configuration option " #name "\n");

Referenced by load_configuration().


Function Documentation

Binding* get_binding ( uint16_t  modifiers,
xcb_keycode_t  keycode 
)

Returns a pointer to the Binding with the specified modifiers and keycode or NULL if no such binding exists.

Definition at line 109 of file config.c.

References bindings, Binding::keycode, Binding::mods, Binding::number_keycodes, Binding::symbol, TAILQ_END, TAILQ_FOREACH, and Binding::translated_to.

Referenced by handle_key_press().

static char* get_config_path (  )  [static]

Definition at line 235 of file config.c.

References die, glob_path(), and path_exists().

Referenced by parse_configuration().

Here is the call graph for this function:

char* glob_path ( const char *  path  ) 

This function resolves ~ in pathnames.

Definition at line 44 of file config.c.

References die, and sstrdup().

Referenced by get_config_path(), and ipc_create_socket().

Here is the call graph for this function:

void grab_all_keys ( xcb_connection_t *  conn,
bool  bind_mode_switch 
)

Grab the bound keys (tell X to send us keypress events for those keycodes).

Definition at line 188 of file config.c.

References BIND_MODE_SWITCH, bindings, grab_keycode_for_binding(), Binding::keycode, Binding::mods, Binding::number_keycodes, TAILQ_FOREACH, and Binding::translated_to.

Referenced by handle_mapping_notify(), load_configuration(), main(), switch_mode(), and xkb_got_event().

Here is the call graph for this function:

static void grab_keycode_for_binding ( xcb_connection_t *  conn,
Binding bind,
uint32_t  keycode 
) [static]

Definition at line 85 of file config.c.

References BIND_MODE_SWITCH, DLOG, GRAB_KEY, Binding::mods, and xcb_numlock_mask.

Referenced by grab_all_keys(), and translate_keysyms().

void load_configuration ( xcb_connection_t *  conn,
const char *  override_configfile,
bool  reload 
)
static void parse_configuration ( const char *  override_configpath  )  [static]

Definition at line 291 of file config.c.

References DLOG, get_config_path(), and parse_file().

Referenced by load_configuration().

Here is the call graph for this function:

bool path_exists ( const char *  path  ) 

Checks if the given path exists by calling stat().

Definition at line 70 of file config.c.

Referenced by get_config_path(), and ipc_create_socket().

void switch_mode ( xcb_connection_t *  conn,
const char *  new_mode 
)

Switches the key bindings to the given mode, if the mode exists.

Definition at line 211 of file config.c.

References Mode::bindings, bindings, ELOG, grab_all_keys(), LOG, modes, Mode::name, SLIST_FOREACH, translate_keysyms(), and ungrab_all_keys().

Referenced by parse_command().

Here is the call graph for this function:

void translate_keysyms (  ) 

Translates keysymbols to keycodes for all bindings which use keysyms.

Definition at line 138 of file config.c.

References bindings, DLOG, ELOG, global_conn, grab_keycode_for_binding(), Binding::keycode, keysyms, Binding::number_keycodes, smalloc(), Binding::symbol, TAILQ_FOREACH, and Binding::translated_to.

Referenced by handle_mapping_notify(), load_configuration(), main(), switch_mode(), and xkb_got_event().

Here is the call graph for this function:

void ungrab_all_keys ( xcb_connection_t *  conn  ) 

Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify event or a configuration file reload.

Definition at line 80 of file config.c.

References DLOG, and root.

Referenced by handle_mapping_notify(), load_configuration(), switch_mode(), and xkb_got_event().


Variable Documentation

struct modes_head modes

Definition at line 38 of file config.c.

Referenced by load_configuration(), switch_mode(), and yyparse().


Generated by  doxygen 1.6.2