diff options
author | Danny Baumann <dannybaumann@web.de> | 2010-11-09 21:11:29 +0800 |
---|---|---|
committer | Sam Spilsbury <sam.spilsbury@canonical.com> | 2010-11-09 21:13:21 +0800 |
commit | 267b9d12b6f8cc4218a761c2a7e92ca350b7f6a6 (patch) | |
tree | c51b378c2803b4edcf55e2ca507a56fb6be98e5d /src | |
parent | 46db42b1107f2ff3dd641ba3b5f8d18088a08bfb (diff) | |
download | unity-window-decorator-267b9d12b6f8cc4218a761c2a7e92ca350b7f6a6.tar.gz unity-window-decorator-267b9d12b6f8cc4218a761c2a7e92ca350b7f6a6.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
Diffstat (limited to 'src')
-rw-r--r-- | src/action.cpp | 3 | ||||
-rw-r--r-- | src/event.cpp | 25 | ||||
-rw-r--r-- | src/option.cpp | 15 | ||||
-rw-r--r-- | src/privateoption.h | 2 |
4 files changed, 25 insertions, 20 deletions
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 |