X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=util%2Fepist%2Factions.cc;h=c4874983e51e50119d34a59bceca74ac385c1c88;hb=e5e886bc0f865d0542d652aaa5bdd6b39396e9c3;hp=d4beaacb7df62aa9d53ca866ae8a2330c0093e94;hpb=be77122bee3300e982ff257929ce1d1224f45803;p=chaz%2Fopenbox diff --git a/util/epist/actions.cc b/util/epist/actions.cc index d4beaacb..c4874983 100644 --- a/util/epist/actions.cc +++ b/util/epist/actions.cc @@ -22,6 +22,37 @@ #include "actions.hh" -Action::Action(enum ActionType type, KeyCode keycode, int modifierMask): - _type(type), _keycode(keycode), _modifierMask(modifierMask) -{ } +Action::Action(enum ActionType type, KeyCode keycode, unsigned int modifierMask, + const std::string &str) + : _type(type), _keycode(keycode), _modifierMask(modifierMask) +{ + // These are the action types that take string arguments. This + // should probably be moved to a static member + ActionType str_types[] = { + execute, + nextWindowOfClass, + prevWindowOfClass, + nextWindowOfClassOnAllWorkspaces, + prevWindowOfClassOnAllWorkspaces, + noaction + }; + + 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); + return; + } + } + + _numberParam = atoi( str.c_str() ); + + // workspace 1 to the user is workspace 0 to us + if (type == changeWorkspace || type == sendToWorkspace) + _numberParam--; +}