#ifndef _CONFIG_H
#define _CONFIG_H
+#include <stdbool.h>
#include "queue.h"
typedef struct Config Config;
* configuration file.
*
*/
-void load_configuration(xcb_connection_t *conn, const char *override_configfile);
+void load_configuration(xcb_connection_t *conn, const char *override_configfile, bool reload);
+void grab_all_keys(xcb_connection_t *conn);
#endif
extern int num_screens;
extern uint8_t root_depth;
extern xcb_atom_t atoms[NUM_ATOMS];
+extern xcb_window_t root;
#endif
#include "client.h"
#include "floating.h"
#include "xcb.h"
+#include "config.h"
bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) {
/* If this container is empty, we’re done */
exit(EXIT_SUCCESS);
}
+ /* Is it <reload */
+ if (STARTS_WITH(command, "reload")) {
+ load_configuration(conn,NULL,true);
+ return;
+ }
+
/* Is it <restart>? Then restart in place. */
if (STARTS_WITH(command, "restart")) {
LOG("restarting \"%s\"...\n", start_argv[0]);
}
}
+/* UnGrab the bound keys */
+
+void ungrab_all_keys(xcb_connection_t *conn) {
+ Binding *bind;
+ TAILQ_FOREACH(bind, &bindings, bindings) {
+ LOG("UnGrabbing %d\n", bind->keycode);
+ #define UNGRAB_KEY(modifier) xcb_ungrab_key(conn,bind->keycode,root,modifier);
+ UNGRAB_KEY(bind->keycode);
+ }
+}
+
+/* Grab the bound keys */
+void grab_all_keys(xcb_connection_t *conn) {
+ Binding *bind;
+ TAILQ_FOREACH(bind, &bindings, bindings) {
+ LOG("Grabbing %d\n", bind->keycode);
+ if ( bind->mods & BIND_MODE_SWITCH )
+ xcb_grab_key(conn, 0, root, 0, bind->keycode,
+ XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
+ else {
+ /* Grab the key in all combinations */
+ #define GRAB_KEY(modifier) xcb_grab_key(conn, 0, root, modifier, bind->keycode, \
+ XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC)
+ GRAB_KEY(bind->mods);
+ GRAB_KEY(bind->mods | xcb_numlock_mask);
+ GRAB_KEY(bind->mods | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
+ }
+ }
+}
+
/*
* Reads the configuration from ~/.i3/config or /etc/i3/config if not found.
*
* configuration file.
*
*/
-void load_configuration(xcb_connection_t *conn, const char *override_configpath) {
+void load_configuration(xcb_connection_t *conn, const char *override_configpath,bool reload) {
+
+ if(reload) {
+ /* First ungrab the keys */
+ ungrab_all_keys(conn);
+ /* clean up lists */
+ Binding *bind;
+ TAILQ_FOREACH(bind,&bindings,bindings) {
+ TAILQ_REMOVE(&bindings,bind,bindings);
+ free(bind->command);
+ free(bind);
+ }
+
+ struct Assignment *assign;
+ TAILQ_FOREACH(assign,&assignments,assignments) {
+ TAILQ_REMOVE(&assignments,assign,assignments);
+ free(assign->windowclass_title);
+ free(assign)
+ }
+ }
+
+
SLIST_HEAD(variables_head, Variable) variables;
#define OPTION_STRING(name) \
die("Unknown configfile option: %s\n", key);
}
+ /* now grab all keys again */
+ if(reload)
+ grab_all_keys(conn);
fclose(handle);
REQUIRED_OPTION(terminal);
xcb_event_handlers_t evenths;
xcb_atom_t atoms[NUM_ATOMS];
+xcb_window_t root;
int num_screens = 0;
/* The depth of the root screen (used e.g. for creating new pixmaps later) */
bool autostart = true;
xcb_connection_t *conn;
xcb_property_handlers_t prophs;
- xcb_window_t root;
xcb_intern_atom_cookie_t atom_cookies[NUM_ATOMS];
setlocale(LC_ALL, "");
if (xcb_connection_has_error(conn))
die("Cannot open display\n");
- load_configuration(conn, override_configpath);
+ load_configuration(conn, override_configpath,false);
/* Place requests for the atoms we need as soon as possible */
#define REQUEST_ATOM(name) atom_cookies[name] = xcb_intern_atom(conn, 0, strlen(#name), #name);
xcb_get_numlock_mask(conn);
- /* Grab the bound keys */
- Binding *bind;
- TAILQ_FOREACH(bind, &bindings, bindings) {
- LOG("Grabbing %d\n", bind->keycode);
- if (bind->mods & BIND_MODE_SWITCH)
- xcb_grab_key(conn, 0, root, 0, bind->keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
- else {
- /* Grab the key in all combinations */
- #define GRAB_KEY(modifier) xcb_grab_key(conn, 0, root, modifier, bind->keycode, \
- XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC)
- GRAB_KEY(bind->mods);
- GRAB_KEY(bind->mods | xcb_numlock_mask);
- GRAB_KEY(bind->mods | xcb_numlock_mask | XCB_MOD_MASK_LOCK);
- }
- }
+ grab_all_keys(conn);
/* Autostarting exec-lines */
struct Autostart *exec;