summaryrefslogtreecommitdiff
path: root/src/action.cpp
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-03-05 20:14:07 +0100
committerDanny Baumann <dannybaumann@web.de>2009-03-05 20:14:07 +0100
commit54097c5b8ff7a3c28475afcafefd73d388e790b6 (patch)
treee1c3fb9ce44b8718287db3023d3cc4b14f3ccbe1 /src/action.cpp
parent8e0ea73acc3fd7b9057067a3bb6edcca353e39a6 (diff)
downloadunity-window-decorator-54097c5b8ff7a3c28475afcafefd73d388e790b6.tar.gz
unity-window-decorator-54097c5b8ff7a3c28475afcafefd73d388e790b6.tar.bz2
Fix parsing of button and key strings.
Diffstat (limited to 'src/action.cpp')
-rw-r--r--src/action.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/action.cpp b/src/action.cpp
index c13a8ff..04cd3aa 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -157,7 +157,7 @@ CompAction::KeyBinding::fromString (const CompString &str)
{
CompString sStr;
unsigned int mods;
- size_t pos;
+ size_t pos, start = 0;
KeySym keysym;
if (!screen)
@@ -167,12 +167,12 @@ CompAction::KeyBinding::fromString (const CompString &str)
pos = str.rfind ('>');
if (pos != std::string::npos)
- pos++;
+ start = pos + 1;
- while (pos < str.size () && !isalnum (str[pos]))
- pos++;
+ while (start < str.size () && !isalnum (str[start]))
+ start++;
- if (pos == std::string::npos || pos == str.size ())
+ if (start == str.size ())
{
if (mods)
{
@@ -185,7 +185,7 @@ CompAction::KeyBinding::fromString (const CompString &str)
return false;
}
- sStr = str.substr (pos);
+ sStr = str.substr (start);
keysym = XStringToKeysym (sStr.c_str ());
if (keysym != NoSymbol)
@@ -274,24 +274,22 @@ bool
CompAction::ButtonBinding::fromString (const CompString &str)
{
unsigned int mods;
- size_t pos;
+ size_t pos, start = 0;
mods = stringToModifiers (str);
pos = str.rfind ('>');
if (pos != std::string::npos)
- pos++;
+ start = pos + 1;
- while (pos < str.size () && !isalnum (str[pos]))
- pos++;
+ while (start < str.size () && !isalnum (str[start]))
+ start++;
- if (pos != std::string::npos &&
- pos != str.size () &&
- str.compare (pos, 6, "Button") == 0)
+ if (start != str.size () && str.compare (start, 6, "Button") == 0)
{
int buttonNum;
- if (sscanf (str.substr (pos + 6).c_str (), "%d", &buttonNum) == 1)
+ if (sscanf (str.substr (start + 6).c_str (), "%d", &buttonNum) == 1)
{
mButton = buttonNum;
mModifiers = mods;