summaryrefslogtreecommitdiff
path: root/launcher
diff options
authorStephen M. Webb <stephen.webb@canonical.com>2012-12-17 16:33:40 -0500
committerStephen M. Webb <stephen.webb@canonical.com>2012-12-17 16:33:40 -0500
commitb213b2acc7da5e93d651509695cd60dbe4b3fa46 (patch)
tree2db8717e146f4a5ce8abe041e1b6cd3f3a2cab35 /launcher
parent0e3903cb424a60b5412c46d2e60313faa3f802d0 (diff)
SwitcherModel: converted some standalone functions into lambdas.
(bzr r2993.2.2)
Diffstat (limited to 'launcher')
-rw-r--r--launcher/SwitcherModel.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/launcher/SwitcherModel.cpp b/launcher/SwitcherModel.cpp
index dae329dcb..f88434aba 100644
--- a/launcher/SwitcherModel.cpp
+++ b/launcher/SwitcherModel.cpp
@@ -29,15 +29,6 @@ using launcher::AbstractLauncherIcon;
namespace switcher
{
-namespace
-{
-bool compare_windows_by_active(Window first, Window second)
-{
- WindowManager& wm = WindowManager::Default();
- return wm.GetWindowActiveNumber(first) > wm.GetWindowActiveNumber(second);
-}
-
-}
SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon::Ptr> icons)
@@ -142,10 +133,6 @@ int SwitcherModel::LastSelectionIndex()
return last_index_;
}
-bool WindowOnOtherViewport(Window xid)
-{
- return !WindowManager::Default().IsWindowOnCurrentDesktop(xid);
-}
std::vector<Window> SwitcherModel::DetailXids()
{
@@ -155,15 +142,18 @@ std::vector<Window> SwitcherModel::DetailXids()
results.push_back(window->window_id());
}
+ WindowManager& wm = WindowManager::Default();
if (only_detail_on_viewport)
{
- results.erase(std::remove_if(results.begin(),
- results.end(),
- WindowOnOtherViewport),
- results.end());
+ results.erase(std::remove_if(results.begin(), results.end(),
+ [&wm](Window xid) { return !wm.IsWindowOnCurrentDesktop(xid); }),
+ results.end());
}
- std::sort(results.begin(), results.end(), compare_windows_by_active);
+ std::sort(results.begin(), results.end(), [&wm](Window first, Window second) {
+ return wm.GetWindowActiveNumber(first) > wm.GetWindowActiveNumber(second);
+ });
+
if (Selection() == last_active_icon_ && results.size () > 1)
{
@@ -178,13 +168,14 @@ std::vector<Window> SwitcherModel::DetailXids()
Window SwitcherModel::DetailSelectionWindow()
{
- if (!detail_selection || DetailXids ().empty())
+ auto windows = DetailXids();
+ if (!detail_selection || windows.empty())
return 0;
- if (detail_selection_index > DetailXids().size() - 1)
+ if (detail_selection_index > windows.size() - 1)
return 0;
- return DetailXids()[detail_selection_index];
+ return windows[detail_selection_index];
}
void SwitcherModel::Next()