Merge lp:~3v1n0/unity/dynamic-app-spread 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: 4046
Proposed branch: lp:~3v1n0/unity/dynamic-app-spread
Merge into: lp:unity
Diff against target: 301 lines (+71/-28)
5 files modified
launcher/ApplicationLauncherIcon.cpp (+20/-13)
unity-shared/PluginAdapter.cpp (+22/-5)
unity-shared/PluginAdapter.h (+3/-0)
unity-shared/SpreadFilter.cpp (+23/-10)
unity-shared/SpreadFilter.h (+3/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/dynamic-app-spread
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+277873@code.launchpad.net

Commit message

ApplicationLauncherIcon: if a new window opens while spreading, spread again with proper match

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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/ApplicationLauncherIcon.cpp'
2--- launcher/ApplicationLauncherIcon.cpp 2015-10-27 19:21:27 +0000
3+++ launcher/ApplicationLauncherIcon.cpp 2015-11-18 16:34:03 +0000
4@@ -157,6 +157,9 @@
5 signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) {
6 signals_conn_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); }));
7 EnsureWindowsLocation();
8+
9+ if (WindowManager::Default().IsScaleActiveForGroup() && IsActive())
10+ Spread(true, 0, false);
11 }));
12
13 auto ensure_win_location_cb = sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowsLocation));
14@@ -291,12 +294,7 @@
15 return;
16 }
17
18- bool scaleWasActive = wm.IsScaleActive();
19- if (scaleWasActive)
20- {
21- wm.TerminateScale();
22- }
23-
24+ bool scale_was_active = wm.IsScaleActive();
25 bool active = IsActive();
26 bool user_visible = IsRunning();
27 /* We should check each child to see if there is
28@@ -389,6 +387,7 @@
29 if (GetQuirk(Quirk::STARTING, arg.monitor))
30 return;
31
32+ wm.TerminateScale();
33 SetQuirk(Quirk::STARTING, true, arg.monitor);
34 OpenInstanceLauncherIcon(arg.timestamp);
35 }
36@@ -396,8 +395,10 @@
37 {
38 if (active)
39 {
40- if (scaleWasActive) // #5 above
41+ if (scale_was_active) // #5 above
42 {
43+ wm.TerminateScale();
44+
45 if (minimize_window_on_click())
46 {
47 for (auto const& win : GetWindows(WindowFilter::ON_CURRENT_DESKTOP))
48@@ -414,7 +415,7 @@
49 {
50 bool minimized = false;
51
52- if (minimize_window_on_click)
53+ if (minimize_window_on_click())
54 {
55 WindowList const& windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP);
56
57@@ -434,9 +435,13 @@
58 }
59 else
60 {
61- if (scaleWasActive) // #4 above
62+ if (scale_was_active) // #4 above
63 {
64+ if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() <= 1)
65+ wm.TerminateScale();
66+
67 Focus(arg);
68+
69 if (arg.source != ActionArg::Source::SWITCHER)
70 Spread(true, 0, false);
71 }
72@@ -704,9 +709,8 @@
73 {
74 std::vector<Window> windows;
75 for (auto& window : GetWindows(current_desktop ? WindowFilter::ON_CURRENT_DESKTOP : 0))
76- {
77 windows.push_back(window->window_id());
78- }
79+
80 return WindowManager::Default().ScaleWindowGroup(windows, state, force);
81 }
82
83@@ -1171,7 +1175,10 @@
84 auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
85
86 _source_manager.AddTimeout(1000, [this, timestamp] {
87- WindowManager::Default().TerminateScale();
88+ bool to_spread = GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1;
89+
90+ if (!to_spread)
91+ WindowManager::Default().TerminateScale();
92
93 if (!IsRunning())
94 return false;
95@@ -1179,7 +1186,7 @@
96 UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
97 Focus(ActionArg(ActionArg::Source::LAUNCHER, 1, timestamp));
98
99- if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1)
100+ if (to_spread)
101 Spread(true, COMPIZ_SCALE_DND_SPREAD, false);
102
103 return false;
104
105=== modified file 'unity-shared/PluginAdapter.cpp'
106--- unity-shared/PluginAdapter.cpp 2015-10-21 14:28:00 +0000
107+++ unity-shared/PluginAdapter.cpp 2015-11-18 16:34:03 +0000
108@@ -72,8 +72,10 @@
109 PluginAdapter::PluginAdapter(CompScreen* screen)
110 : bias_active_to_viewport(false)
111 , m_Screen(screen)
112+ , _scale_screen(ScaleScreen::get(screen))
113 , _coverage_area_before_automaximize(0.75)
114 , _spread_state(false)
115+ , _spread_requested_state(false)
116 , _spread_windows_state(false)
117 , _expo_state(false)
118 , _vp_switch_started(false)
119@@ -95,6 +97,7 @@
120 if (!_spread_state && screen->grabExist("scale"))
121 {
122 _spread_state = true;
123+ _spread_requested_state = true;
124 initiate_spread.emit();
125 }
126
127@@ -110,6 +113,7 @@
128 if (_spread_state && !screen->grabExist("scale"))
129 {
130 _spread_state = false;
131+ _spread_requested_state = false;
132 _spread_windows_state = false;
133 terminate_spread.emit();
134 }
135@@ -216,6 +220,7 @@
136 if (_spread_state != new_state)
137 {
138 _spread_state = new_state;
139+ _spread_requested_state = new_state;
140 _spread_state ? initiate_spread.emit() : terminate_spread.emit();
141
142 if (!_spread_state)
143@@ -230,10 +235,12 @@
144
145 bool old_windows_state = _spread_windows_state;
146 _spread_state = false;
147+ _spread_requested_state = false;
148 _spread_windows_state = false;
149 terminate_spread.emit();
150
151 _spread_state = true;
152+ _spread_requested_state = true;
153 _spread_windows_state = old_windows_state;
154 initiate_spread.emit();
155 }
156@@ -391,16 +398,26 @@
157
158 void PluginAdapter::InitiateScale(std::string const& match, int state)
159 {
160- CompOption::Vector argument(1);
161- argument[0].setName("match", CompOption::TypeMatch);
162- argument[0].value().set(CompMatch(match));
163-
164- m_ScaleActionList.InitiateAll(argument, state);
165+ if (!_spread_requested_state || !_scale_screen)
166+ {
167+ _spread_requested_state = true;
168+ CompOption::Vector argument(1);
169+ argument[0].setName("match", CompOption::TypeMatch);
170+ argument[0].value().set(CompMatch(match));
171+ m_ScaleActionList.InitiateAll(argument, state);
172+ }
173+ else
174+ {
175+ terminate_spread.emit();
176+ _scale_screen->relayoutSlots(CompMatch(match));
177+ initiate_spread.emit();
178+ }
179 }
180
181 void PluginAdapter::TerminateScale()
182 {
183 m_ScaleActionList.TerminateAll();
184+ _spread_requested_state = false;
185 }
186
187 bool PluginAdapter::IsScaleActive() const
188
189=== modified file 'unity-shared/PluginAdapter.h'
190--- unity-shared/PluginAdapter.h 2015-10-21 14:28:00 +0000
191+++ unity-shared/PluginAdapter.h 2015-11-18 16:34:03 +0000
192@@ -23,6 +23,7 @@
193 /* Compiz */
194 #include <core/core.h>
195 #include <core/atoms.h>
196+#include <scale/scale.h>
197
198 #include <NuxCore/Property.h>
199
200@@ -214,11 +215,13 @@
201 bool IsCurrentViewportEmpty() const;
202
203 CompScreen* m_Screen;
204+ ScaleScreen* _scale_screen;
205 MultiActionList m_ExpoActionList;
206 MultiActionList m_ScaleActionList;
207
208 float _coverage_area_before_automaximize;
209 bool _spread_state;
210+ bool _spread_requested_state;
211 bool _spread_windows_state;
212 bool _expo_state;
213 bool _vp_switch_started;
214
215=== modified file 'unity-shared/SpreadFilter.cpp'
216--- unity-shared/SpreadFilter.cpp 2015-04-07 22:29:54 +0000
217+++ unity-shared/SpreadFilter.cpp 2015-11-18 16:34:03 +0000
218@@ -106,6 +106,8 @@
219 search_bar_->SetSearchFinished();
220 }
221 });
222+
223+ ApplicationManager::Default().window_opened.connect(sigc::hide(sigc::mem_fun(this, &Filter::OnWindowChanged)));
224 }
225
226 bool Filter::Visible() const
227@@ -127,26 +129,37 @@
228 {
229 auto const& lower_search = casefold_copy(text());
230 filtered_windows_.clear();
231+ title_connections_.Clear();
232
233 if (lower_search.empty())
234 return;
235
236+ auto update_cb = sigc::hide(sigc::mem_fun(this, &Filter::OnWindowChanged));
237+
238 for (auto const& app : ApplicationManager::Default().GetRunningApplications())
239 {
240+ title_connections_.Add(app->title.changed.connect(update_cb));
241+
242 if (casefold_copy(app->title()).find(lower_search) != std::string::npos)
243 {
244 for (auto const& win : app->GetWindows())
245 filtered_windows_.insert(win->window_id());
246-
247- continue;
248- }
249-
250- for (auto const& win : app->GetWindows())
251- {
252- if (casefold_copy(win->title()).find(lower_search) != std::string::npos)
253- filtered_windows_.insert(win->window_id());
254- }
255- }
256+ }
257+ }
258+
259+ for (auto const& win : ApplicationManager::Default().GetWindowsForMonitor(-1))
260+ {
261+ title_connections_.Add(win->title.changed.connect(update_cb));
262+
263+ if (casefold_copy(win->title()).find(lower_search) != std::string::npos)
264+ filtered_windows_.insert(win->window_id());
265+ }
266+}
267+
268+void Filter::OnWindowChanged()
269+{
270+ UpdateFilteredWindows();
271+ text.changed.emit(text);
272 }
273
274 //
275
276=== modified file 'unity-shared/SpreadFilter.h'
277--- unity-shared/SpreadFilter.h 2015-04-07 22:29:54 +0000
278+++ unity-shared/SpreadFilter.h 2015-11-18 16:34:03 +0000
279@@ -25,6 +25,7 @@
280 #include <Nux/Nux.h>
281 #include <Nux/BaseWindow.h>
282 #include <NuxCore/Animation.h>
283+#include <UnityCore/ConnectionManager.h>
284 #include "Introspectable.h"
285
286 namespace unity
287@@ -54,12 +55,14 @@
288 void AddProperties(debug::IntrospectionData&);
289
290 private:
291+ void OnWindowChanged();
292 void UpdateFilteredWindows();
293
294 nux::ObjectPtr<SearchBar> search_bar_;
295 nux::ObjectPtr<nux::BaseWindow> view_window_;
296 nux::animation::AnimateValue<double> fade_animator_;
297 std::set<uint64_t> filtered_windows_;
298+ connection::Manager title_connections_;
299 };
300
301 } // namespace spread