summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorErkin Bahceci <erkinbah@gmail.com>2009-12-15 21:27:20 -0600
committerErkin Bahceci <erkinbah@gmail.com>2009-12-16 06:14:32 -0600
commitb873536fc62e5ad485a46be166614fed0273ed61 (patch)
treecc0e3ec51ed51f9e8e6fe6ef964a705140068f1a /plugins
parent4afcd6dc0b0b55396b01a46a6152a2af2bff9cbd (diff)
downloadcompiz-with-glib-mainloop-b873536fc62e5ad485a46be166614fed0273ed61.tar.gz
compiz-with-glib-mainloop-b873536fc62e5ad485a46be166614fed0273ed61.tar.bz2
Various minor optimizations.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/compiztoolbox/src/compiztoolbox.cpp1
-rw-r--r--plugins/switcher/src/switcher.cpp29
2 files changed, 18 insertions, 12 deletions
diff --git a/plugins/compiztoolbox/src/compiztoolbox.cpp b/plugins/compiztoolbox/src/compiztoolbox.cpp
index 1b13305..f65800e 100644
--- a/plugins/compiztoolbox/src/compiztoolbox.cpp
+++ b/plugins/compiztoolbox/src/compiztoolbox.cpp
@@ -624,7 +624,6 @@ BaseSwitchScreen::handleEvent (XEvent *event)
BaseSwitchScreen::BaseSwitchScreen (CompScreen *screen) :
cScreen (CompositeScreen::get (screen)),
gScreen (GLScreen::get (screen)),
- windows (),
popupWindow (None),
selectedWindow (NULL),
lastActiveNum (0),
diff --git a/plugins/switcher/src/switcher.cpp b/plugins/switcher/src/switcher.cpp
index 3702fb1..9a2b41a 100644
--- a/plugins/switcher/src/switcher.cpp
+++ b/plugins/switcher/src/switcher.cpp
@@ -98,9 +98,10 @@ SwitchScreen::createWindowList (int count)
foreach (CompWindow *w, screen->windows ())
{
- if (SwitchWindow::get (w)->isSwitchWin ())
+ SWITCH_WINDOW (w);
+
+ if (sw->isSwitchWin ())
{
- SWITCH_WINDOW (w);
windows.push_back (w);
sw->cWindow->damageRectSetEnabled (sw, true);
@@ -450,6 +451,8 @@ SwitchScreen::windowRemove (CompWindow *w)
CompWindow *selected;
CompWindow *old;
+ int allWindowsWidth;
+
SWITCH_WINDOW (w);
if (!sw->isSwitchWin (true))
@@ -490,7 +493,7 @@ SwitchScreen::windowRemove (CompWindow *w)
count = windows.size ();
- if (windows.size () == 2)
+ if (count == 2)
{
if (windows.front () == windows.back ())
{
@@ -500,11 +503,10 @@ SwitchScreen::windowRemove (CompWindow *w)
else
{
windows.push_back (windows.front ());
- windows.push_back ((*++windows.begin ()));
+ windows.push_back (*++windows.begin ());
}
}
-
- if (windows.size () == 0)
+ else if (count == 0)
{
CompOption::Vector o (0);
@@ -521,6 +523,8 @@ SwitchScreen::windowRemove (CompWindow *w)
updateWindowList (count);
+ allWindowsWidth = windows.size () * WIDTH;
+
foreach (CompWindow *w, windows)
{
selectedWindow = w;
@@ -529,8 +533,8 @@ SwitchScreen::windowRemove (CompWindow *w)
break;
pos -= WIDTH;
- if (pos < -(int)windows.size () * WIDTH)
- pos += (int)windows.size () * WIDTH;
+ if (pos < -allWindowsWidth)
+ pos += allWindowsWidth;
}
if (popupWindow)
@@ -635,6 +639,9 @@ SwitchScreen::preparePaint (int msSinceLastPaint)
{
int steps, m;
float amount, chunk;
+ int allWindowsWidth;
+
+ allWindowsWidth = windows.size () * WIDTH;
amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
steps = amount / (0.5f * optionGetTimestep ());
@@ -685,10 +692,10 @@ SwitchScreen::preparePaint (int msSinceLastPaint)
move -= m;
pos += m;
- if (pos < -(int)windows.size () * WIDTH)
- pos += (int)windows.size () * WIDTH;
+ if (pos < -allWindowsWidth)
+ pos += allWindowsWidth;
else if (pos > 0)
- pos -= (int)windows.size () * WIDTH;
+ pos -= allWindowsWidth;
translate += tVelocity * chunk;
sTranslate += sVelocity * chunk;