* vim:ts=4:sw=4:expandtab
*
*/
+#undef I3__FILE__
+#define I3__FILE__ "cfgparse.y"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include "all.h"
+bool force_old_config_parser = false;
+
static pid_t configerror_pid = -1;
static Match current_match;
strncasecmp(bind, "focus down", strlen("focus down")) == 0 ||
strncasecmp(bind, "border normal", strlen("border normal")) == 0 ||
strncasecmp(bind, "border 1pixel", strlen("border 1pixel")) == 0 ||
+ strncasecmp(bind, "border pixel", strlen("border pixel")) == 0 ||
strncasecmp(bind, "border borderless", strlen("border borderless")) == 0 ||
strncasecmp(bind, "--no-startup-id", strlen("--no-startup-id")) == 0 ||
strncasecmp(bind, "bar", strlen("bar")) == 0) {
/* Check if the keycodes or modifiers are different. If so, they
* can't be duplicate */
if (bind->keycode != current->keycode ||
- bind->mods != current->mods)
+ bind->mods != current->mods ||
+ bind->release != current->release)
continue;
+
context->has_errors = true;
if (current->keycode != 0) {
ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
}
}
- /* now lex/parse it */
- yy_scan_string(new);
context = scalloc(sizeof(struct context));
context->filename = f;
- if (yyparse() != 0) {
- fprintf(stderr, "Could not parse configfile\n");
- exit(1);
+ if (force_old_config_parser) {
+ /* now lex/parse it */
+ yy_scan_string(new);
+ if (yyparse() != 0) {
+ fprintf(stderr, "Could not parse configfile\n");
+ exit(1);
+ }
+ } else {
+ struct ConfigResult *config_output = parse_config(new, context);
+ yajl_gen_free(config_output->json_gen);
}
check_for_duplicate_bindings(context);
start_configerror_nagbar(f);
}
- yylex_destroy();
+ if (force_old_config_parser)
+ yylex_destroy();
FREE(context->line_copy);
free(context);
FREE(font_pattern);
%token <color> TOKCOLOR
%token TOKARROW "→"
%token TOKMODE "mode"
+%token TOK_TIME_MS "ms"
%token TOK_BAR "bar"
%token TOK_ORIENTATION "default_orientation"
%token TOK_HORIZ "horizontal"
%token TOKNEWFLOAT "new_float"
%token TOK_NORMAL "normal"
%token TOK_NONE "none"
+%token TOK_PIXEL "pixel"
%token TOK_1PIXEL "1pixel"
+%token TOK_HIDE_EDGE_BORDERS "hide_edge_borders"
+%token TOK_BOTH "both"
%token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
%token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
%token TOK_FORCE_XINERAMA "force_xinerama"
%token TOK_FAKE_OUTPUTS "fake_outputs"
%token TOK_WORKSPACE_AUTO_BAF "workspace_auto_back_and_forth"
+%token TOK_WORKSPACE_URGENCY_TIMER "force_display_urgency_hint"
%token TOKWORKSPACEBAR "workspace_bar"
%token TOK_DEFAULT "default"
%token TOK_STACKING "stacking"
%token TOK_BAR_COLOR_INACTIVE_WORKSPACE "inactive_workspace"
%token TOK_BAR_COLOR_URGENT_WORKSPACE "urgent_workspace"
%token TOK_NO_STARTUP_ID "--no-startup-id"
+%token TOK_RELEASE "--release"
%token TOK_MARK "mark"
%token TOK_CLASS "class"
%type <number> layout_mode
%type <number> border_style
%type <number> new_window
+%type <number> hide_edge_borders
+%type <number> edge_hiding_mode
%type <number> new_float
%type <number> colorpixel
%type <number> bool
%type <number> bar_mode_mode
%type <number> bar_modifier_modifier
%type <number> optional_no_startup_id
+%type <number> optional_border_width
+%type <number> optional_release
%type <string> command
%type <string> word_or_number
+%type <string> duration
%type <string> qstring_or_number
%type <string> optional_workspace_name
%type <string> workspace_name
| workspace_layout
| new_window
| new_float
+ | hide_edge_borders
| focus_follows_mouse
| force_focus_wrapping
| force_xinerama
| fake_outputs
+ | force_display_urgency_hint
| workspace_back_and_forth
| workspace_bar
| workspace
;
bindcode:
- binding_modifiers NUMBER command
+ optional_release binding_modifiers NUMBER command
{
- printf("\tFound keycode binding mod%d with key %d and command %s\n", $1, $2, $3);
+ DLOG("bindcode: release = %d, mod = %d, key = %d, command = %s\n", $1, $2, $3, $4);
Binding *new = scalloc(sizeof(Binding));
- new->keycode = $2;
- new->mods = $1;
- new->command = $3;
+ new->release = $1;
+ new->keycode = $3;
+ new->mods = $2;
+ new->command = $4;
$$ = new;
}
;
bindsym:
- binding_modifiers word_or_number command
+ optional_release binding_modifiers word_or_number command
{
- printf("\tFound keysym binding mod%d with key %s and command %s\n", $1, $2, $3);
+ DLOG("bindsym: release = %d, mod = %d, key = %s, command = %s\n", $1, $2, $3, $4);
Binding *new = scalloc(sizeof(Binding));
- new->symbol = $2;
- new->mods = $1;
- new->command = $3;
+ new->release = $1;
+ new->symbol = $3;
+ new->mods = $2;
+ new->command = $4;
$$ = new;
}
;
+optional_release:
+ /* empty */ { $$ = B_UPON_KEYPRESS; }
+ | TOK_RELEASE { $$ = B_UPON_KEYRELEASE; }
+ ;
+
for_window:
TOK_FOR_WINDOW match command
{
}
;
+duration:
+ NUMBER { sasprintf(&$$, "%d", $1); }
+ | NUMBER TOK_TIME_MS { sasprintf(&$$, "%d", $1); }
+ ;
+
mode:
TOKMODE QUOTEDSTRING '{' modelines '}'
{
;
border_style:
- TOK_NORMAL { $$ = BS_NORMAL; }
- | TOK_NONE { $$ = BS_NONE; }
- | TOK_1PIXEL { $$ = BS_1PIXEL; }
+ TOK_NORMAL optional_border_width
+ {
+ /* FIXME: the whole border_style thing actually screws up when new_float is used because it overwrites earlier values :-/ */
+ config.default_border_width = $2;
+ $$ = BS_NORMAL;
+ }
+ | TOK_1PIXEL
+ {
+ config.default_border_width = 1;
+ $$ = BS_PIXEL;
+ }
+ | TOK_NONE
+ {
+ config.default_border_width = 0;
+ $$ = BS_NONE;
+ }
+ | TOK_PIXEL optional_border_width
+ {
+ config.default_border_width = $2;
+ $$ = BS_PIXEL;
+ }
;
bool:
}
;
+hide_edge_borders:
+ TOK_HIDE_EDGE_BORDERS edge_hiding_mode
+ {
+ DLOG("hide edge borders = %d\n", $2);
+ config.hide_edge_borders = $2;
+ }
+ ;
+
+edge_hiding_mode:
+ TOK_NONE { $$ = ADJ_NONE; }
+ | TOK_VERT { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE; }
+ | TOK_HORIZ { $$ = ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
+ | TOK_BOTH { $$ = ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE | ADJ_UPPER_SCREEN_EDGE | ADJ_LOWER_SCREEN_EDGE; }
+ | bool { $$ = ($1 ? ADJ_LEFT_SCREEN_EDGE | ADJ_RIGHT_SCREEN_EDGE : ADJ_NONE); }
+ ;
+
focus_follows_mouse:
TOKFOCUSFOLLOWSMOUSE bool
{
}
;
+force_display_urgency_hint:
+ TOK_WORKSPACE_URGENCY_TIMER duration
+ {
+ DLOG("workspace urgency_timer = %f\n", atoi($2) / 1000.0);
+ config.workspace_urgency_timer = atoi($2) / 1000.0;
+ }
+ ;
+
workspace_bar:
TOKWORKSPACEBAR bool
{
}
;
+optional_border_width:
+ /* empty */ { $$ = 2; } // 2 pixels is the default value for any type of border
+ | NUMBER { $$ = $1; }
+ ;
+
optional_no_startup_id:
/* empty */ { $$ = false; }
| TOK_NO_STARTUP_ID { $$ = true; }