summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-04-01 17:03:24 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-04-01 17:03:24 +0200
commit6ed8526bb52e21cfb4609cd9549db4c0ffd0223c (patch)
treec67601e5eb42bed81a8b556e182c0a02998068ce
parent86b0dcc756a3590536d0a85cdcbd4c73b9a203f4 (diff)
SpreadFilter: compute a list of filtered windows using both window and application name
Fixes LP: #1281297 (bzr r3748.3.4)
-rw-r--r--unity-shared/SpreadFilter.cpp35
-rw-r--r--unity-shared/SpreadFilter.h5
2 files changed, 40 insertions, 0 deletions
diff --git a/unity-shared/SpreadFilter.cpp b/unity-shared/SpreadFilter.cpp
index 6ee08a628..1cff86e2e 100644
--- a/unity-shared/SpreadFilter.cpp
+++ b/unity-shared/SpreadFilter.cpp
@@ -20,10 +20,12 @@
#include "SpreadFilter.h"
#include <Nux/HLayout.h>
+#include <boost/algorithm/string.hpp>
#include "AnimationUtils.h"
#include "SearchBar.h"
#include "UnitySettings.h"
#include "WindowManager.h"
+#include "ApplicationManager.h"
#include "RawPixel.h"
namespace unity
@@ -83,6 +85,7 @@ Filter::Filter()
if (search.empty())
{
+ UpdateFilteredWindows();
text.changed.emit(search);
animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
}
@@ -91,6 +94,7 @@ Filter::Filter()
search_bar_->live_search_reached.connect([this] (std::string const& search) {
if (!search.empty())
{
+ UpdateFilteredWindows();
text.changed.emit(search);
search_bar_->SetSearchFinished();
}
@@ -113,6 +117,37 @@ nux::Geometry const& Filter::GetAbsoluteGeometry() const
return view_window_->GetGeometry();
}
+std::set<uint64_t> const& Filter::FilteredWindows() const
+{
+ return filtered_windows_;
+}
+
+void Filter::UpdateFilteredWindows()
+{
+ auto const& lower_search = boost::to_lower_copy(text());
+ filtered_windows_.clear();
+
+ if (lower_search.empty())
+ return;
+
+ for (auto const& app : ApplicationManager::Default().GetRunningApplications())
+ {
+ if (boost::to_lower_copy(app->title()).find(lower_search) != std::string::npos)
+ {
+ for (auto const& win : app->GetWindows())
+ filtered_windows_.insert(win->window_id());
+
+ continue;
+ }
+
+ for (auto const& win : app->GetWindows())
+ {
+ if (boost::to_lower_copy(win->title()).find(lower_search) != std::string::npos)
+ filtered_windows_.insert(win->window_id());
+ }
+ }
+}
+
//
// Introspection
//
diff --git a/unity-shared/SpreadFilter.h b/unity-shared/SpreadFilter.h
index 2709315a5..91fda0df2 100644
--- a/unity-shared/SpreadFilter.h
+++ b/unity-shared/SpreadFilter.h
@@ -47,15 +47,20 @@ public:
bool Visible() const;
nux::Geometry const& GetAbsoluteGeometry() const;
+ std::set<uint64_t> const& FilteredWindows() const;
+
protected:
// Introspectable
std::string GetName() const;
void AddProperties(debug::IntrospectionData&);
private:
+ void UpdateFilteredWindows();
+
nux::ObjectPtr<SearchBar> search_bar_;
nux::ObjectPtr<nux::BaseWindow> view_window_;
nux::animation::AnimateValue<double> fade_animator_;
+ std::set<uint64_t> filtered_windows_;
};
} // namespace spread