Merge lp:~3v1n0/unity/spread-filter-improvements into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3752
Proposed branch: lp:~3v1n0/unity/spread-filter-improvements
Merge into: lp:unity
Diff against target: 179 lines (+70/-7)
4 files modified
plugins/unityshell/src/unityshell.cpp (+6/-1)
unity-shared/SearchBar.cpp (+3/-1)
unity-shared/SpreadFilter.cpp (+56/-5)
unity-shared/SpreadFilter.h (+5/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/spread-filter-improvements
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone (community) Approve
Review via email: mp+213671@code.launchpad.net

Commit message

SpreadFilter: use launcher width, scale on HiDPI, match also application names

Launcher Width is now considered in setting the offset of the scale filter (fixes
padding when launcher is in autohide mode).
The search bar is correctly scaled when in HiDPI mode.
We use ApplicationManager and thus BAMF to match windows by their name or app name.

Description of the change

Launcher Width is now considered in setting the offset of the scale filter (fixes padding when launcher is in autohide mode)

The search bar is correctly scaled when in HiDPI mode

We use ApplicationManager and thus BAMF to match windows by their name or app name.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2014-03-21 23:08:47 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2014-04-01 17:13:46 +0000
4@@ -525,8 +525,13 @@
5 }
6 else
7 {
8+ CompMatch windows_match;
9+ for (auto xid : spread_filter_->FilteredWindows())
10+ windows_match |= "xid="+std::to_string(xid);
11+
12 auto match = sScreen->getCustomMatch();
13- sScreen->relayoutSlots(match & ("ititle="+filter));
14+ match &= windows_match;
15+ sScreen->relayoutSlots(match);
16 }
17 });
18
19
20=== modified file 'unity-shared/SearchBar.cpp'
21--- unity-shared/SearchBar.cpp 2014-03-20 04:05:39 +0000
22+++ unity-shared/SearchBar.cpp 2014-04-01 17:13:46 +0000
23@@ -332,7 +332,9 @@
24 void SearchBar::UpdateScale(double scale)
25 {
26 hint_->SetScale(scale);
27- show_filters_->SetScale(scale);
28+
29+ if (show_filters_)
30+ show_filters_->SetScale(scale);
31
32 UpdateSearchBarSize();
33 }
34
35=== modified file 'unity-shared/SpreadFilter.cpp'
36--- unity-shared/SpreadFilter.cpp 2014-02-17 23:30:29 +0000
37+++ unity-shared/SpreadFilter.cpp 2014-04-01 17:13:46 +0000
38@@ -22,7 +22,10 @@
39 #include <Nux/HLayout.h>
40 #include "AnimationUtils.h"
41 #include "SearchBar.h"
42+#include "UnitySettings.h"
43 #include "WindowManager.h"
44+#include "ApplicationManager.h"
45+#include "RawPixel.h"
46
47 namespace unity
48 {
49@@ -32,15 +35,31 @@
50 {
51 const unsigned FADE_DURATION = 100;
52 const unsigned DEFAULT_SEARCH_WAIT = 300;
53-const nux::Point OFFSET(10, 15);
54-const nux::Size SIZE(620, 42);
55+const RawPixel OFFSET_X = 10_em;
56+const RawPixel OFFSET_Y = 15_em;
57+const RawPixel WIDTH = 620_em;
58+const RawPixel HEIGHT = 42_em;
59+
60+// For some reason std::to_lower or boost::to_lower_copy doesn't seem to handle well utf8
61+std::string casefold_copy(std::string const& str)
62+{
63+ return glib::String(g_utf8_casefold(str.c_str(), -1)).Str();
64+}
65 }
66
67 Filter::Filter()
68 : fade_animator_(FADE_DURATION)
69 {
70+ auto& wm = WindowManager::Default();
71+ auto& settings = Settings::Instance();
72+ auto const& work_area = wm.GetWorkAreaGeometry(0);
73+ int monitor = wm.MonitorGeometryIn(work_area);
74+ int launcher_width = settings.LauncherWidth(monitor);
75+ auto const& cv = settings.em(monitor);
76+
77 search_bar_ = SearchBar::Ptr(new SearchBar());
78- search_bar_->SetMinMaxSize(SIZE.width, SIZE.height);
79+ search_bar_->SetMinMaxSize(WIDTH.CP(cv), HEIGHT.CP(cv));
80+ search_bar_->scale = cv->DPIScale();
81 search_bar_->live_search_wait = DEFAULT_SEARCH_WAIT;
82 text.SetGetterFunction([this] { return search_bar_->search_string(); });
83 text.SetSetterFunction([this] (std::string const& t) { search_bar_->search_string = t; return false; });
84@@ -51,7 +70,6 @@
85 layout->SetHorizontalExternalMargin(0);
86 layout->AddView(search_bar_.GetPointer());
87
88- auto const& work_area = WindowManager::Default().GetWorkAreaGeometry(0);
89 view_window_ = new nux::BaseWindow(GetName().c_str());
90 view_window_->SetLayout(layout);
91 view_window_->SetBackgroundColor(nux::color::Transparent);
92@@ -61,7 +79,7 @@
93 view_window_->SetOpacity(0.0f);
94 view_window_->SetEnterFocusInputArea(search_bar_.GetPointer());
95 view_window_->SetInputFocus();
96- view_window_->SetXY(OFFSET.x + work_area.x, OFFSET.y + work_area.y);
97+ view_window_->SetXY(OFFSET_X.CP(cv) + std::max(work_area.x, launcher_width), OFFSET_Y.CP(cv) + work_area.y);
98 fade_animator_.updated.connect([this] (double opacity) { view_window_->SetOpacity(opacity); });
99
100 nux::GetWindowCompositor().SetKeyFocusArea(search_bar_->text_entry());
101@@ -72,6 +90,7 @@
102
103 if (search.empty())
104 {
105+ UpdateFilteredWindows();
106 text.changed.emit(search);
107 animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
108 }
109@@ -80,6 +99,7 @@
110 search_bar_->live_search_reached.connect([this] (std::string const& search) {
111 if (!search.empty())
112 {
113+ UpdateFilteredWindows();
114 text.changed.emit(search);
115 search_bar_->SetSearchFinished();
116 }
117@@ -102,6 +122,37 @@
118 return view_window_->GetGeometry();
119 }
120
121+std::set<uint64_t> const& Filter::FilteredWindows() const
122+{
123+ return filtered_windows_;
124+}
125+
126+void Filter::UpdateFilteredWindows()
127+{
128+ auto const& lower_search = casefold_copy(text());
129+ filtered_windows_.clear();
130+
131+ if (lower_search.empty())
132+ return;
133+
134+ for (auto const& app : ApplicationManager::Default().GetRunningApplications())
135+ {
136+ if (casefold_copy(app->title()).find(lower_search) != std::string::npos)
137+ {
138+ for (auto const& win : app->GetWindows())
139+ filtered_windows_.insert(win->window_id());
140+
141+ continue;
142+ }
143+
144+ for (auto const& win : app->GetWindows())
145+ {
146+ if (casefold_copy(win->title()).find(lower_search) != std::string::npos)
147+ filtered_windows_.insert(win->window_id());
148+ }
149+ }
150+}
151+
152 //
153 // Introspection
154 //
155
156=== modified file 'unity-shared/SpreadFilter.h'
157--- unity-shared/SpreadFilter.h 2014-02-17 04:01:26 +0000
158+++ unity-shared/SpreadFilter.h 2014-04-01 17:13:46 +0000
159@@ -47,15 +47,20 @@
160 bool Visible() const;
161 nux::Geometry const& GetAbsoluteGeometry() const;
162
163+ std::set<uint64_t> const& FilteredWindows() const;
164+
165 protected:
166 // Introspectable
167 std::string GetName() const;
168 void AddProperties(debug::IntrospectionData&);
169
170 private:
171+ void UpdateFilteredWindows();
172+
173 nux::ObjectPtr<SearchBar> search_bar_;
174 nux::ObjectPtr<nux::BaseWindow> view_window_;
175 nux::animation::AnimateValue<double> fade_animator_;
176+ std::set<uint64_t> filtered_windows_;
177 };
178
179 } // namespace spread