Some fixes/reformatting for bapt’s patch
This commit is contained in:
parent
40750e227d
commit
ce501c9de9
|
@ -908,7 +908,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is it <reload */
|
/* Is it a <reload>? */
|
||||||
if (STARTS_WITH(command, "reload")) {
|
if (STARTS_WITH(command, "reload")) {
|
||||||
load_configuration(conn, NULL, true);
|
load_configuration(conn, NULL, true);
|
||||||
return;
|
return;
|
||||||
|
|
61
src/config.c
61
src/config.c
|
@ -57,23 +57,27 @@ static void replace_variable(char *buffer, const char *key, const char *value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* UnGrab the bound keys */
|
/*
|
||||||
|
* Ungrab the bound keys
|
||||||
|
*
|
||||||
|
*/
|
||||||
void ungrab_all_keys(xcb_connection_t *conn) {
|
void ungrab_all_keys(xcb_connection_t *conn) {
|
||||||
Binding *bind;
|
Binding *bind;
|
||||||
TAILQ_FOREACH(bind, &bindings, bindings) {
|
TAILQ_FOREACH(bind, &bindings, bindings) {
|
||||||
LOG("UnGrabbing %d\n", bind->keycode);
|
LOG("Ungrabbing %d\n", bind->keycode);
|
||||||
#define UNGRAB_KEY(modifier) xcb_ungrab_key(conn,bind->keycode,root,modifier);
|
xcb_ungrab_key(conn, bind->keycode, root, bind->keycode);
|
||||||
UNGRAB_KEY(bind->keycode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab the bound keys */
|
/*
|
||||||
|
* Grab the bound keys (tell X to send us keypress events for those keycodes)
|
||||||
|
*
|
||||||
|
*/
|
||||||
void grab_all_keys(xcb_connection_t *conn) {
|
void grab_all_keys(xcb_connection_t *conn) {
|
||||||
Binding *bind;
|
Binding *bind;
|
||||||
TAILQ_FOREACH(bind, &bindings, bindings) {
|
TAILQ_FOREACH(bind, &bindings, bindings) {
|
||||||
LOG("Grabbing %d\n", bind->keycode);
|
LOG("Grabbing %d\n", bind->keycode);
|
||||||
if ( bind->mods & BIND_MODE_SWITCH )
|
if ((bind->mods & BIND_MODE_SWITCH) != 0)
|
||||||
xcb_grab_key(conn, 0, root, 0, bind->keycode,
|
xcb_grab_key(conn, 0, root, 0, bind->keycode,
|
||||||
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
|
XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_SYNC);
|
||||||
else {
|
else {
|
||||||
|
@ -95,27 +99,28 @@ void grab_all_keys(xcb_connection_t *conn) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload) {
|
void load_configuration(xcb_connection_t *conn, const char *override_configpath, bool reload) {
|
||||||
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
/* First ungrab the keys */
|
/* First ungrab the keys */
|
||||||
ungrab_all_keys(conn);
|
ungrab_all_keys(conn);
|
||||||
/* clean up lists */
|
|
||||||
|
/* Clear the old binding and assignment lists */
|
||||||
Binding *bind;
|
Binding *bind;
|
||||||
TAILQ_FOREACH(bind,&bindings,bindings) {
|
while (!TAILQ_EMPTY(&bindings)) {
|
||||||
|
bind = TAILQ_FIRST(&bindings);
|
||||||
TAILQ_REMOVE(&bindings, bind, bindings);
|
TAILQ_REMOVE(&bindings, bind, bindings);
|
||||||
free(bind->command);
|
FREE(bind->command);
|
||||||
free(bind);
|
FREE(bind);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Assignment *assign;
|
struct Assignment *assign;
|
||||||
TAILQ_FOREACH(assign,&assignments,assignments) {
|
while (!TAILQ_EMPTY(&assignments)) {
|
||||||
|
assign = TAILQ_FIRST(&assignments);
|
||||||
|
FREE(assign->windowclass_title);
|
||||||
TAILQ_REMOVE(&assignments, assign, assignments);
|
TAILQ_REMOVE(&assignments, assign, assignments);
|
||||||
free(assign->windowclass_title);
|
FREE(assign);
|
||||||
free(assign)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SLIST_HEAD(variables_head, Variable) variables;
|
SLIST_HEAD(variables_head, Variable) variables;
|
||||||
|
|
||||||
#define OPTION_STRING(name) \
|
#define OPTION_STRING(name) \
|
||||||
|
@ -293,23 +298,22 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
/* assign window class[/window title] → workspace */
|
/* assign window class[/window title] → workspace */
|
||||||
if (strcasecmp(key, "assign") == 0) {
|
if (strcasecmp(key, "assign") == 0) {
|
||||||
LOG("assign: \"%s\"\n", value);
|
LOG("assign: \"%s\"\n", value);
|
||||||
char *class_title = sstrdup(value);
|
char *class_title;
|
||||||
char *target;
|
char *target;
|
||||||
|
char *end;
|
||||||
|
|
||||||
/* If the window class/title is quoted we skip quotes */
|
/* If the window class/title is quoted we skip quotes */
|
||||||
if (class_title[0] == '"') {
|
if (value[0] == '"') {
|
||||||
class_title++;
|
class_title = sstrdup(value+1);
|
||||||
char *end = strchr(class_title, '"');
|
end = strchr(class_title, '"');
|
||||||
|
} else {
|
||||||
|
class_title = sstrdup(value);
|
||||||
|
/* If it is not quoted, we terminate it at the first space */
|
||||||
|
end = strchr(class_title, ' ');
|
||||||
|
}
|
||||||
if (end == NULL)
|
if (end == NULL)
|
||||||
die("Malformed assignment, couldn't find terminating quote\n");
|
die("Malformed assignment, couldn't find terminating quote\n");
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
} else {
|
|
||||||
/* If it is not quoted, we terminate it at the first space */
|
|
||||||
char *end = strchr(class_title, ' ');
|
|
||||||
if (end == NULL)
|
|
||||||
die("Malformed assignment, couldn't find terminating space\n");
|
|
||||||
*end = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Strip trailing whitespace */
|
/* Strip trailing whitespace */
|
||||||
while (strlen(value) > 0 && value[strlen(value)-1] == ' ')
|
while (strlen(value) > 0 && value[strlen(value)-1] == ' ')
|
||||||
|
@ -317,7 +321,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
|
|
||||||
/* The target is the last argument separated by a space */
|
/* The target is the last argument separated by a space */
|
||||||
if ((target = strrchr(value, ' ')) == NULL)
|
if ((target = strrchr(value, ' ')) == NULL)
|
||||||
die("Malformed assignment, couldn't find target\n");
|
die("Malformed assignment, couldn't find target (\"%s\")\n", value);
|
||||||
target++;
|
target++;
|
||||||
|
|
||||||
if (strchr(target, '~') == NULL && (atoi(target) < 1 || atoi(target) > 10))
|
if (strchr(target, '~') == NULL && (atoi(target) < 1 || atoi(target) > 10))
|
||||||
|
@ -380,7 +384,6 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath,
|
||||||
REQUIRED_OPTION(terminal);
|
REQUIRED_OPTION(terminal);
|
||||||
REQUIRED_OPTION(font);
|
REQUIRED_OPTION(font);
|
||||||
|
|
||||||
|
|
||||||
while (!SLIST_EMPTY(&variables)) {
|
while (!SLIST_EMPTY(&variables)) {
|
||||||
struct Variable *v = SLIST_FIRST(&variables);
|
struct Variable *v = SLIST_FIRST(&variables);
|
||||||
SLIST_REMOVE_HEAD(&variables, variables);
|
SLIST_REMOVE_HEAD(&variables, variables);
|
||||||
|
|
Loading…
Reference in New Issue