summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/action.cpp37
-rw-r--r--src/match.cpp30
-rw-r--r--src/option.cpp49
3 files changed, 58 insertions, 58 deletions
diff --git a/src/action.cpp b/src/action.cpp
index 2e33491..c13a8ff 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -72,7 +72,7 @@ struct _Edge {
static CompString
modifiersToString (unsigned int modMask)
{
- CompString binding = "";
+ CompString binding;
for (unsigned int i = 0; i < N_MODIFIERS; i++)
{
@@ -112,8 +112,8 @@ bindingStringToEdgeMask (CompString str)
static CompString
edgeMaskToBindingString (unsigned int edgeMask)
{
- CompString binding = "";
- int i;
+ CompString binding;
+ int i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
if (edgeMask & (1 << i))
@@ -185,8 +185,9 @@ CompAction::KeyBinding::fromString (const CompString &str)
return false;
}
- sStr = str.substr (pos);
+ sStr = str.substr (pos);
keysym = XStringToKeysym (sStr.c_str ());
+
if (keysym != NoSymbol)
{
KeyCode keycode;
@@ -215,7 +216,7 @@ CompAction::KeyBinding::fromString (const CompString &str)
CompString
CompAction::KeyBinding::toString () const
{
- CompString binding = "";
+ CompString binding;
if (!screen)
return "";
@@ -231,13 +232,9 @@ CompAction::KeyBinding::toString () const
keyname = XKeysymToString (keysym);
if (keyname)
- {
binding += keyname;
- }
else
- {
binding += compPrintf ("0x%x", mKeycode);
- }
}
return binding;
@@ -288,7 +285,8 @@ CompAction::ButtonBinding::fromString (const CompString &str)
while (pos < str.size () && !isalnum (str[pos]))
pos++;
- if (pos != std::string::npos && pos != str.size () &&
+ if (pos != std::string::npos &&
+ pos != str.size () &&
str.compare (pos, 6, "Button") == 0)
{
int buttonNum;
@@ -382,13 +380,9 @@ CompAction::setKey (const CompAction::KeyBinding &key)
priv->key = key;
if (key.modifiers () || key.keycode ())
- {
priv->type = CompAction::BindingTypeKey;
- }
else
- {
priv->type = CompAction::BindingTypeNone;
- }
}
CompAction::ButtonBinding &
@@ -413,7 +407,6 @@ CompAction::setButton (const CompAction::ButtonBinding &button)
{
priv->type = CompAction::BindingTypeNone;
}
-
}
unsigned int
@@ -458,9 +451,10 @@ CompAction::setState (CompAction::State state)
void
CompAction::copyState (const CompAction &action)
{
- priv->initiate = action.priv->initiate;
+ priv->initiate = action.priv->initiate;
priv->terminate = action.priv->terminate;
- priv->state = action.priv->state;
+ priv->state = action.priv->state;
+
memcpy (&priv->priv, &action.priv->priv, sizeof (CompPrivate));
}
@@ -494,6 +488,7 @@ CompAction::operator= (const CompAction &action)
{
delete priv;
priv = new PrivateAction (*action.priv);
+
return *this;
}
@@ -576,7 +571,7 @@ CompAction::keyToString ()
CompString binding;
binding = priv->key.toString ();
- if (binding.size () == 0)
+ if (!binding.size ())
return "Disabled";
return binding;
@@ -585,14 +580,14 @@ CompAction::keyToString ()
CompString
CompAction::buttonToString ()
{
- CompString binding = "", edge = "";
+ CompString binding, edge;
binding = modifiersToString (priv->button.modifiers ());
binding += edgeMaskToBindingString (priv->edgeMask);
binding += compPrintf ("Button%d", priv->button.button ());
- if (priv->button.button () == 0)
+ if (!priv->button.button ())
return "Disabled";
return binding;
@@ -621,7 +616,7 @@ CompAction::edgeMaskToString ()
CompString
CompAction::edgeToString (unsigned int edge)
{
- return CompString (edges[edge].name);
+ return edges[edge].name;
}
PrivateAction::PrivateAction () :
diff --git a/src/match.cpp b/src/match.cpp
index 7759e49..fd4b6c1 100644
--- a/src/match.cpp
+++ b/src/match.cpp
@@ -160,8 +160,6 @@ CompScreen::matchPropertyChanged (CompWindow *w)
WRAPABLE_HND_FUNC(12, matchPropertyChanged, w)
}
-
-
static void
matchResetOps (MatchOp::List &list)
{
@@ -175,10 +173,7 @@ matchResetOps (MatchOp::List &list)
case MatchOp::TypeExp:
exp = dynamic_cast <MatchExpOp *> (op);
if (exp && exp->e)
- {
-
exp->e.reset ();
- }
break;
default:
break;
@@ -190,11 +185,10 @@ static bool
matchOpsEqual (MatchOp::List &list1,
MatchOp::List &list2)
{
+ MatchGroupOp *g1, *g2;
+ MatchExpOp *e1, *e2;
MatchOp::List::iterator it1 = list1.begin (), it2 = list2.begin ();
- MatchGroupOp *g1, *g2;
- MatchExpOp *e1, *e2;
-
if (list1.size () != list2.size ())
return false;
@@ -234,7 +228,6 @@ matchOpsEqual (MatchOp::List &list1,
return true;
}
-
static unsigned int
nextIndex (CompString &str,
unsigned int i)
@@ -246,7 +239,6 @@ nextIndex (CompString &str,
return i;
}
-
static CompString
strndupValue (CompString str)
{
@@ -398,7 +390,9 @@ matchOpsToString (MatchOp::List &list)
{
switch (op->type ()) {
case MatchOp::TypeGroup:
- group = matchOpsToString (dynamic_cast <MatchGroupOp *> (op)->op);
+ group =
+ matchOpsToString (dynamic_cast <MatchGroupOp *> (op)->op);
+
if (group.length ())
{
if (value.length ())
@@ -412,14 +406,12 @@ matchOpsToString (MatchOp::List &list)
}
break;
case MatchOp::TypeExp:
-
if (value.length ())
- {
- value += ((op->flags & MATCH_OP_AND_MASK) ?
- "& " : "| ");
- }
+ value += ((op->flags & MATCH_OP_AND_MASK) ? "& " : "| ");
+
if (op->flags & MATCH_OP_NOT_MASK)
value += "!";
+
value += dynamic_cast <MatchExpOp *> (op)->value;
value += " ";
break;
@@ -480,7 +472,8 @@ matchEvalOps (MatchOp::List &list,
switch (op->type ()) {
case MatchOp::TypeGroup:
- value = matchEvalOps (dynamic_cast <MatchGroupOp *> (op)->op, w);
+ value =
+ matchEvalOps (dynamic_cast <MatchGroupOp *> (op)->op, w);
break;
case MatchOp::TypeExp:
exp = dynamic_cast <MatchExpOp *> (op);
@@ -681,9 +674,11 @@ const CompMatch &
CompMatch::operator! ()
{
MatchGroupOp *g = new MatchGroupOp (priv->op);
+
g->flags ^= MATCH_OP_NOT_MASK;
priv->op = MatchGroupOp ();
priv->op.op.push_back (g);
+
return *this;
}
@@ -692,6 +687,7 @@ CompMatch::operator= (const CompString &str)
{
priv->op = MatchGroupOp ();
matchAddFromString (priv->op.op, str);
+
return *this;
}
diff --git a/src/option.cpp b/src/option.cpp
index 66b76cb..f50b452 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -255,42 +255,54 @@ CompOption::Value::operator== (const CompOption::Value &val)
{
if (priv->type != val.priv->type)
return false;
+
switch (priv->type)
{
case CompOption::TypeBool:
return priv->value.b == val.priv->value.b;
break;
+
case CompOption::TypeInt:
return priv->value.i == val.priv->value.i;
break;
+
case CompOption::TypeFloat:
return priv->value.f == val.priv->value.f;
break;
+
case CompOption::TypeColor:
return (priv->value.c[0] == val.priv->value.c[0]) &&
(priv->value.c[1] == val.priv->value.c[1]) &&
(priv->value.c[2] == val.priv->value.c[2]) &&
(priv->value.c[3] == val.priv->value.c[3]);
break;
+
case CompOption::TypeString:
return priv->string.compare (val.priv->string) == 0;
break;
+
case CompOption::TypeMatch:
return priv->match == val.priv->match;
break;
+
case CompOption::TypeAction:
return priv->action == val.priv->action;
break;
+
case CompOption::TypeList:
if (priv->listType != val.priv->listType)
return false;
+
if (priv->list.size () != val.priv->list.size ())
return false;
+
for (unsigned int i = 0; i < priv->list.size (); i++)
if (priv->list[i] != val.priv->list[i])
return false;
+
return true;
break;
+
default:
break;
}
@@ -309,6 +321,7 @@ CompOption::Value::operator= (const CompOption::Value &val)
{
delete priv;
priv = new PrivateValue (*val.priv);
+
return *this;
}
@@ -462,7 +475,6 @@ CompOption::Restriction::operator= (const CompOption::Restriction &rest)
return *this;
}
-
CompOption *
CompOption::findOption (CompOption::Vector &options,
CompString name,
@@ -511,12 +523,15 @@ finiScreenOptionValue (CompScreen *s,
case CompOption::TypeButton:
case CompOption::TypeEdge:
case CompOption::TypeBell:
-if (v.action ().state () & CompAction::StateAutoGrab)
+ if (v.action ().state () & CompAction::StateAutoGrab)
s->removeAction (&v.action ());
break;
+
case CompOption::TypeList:
foreach (CompOption::Value &val, v.list ())
finiScreenOptionValue (s, val, v.listType ());
+ break;
+
default:
break;
}
@@ -533,13 +548,14 @@ finiOptionValue (CompOption::Value &v,
case CompOption::TypeEdge:
case CompOption::TypeBell:
if (v.action ().state () & CompAction::StateAutoGrab && screen)
- {
screen->removeAction (&v.action ());
- }
break;
+
case CompOption::TypeList:
foreach (CompOption::Value &val, v.list ())
finiOptionValue (val, v.listType ());
+ break;
+
default:
break;
}
@@ -585,10 +601,7 @@ CompOption::rest ()
bool
CompOption::set (CompOption::Value &val)
{
- if (priv->type == CompOption::TypeKey ||
- priv->type == CompOption::TypeButton ||
- priv->type == CompOption::TypeEdge ||
- priv->type == CompOption::TypeBell)
+ if (isAction () && priv->type != CompOption::TypeAction)
val.action ().copyState (priv->value.action ());
if (priv->value == val)
@@ -598,21 +611,18 @@ CompOption::set (CompOption::Value &val)
priv->value.action ().state () & CompAction::StateAutoGrab && screen)
{
if (!screen->addAction (&val.action ()))
- {
return false;
- }
else
- {
screen->removeAction (&priv->value.action ());
- }
}
switch (priv->type)
{
- case CompOption::TypeInt:
+ case CompOption::TypeInt:
if (!priv->rest.inRange (val.i ()))
return false;
break;
+
case CompOption::TypeFloat:
{
float v, p;
@@ -627,21 +637,27 @@ CompOption::set (CompOption::Value &val)
priv->value.set (v);
return true;
}
+
case CompOption::TypeAction:
return false;
+
case CompOption::TypeKey:
if (!(val.action ().type () & CompAction::BindingTypeKey))
return false;
break;
+
case CompOption::TypeButton:
if (!(val.action ().type () & (CompAction::BindingTypeButton |
CompAction::BindingTypeEdgeButton)))
return false;
break;
+
default:
break;
}
+
priv->value = val;
+
return true;
}
@@ -670,7 +686,6 @@ CompOption::operator= (const CompOption &option)
return *this;
}
-
bool
CompOption::getBoolOptionNamed (const Vector& options,
const CompString& name,
@@ -695,7 +710,6 @@ CompOption::getIntOptionNamed (const Vector& options,
return defaultValue;
}
-
float
CompOption::getFloatOptionNamed (const Vector& options,
const CompString& name,
@@ -708,7 +722,6 @@ CompOption::getFloatOptionNamed (const Vector& options,
return defaultValue;
}
-
CompString
CompOption::getStringOptionNamed (const Vector& options,
const CompString& name,
@@ -721,7 +734,6 @@ CompOption::getStringOptionNamed (const Vector& options,
return defaultValue;
}
-
unsigned short *
CompOption::getColorOptionNamed (const Vector& options,
const CompString& name,
@@ -734,7 +746,6 @@ CompOption::getColorOptionNamed (const Vector& options,
return defaultValue;
}
-
CompMatch
CompOption::getMatchOptionNamed (const Vector& options,
const CompString& name,
@@ -747,8 +758,6 @@ CompOption::getMatchOptionNamed (const Vector& options,
return defaultValue;
}
-
-
bool
CompOption::stringToColor (CompString color,
unsigned short *rgba)