]> Dogcows Code - chaz/openbox/commitdiff
A few bug fixes and change the config to case insensitive and be more
authorScott Moynes <smoynes@nexus.carleton.ca>
Thu, 8 Aug 2002 03:10:54 +0000 (03:10 +0000)
committerScott Moynes <smoynes@nexus.carleton.ca>
Thu, 8 Aug 2002 03:10:54 +0000 (03:10 +0000)
tolerant of errors.

util/epist/actions.cc
util/epist/epist.l
util/epist/epist.y
util/epist/keytree.cc
util/epist/parser.cc
util/epist/parser.hh

index c4874983e51e50119d34a59bceca74ac385c1c88..7a895be75e957ea5e74ab1a516850bcd3932f839 100644 (file)
@@ -39,17 +39,11 @@ Action::Action(enum ActionType type, KeyCode keycode, unsigned int modifierMask,
 
   for (int i = 0; str_types[i] != noaction; ++i) {
     if (type == str_types[i]) {
-      // the first and last characters of the string are quotes, and we need to
-      // get rid of them
-      assert(str.size() >= 2);
-      assert(str[0] == '"');
-      assert(str[str.size() - 1] == '"');
-
-      _stringParam = str.substr(1, str.size() - 2);
+      _stringParam = str;
       return;
     }
   }
-  
   _numberParam = atoi( str.c_str() );
 
   // workspace 1 to the user is workspace 0 to us
index 5a96e39d0cc94b9235b4759783f07eca0a65f2bc..146d4b0eb71d1796bb591e0b8a7bf53b27fe9022 100644 (file)
@@ -2,6 +2,9 @@
 #include <stdio.h>
 #include <string.h>
 #include "yacc_parser.hh"
+
+extern YYSTYPE yylval;
+    
 %}
 
 %%
 \}                  return EBRACE;
 ;                   return SEMICOLON;
 -                   return DASH;
-noaction |
-execute |
-iconify |
-raise |
-lower |
-close |
-toggleshade |
-toggleomnipresent |
-moveWindowUp |
-moveWindowDown |
-moveWindowLeft |
-moveWindowRight |
-resizeWindowWidth |
-resizeWindowHeight |
-toggleMaximizeFull |
-toggleMaximizeVertical |
-toggleMaximizeHorizontal |
-sendToWorkspace |
-nextWindow |
-prevWindow |
-nextWindowOnAllWorkspaces |
-prevWindowOnAllWorkspaces |
-nextWindowOnAllScreens |
-prevWindowOnAllScreens |
-nextWindowOfClass |
-prevWindowOfClass |
-nextWindowOfClassOnAllWorkspaces |
-prevWindowOfClassOnAllWorkspaces |
-changeWorkspace |
-nextWorkspace |
-prevWorkspace |
-nextScreen |
-prevScreen |
-showRootMenu |
-showWorkspaceMenu |
-stringChain |
-keyChain |
-numberChain |
-cancel              yylval = (int) strdup(yytext); return ACTION;
 Mod1 |
 Mod2 |
 Mod3 |
index 60fe9aaaa9f88519b3919dc4423f019276202bb5..c1bf196dcdb748de4156a65d96fc70fd297f515f 100644 (file)
@@ -20,7 +20,7 @@ void yyerror(const char *c) {
 
 %}
 
-%token OBRACE EBRACE SEMICOLON DASH ACTION BINDING NUMBER QUOTES WORD  
+%token OBRACE EBRACE SEMICOLON DASH NUMBER QUOTES WORD BINDING 
 
 %%
 
@@ -33,7 +33,7 @@ command:
     ;
 
 action_command:
-    binding ACTION parameter SEMICOLON
+    binding WORD parameter SEMICOLON
     {
         ((parser*)parser_obj)->setAction($2);
         ((parser*)parser_obj)->endAction();
@@ -59,7 +59,7 @@ obrace:
 ebrace:
     EBRACE { /* ((parser*)parser_obj)->endChain(); */ }
     ;
-    
+
 binding_w_modifier:
     | BINDING DASH binding_w_modifier { ((parser*)parser_obj)->addModifier($1); }
     ;
@@ -72,11 +72,11 @@ bind_key:
     | NUMBER     { ((parser*)parser_obj)->setKey($1); }
     | WORD       { ((parser*)parser_obj)->setKey($1); }
     ;
-    
+
 parameter:
-    | NUMBER      { ((parser*)parser_obj)->setArgument($1); }
-    | DASH NUMBER { ((parser*)parser_obj)->setArgument($1); }
-    | QUOTES      { ((parser*)parser_obj)->setArgument($1); }
+    | NUMBER      { ((parser*)parser_obj)->setArgumentNum($1); }
+    | DASH NUMBER { ((parser*)parser_obj)->setArgumentNegNum($2); }
+    | QUOTES      { ((parser*)parser_obj)->setArgumentStr($1); }
     ;
 
 %%
index cf0dd379ea148be1faca259b1b3834683efa8e94..7c954c510eaa19d475da18db91ababe6abcb8a42 100644 (file)
@@ -69,10 +69,31 @@ void keytree::grabChildren(keynode *node, screen *scr)
 
 void keytree::ungrabChildren(keynode *node, screen *scr)
 {
+  ChildList::const_iterator head_it, head_end = _head->children.end();
   ChildList::const_iterator it, end = node->children.end();
-  for (it = node->children.begin(); it != end; ++it)
-    if ( (*it)->action )
-      scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask());
+  bool ungrab = true;
+  // when ungrabbing children, make sure that we don't ungrab any topmost keys
+  // (children of the head node) This would render those topmost keys useless.
+  // Topmost keys are _never_ ungrabbed, since they are only grabbed at startup
+  
+  for (it = node->children.begin(); it != end; ++it) {
+    if ( (*it)->action ) {
+      for (head_it = _head->children.begin(); head_it != head_end; ++head_it) {
+        if ( (*it)->action->modifierMask() == (*head_it)->action->modifierMask() &&
+             (*it)->action->keycode() == (*head_it)->action->keycode())
+        {
+          ungrab = false;
+          break;
+        }
+      }
+      
+      if (ungrab) 
+        scr->ungrabKey( (*it)->action->keycode(), (*it)->action->modifierMask());
+      
+      ungrab = true;
+    }
+  }
 }
 
 const Action * keytree::getAction(const XEvent &e, unsigned int state,
@@ -80,6 +101,7 @@ const Action * keytree::getAction(const XEvent &e, unsigned int state,
 {
   Action *act;
 
+  // we're done with the children. ungrab them
   if (_current != _head)
     ungrabChildren(_current, scr);
   
@@ -88,17 +110,20 @@ const Action * keytree::getAction(const XEvent &e, unsigned int state,
     act = (*it)->action;
     if (e.xkey.keycode == act->keycode() && state == act->modifierMask()) {
       if ( isLeaf(*it) ) {
-       _current = _head;
-       return act;
+        // node is a leaf, so an action will be executed
+        _current = _head;
+        return act;
       }
       else {
-       _current = *it;
-       grabChildren(_current, scr);
-       return (const Action *)NULL;
+        // node is not a leaf, so we advance down the tree, and grab the
+        // children of the new current node. no action is executed
+        _current = *it;
+        grabChildren(_current, scr);
+        return (const Action *)NULL;
       }
     }
   }
-
+  
   // action not found. back to the head
   _current = _head;
   return (const Action *)NULL;
@@ -108,14 +133,15 @@ void keytree::addAction(Action::ActionType action, unsigned int mask,
                         string key, string arg)
 {
   // can't grab non-modifier as topmost key
+  // XXX: do we allow Esc to be grabbed at the top?
   if (_current == _head && (mask == 0 || mask == ShiftMask))
     return;
 
   keynode *tmp = new keynode;
   tmp->action = new Action(action,
-                          XKeysymToKeycode(_display,
-                                           XStringToKeysym(key.c_str())),
-                          mask, arg);
+                           XKeysymToKeycode(_display,
+                                            XStringToKeysym(key.c_str())),
+                           mask, arg);
   tmp->parent = _current;
   _current->children.push_back(tmp);
 }
@@ -140,8 +166,9 @@ void keytree::setCurrentNodeProps(Action::ActionType action, unsigned int mask,
 {
   if (_current->action)
     delete _current->action;
+  
   _current->action = new Action(action,
-                               XKeysymToKeycode(_display,
-                                                XStringToKeysym(key.c_str())),
-                               mask, arg);
+                                XKeysymToKeycode(_display,
+                                                 XStringToKeysym(key.c_str())),
+                                mask, arg);
 }
index bbf5dad12e0153c18f0c0baf729aae8549a9597c..1bea940e3b148b7293f99f3ce18d6b7b41223c9e 100644 (file)
@@ -1,14 +1,13 @@
 extern "C" {
 #include <stdio.h>
+#include <string.h>
 }
 
 #include "parser.hh"
-
 #include <string>
 
 using std::string;
 
-
 parser::parser(keytree *kt)
     : _kt(kt), _mask(0), _action(Action::noaction), _key(""), _arg("") 
 {
@@ -35,7 +34,7 @@ void parser::parse(string rc_file)
 void parser::setAction(string act)
 {
     struct {
-        string str;
+        const char* str;
         Action::ActionType act;
     }
     actions[] = {
@@ -47,36 +46,36 @@ void parser::setAction(string act)
         { "close", Action::close },
         { "toggleshade", Action::toggleshade },
         { "toggleomnipresent", Action::toggleomnipresent },
-        { "moveWindowUp", Action::moveWindowUp },
-        { "moveWindowDown", Action::moveWindowDown },
-        { "moveWindowLeft", Action::moveWindowLeft },
-        { "moveWindowRight", Action::moveWindowRight },
-        { "resizeWindowWidth", Action::resizeWindowWidth },
-        { "resizeWindowHeight", Action::resizeWindowHeight },
-        { "toggleMaximizeFull", Action::toggleMaximizeFull },
-        { "toggleMaximizeVertical", Action::toggleMaximizeVertical },
-        { "toggleMaximizeHorizontal", Action::toggleMaximizeHorizontal },
-        { "sendToWorkspace", Action::sendToWorkspace },
-        { "nextWindow", Action::nextWindow },
-        { "prevWindow", Action::prevWindow },
-        { "nextWindowOnAllWorkspaces", Action::nextWindowOnAllWorkspaces },
-        { "prevWindowOnAllWorkspaces", Action::prevWindowOnAllWorkspaces },
-        { "nextWindowOnAllScreens", Action::nextWindowOnAllScreens },
-        { "prevWindowOnAllScreens", Action::prevWindowOnAllScreens },
-        { "nextWindowOfClass", Action::nextWindowOfClass },
-        { "prevWindowOfClass", Action::prevWindowOfClass },
-        { "nextWindowOfClassOnAllWorkspaces", Action::nextWindowOfClassOnAllWorkspaces },
-        { "prevWindowOfClassOnAllWorkspaces", Action::prevWindowOfClassOnAllWorkspaces },
-        { "changeWorkspace", Action::changeWorkspace },
-        { "nextWorkspace", Action::nextWorkspace },
-        { "prevWorkspace", Action::prevWorkspace },
-        { "nextScreen", Action::nextScreen },
-        { "prevScreen", Action::prevScreen },
-        { "showRootMenu", Action::showRootMenu },
-        { "showWorkspaceMenu", Action::showWorkspaceMenu },
-        { "stringChain", Action::stringChain },
-        { "keyChain", Action::keyChain },
-        { "numberChain", Action::numberChain },
+        { "movewindowup", Action::moveWindowUp },
+        { "movewindowdown", Action::moveWindowDown },
+        { "movewindowleft", Action::moveWindowLeft },
+        { "movewindowright", Action::moveWindowRight },
+        { "resizewindowwidth", Action::resizeWindowWidth },
+        { "resizewindowheight", Action::resizeWindowHeight },
+        { "togglemaximizefull", Action::toggleMaximizeFull },
+        { "togglemaximizevertical", Action::toggleMaximizeVertical },
+        { "togglemaximizehorizontal", Action::toggleMaximizeHorizontal },
+        { "sendtoworkspace", Action::sendToWorkspace },
+        { "nextwindow", Action::nextWindow },
+        { "prevwindow", Action::prevWindow },
+        { "nextwindowonallworkspaces", Action::nextWindowOnAllWorkspaces },
+        { "prevwindowonallworkspaces", Action::prevWindowOnAllWorkspaces },
+        { "nextwindowonallscreens", Action::nextWindowOnAllScreens },
+        { "prevwindowonallscreens", Action::prevWindowOnAllScreens },
+        { "nextwindowofclass", Action::nextWindowOfClass },
+        { "prevwindowofclass", Action::prevWindowOfClass },
+        { "nextwindowofclassonallworkspaces", Action::nextWindowOfClassOnAllWorkspaces },
+        { "prevwindowofclassonallworkspaces", Action::prevWindowOfClassOnAllWorkspaces },
+        { "changeworkspace", Action::changeWorkspace },
+        { "nextworkspace", Action::nextWorkspace },
+        { "prevworkspace", Action::prevWorkspace },
+        { "nextscreen", Action::nextScreen },
+        { "prevscreen", Action::prevScreen },
+        { "showrootmenu", Action::showRootMenu },
+        { "showworkspacemenu", Action::showWorkspaceMenu },
+        { "stringchain", Action::stringChain },
+        { "keychain", Action::keyChain },
+        { "numberchain", Action::numberChain },
         { "cancel", Action::cancel },
         { "", Action::noaction }
     };
@@ -84,7 +83,7 @@ void parser::setAction(string act)
     bool found = false;
 
     for (int i = 0; actions[i].str != ""; ++i) {
-        if (actions[i].str == act) {
+        if ( strcasecmp(actions[i].str, act.c_str()) == 0 ) {
             _action = actions[i].act;
             found = true;
         }
@@ -104,6 +103,7 @@ void parser::addModifier(string mod)
         { "Mod1", Mod1Mask },
         { "Mod2", Mod2Mask },
         { "Mod3", Mod3Mask },
+        { "Mod4", Mod4Mask },
         { "Control", ControlMask },
         { "Shift", ShiftMask },
         { "", 0 }
index a66e414126ccda26a3af788dd1b5d1f76b07051f..a237053482d837821a35a5a480b80ab8f65d78db 100644 (file)
@@ -13,9 +13,15 @@ public:
     void setKey(std::string key)
     {  _key = key; }
 
-    void setArgument(std::string arg)
+    void setArgumentNum(std::string arg)
     { _arg = arg; }
 
+    void setArgumentNegNum(std::string arg)
+    { _arg = "-" + arg; }
+
+    void setArgumentStr(std::string arg)
+    { _arg = arg.substr(1, arg.size() - 2); }
+
     void setAction(std::string);
     void addModifier(std::string);
     void endAction();
This page took 0.034497 seconds and 4 git commands to generate.