summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2010-11-09 21:11:29 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-11-09 22:13:19 +0800
commitc297f4d9b4029805d7dbf7b6367f6e714f7f2e83 (patch)
treeef69c3b4a878a2b6d7e7501368652903674a527b
parent7302b672e62fa89f2f4b86a01326f5e2cc132ced (diff)
downloadmobilebling-c297f4d9b4029805d7dbf7b6367f6e714f7f2e83.tar.gz
mobilebling-c297f4d9b4029805d7dbf7b6367f6e714f7f2e83.tar.bz2
[PATCH] Be a little bit more clever when handing option construction in handleActionEvent.
Previously we would have a static CompAction::Vector which we would resize to lower sizes (so that triggerFooBindings doesn't die) but this causes us to be reconstruction CompOptions all the time which is expensive. Instead just reset the option to make it "dead" (eg keep it in memory for longer) but don't create and recreate them all the time Also copy the active state of a CompAction on copy-construct
-rw-r--r--include/core/option.h8
-rw-r--r--src/action.cpp3
-rw-r--r--src/event.cpp25
-rw-r--r--src/option.cpp15
-rw-r--r--src/privateoption.h2
5 files changed, 30 insertions, 23 deletions
diff --git a/include/core/option.h b/include/core/option.h
index 09cf033..934a133 100644
--- a/include/core/option.h
+++ b/include/core/option.h
@@ -64,7 +64,7 @@ class CompOption {
/* internal use only */
TypeUnset
} Type;
-
+
/**
* A value of an Option
*/
@@ -126,7 +126,7 @@ class CompOption {
private:
PrivateValue *priv;
};
-
+
/**
* TODO
*/
@@ -154,7 +154,7 @@ class CompOption {
};
typedef std::vector<CompOption> Vector;
-
+
/**
* TODO
*/
@@ -176,6 +176,8 @@ class CompOption {
void setName (CompString name, Type type);
+ void reset ();
+
CompString name ();
Type type ();
diff --git a/src/action.cpp b/src/action.cpp
index 2c97244..14153c4 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -648,7 +648,8 @@ PrivateAction::PrivateAction (const PrivateAction& a) :
key (a.key),
button (a.button),
bell (a.bell),
- edgeMask (a.edgeMask)
+ edgeMask (a.edgeMask),
+ active (a.active)
{
memcpy (&priv, &a.priv, sizeof (CompPrivate));
}
diff --git a/src/event.cpp b/src/event.cpp
index 15768d1..34e3a34 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -618,7 +618,6 @@ PrivateScreen::handleActionEvent (XEvent *event)
{
static CompOption::Vector o (8);
Window xid;
- o.resize (8);
o[0].setName ("event_window", CompOption::TypeInt);
o[1].setName ("window", CompOption::TypeInt);
@@ -626,6 +625,8 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[3].setName ("x", CompOption::TypeInt);
o[4].setName ("y", CompOption::TypeInt);
o[5].setName ("root", CompOption::TypeInt);
+ o[6].reset ();
+ o[7].reset ();
switch (event->type) {
case ButtonPress:
@@ -764,8 +765,6 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[6].setName ("time", CompOption::TypeInt);
o[6].value ().set ((int) event->xcrossing.time);
-
- o.resize (7);
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
@@ -801,8 +800,6 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[6].setName ("time", CompOption::TypeInt);
o[6].value ().set ((int) event->xcrossing.time);
-
- o.resize (7);
if (triggerEdgeEnter (edge, state, o))
return true;
@@ -849,8 +846,6 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[3].value ().set ((int) 0); /* fixme */
o[4].value ().set ((int) 0); /* fixme */
o[5].value ().set ((int) root);
-
- o.resize (6);
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
@@ -895,8 +890,6 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[3].value ().set ((int) event->xclient.data.l[2] >> 16);
o[4].value ().set ((int) event->xclient.data.l[2] & 0xffff);
o[5].value ().set ((int) root);
-
- o.resize (6);
if (triggerEdgeEnter (edge, state, o))
return true;
@@ -918,10 +911,10 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[1].value ().set ((int) activeWindow);
o[2].value ().set ((int) stateEvent->mods);
- o[3] = CompOption ("time", CompOption::TypeInt);
+ o[3].setName ("time", CompOption::TypeInt);
o[3].value ().set ((int) xkbEvent->time);
-
- o.resize (4);
+ o[4].reset ();
+ o[5].reset ();
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
@@ -935,10 +928,12 @@ PrivateScreen::handleActionEvent (XEvent *event)
o[0].value ().set ((int) activeWindow);
o[1].value ().set ((int) activeWindow);
- o[2] = CompOption ("time", CompOption::TypeInt);
+ o[2].setName ("time", CompOption::TypeInt);
o[2].value ().set ((int) xkbEvent->time);
+ o[3].reset ();
+ o[4].reset ();
+ o[5].reset ();
- o.resize (3);
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
@@ -1734,7 +1729,7 @@ CompScreen::handleEvent (XEvent *event)
{
w = findWindow (((XShapeEvent *) event)->window);
if (w)
- {
+ {
if (w->mapNum ())
w->priv->updateRegion ();
}
diff --git a/src/option.cpp b/src/option.cpp
index 2de2f9e..78fdc0f 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -586,7 +586,7 @@ CompOption::Restriction::operator= (const CompOption::Restriction &rest)
{
if (this == &rest)
return *this;
-
+
delete priv;
priv = new PrivateRestriction (*rest.priv);
return *this;
@@ -692,6 +692,13 @@ CompOption::~CompOption ()
}
void
+CompOption::reset ()
+{
+ priv->name = "";
+ priv->type = TypeUnset;
+}
+
+void
CompOption::setName (CompString name, CompOption::Type type)
{
priv->name = name;
@@ -776,13 +783,13 @@ CompOption::set (CompOption::Value &val)
return false;
case CompOption::TypeKey:
- if (val.action ().type () == value().action ().type () &&
+ if (val.action ().type () == value().action ().type () &&
!(val.action ().type () & CompAction::BindingTypeKey))
return false;
break;
case CompOption::TypeButton:
- if (val.action ().type () == value().action ().type () &&
+ if (val.action ().type () == value().action ().type () &&
!(val.action ().type () & (CompAction::BindingTypeButton |
CompAction::BindingTypeEdgeButton)))
return false;
@@ -808,7 +815,7 @@ CompOption::operator= (const CompOption &option)
{
if (this == &option)
return *this;
-
+
delete priv;
priv = new PrivateOption (*option.priv);
return *this;
diff --git a/src/privateoption.h b/src/privateoption.h
index 1749554..0b00fb0 100644
--- a/src/privateoption.h
+++ b/src/privateoption.h
@@ -78,6 +78,8 @@ class PrivateValue {
CompMatch match;
CompOption::Type listType;
CompOption::Value::Vector list;
+
+ bool active;
};
class PrivateOption