*/
#include "all.h"
+#include <xkbcommon/xkbcommon.h>
+
pid_t command_error_nagbar_pid = -1;
/*
continue;
/* We need to translate the symbol to a keycode */
- keysym = XStringToKeysym(bind->symbol);
- if (keysym == NoSymbol) {
+ keysym = xkb_keysym_from_name(bind->symbol, XKB_KEYSYM_NO_FLAGS);
+ if (keysym == XKB_KEY_NoSymbol) {
ELOG("Could not translate string to key symbol: \"%s\"\n",
bind->symbol);
continue;
}
/*
- * Runs the given binding and handles parse errors. Returns a CommandResult for
- * running the binding's command. Caller should render tree if
- * needs_tree_render is true. Free with command_result_free().
+ * Runs the given binding and handles parse errors. If con is passed, it will
+ * execute the command binding with that container selected by criteria.
+ * Returns a CommandResult for running the binding's command. Caller should
+ * render tree if needs_tree_render is true. Free with command_result_free().
*
*/
-CommandResult *run_binding(Binding *bind) {
+CommandResult *run_binding(Binding *bind, Con *con) {
+ char *command;
+
/* We need to copy the command since “reload” may be part of the command,
* and then the memory that bind->command points to may not contain the
* same data anymore. */
- char *command_copy = sstrdup(bind->command);
- CommandResult *result = parse_command(command_copy, NULL);
- free(command_copy);
+ if (con == NULL)
+ command = sstrdup(bind->command);
+ else
+ sasprintf(&command, "[con_id=\"%d\"] %s", con, bind->command);
+
+ CommandResult *result = parse_command(command, NULL);
+ free(command);
if (result->needs_tree_render)
tree_render();