]> git.sur5r.net Git - i3/i3/blobdiff - src/cfgparse.y
naive implementation of 'bindsym --release' (and bindcode)
[i3/i3] / src / cfgparse.y
index a2f1b9f4cf2ad8248d733dcac511c4c0175ddabb..5c1667784cd44aacdb80e64313150f12d5f67a09 100644 (file)
@@ -3,6 +3,8 @@
  * 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>
@@ -736,6 +738,7 @@ void parse_file(const char *f) {
 %token                  TOK_NONE                    "none"
 %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"
@@ -781,6 +784,7 @@ void parse_file(const char *f) {
 %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"
@@ -800,6 +804,8 @@ void parse_file(const char *f) {
 %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
@@ -808,6 +814,7 @@ void parse_file(const char *f) {
 %type   <number>        bar_mode_mode
 %type   <number>        bar_modifier_modifier
 %type   <number>        optional_no_startup_id
+%type   <number>        optional_release
 %type   <string>        command
 %type   <string>        word_or_number
 %type   <string>        qstring_or_number
@@ -876,33 +883,40 @@ binding:
     ;
 
 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 */ { $$ = false; }
+    | TOK_RELEASE  { $$ = true; }
+    ;
+
 for_window:
     TOK_FOR_WINDOW match command
     {
@@ -1477,13 +1491,21 @@ bool:
     ;
 
 hide_edge_borders:
-    TOK_HIDE_EDGE_BORDERS bool
+    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
     {