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
=== modified file 'launcher/ApplicationLauncherIcon.cpp'
--- launcher/ApplicationLauncherIcon.cpp 2015-10-27 19:21:27 +0000
+++ launcher/ApplicationLauncherIcon.cpp 2015-11-18 16:34:03 +0000
@@ -157,6 +157,9 @@
157 signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) {157 signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) {
158 signals_conn_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); }));158 signals_conn_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); }));
159 EnsureWindowsLocation();159 EnsureWindowsLocation();
160
161 if (WindowManager::Default().IsScaleActiveForGroup() && IsActive())
162 Spread(true, 0, false);
160 }));163 }));
161164
162 auto ensure_win_location_cb = sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowsLocation));165 auto ensure_win_location_cb = sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowsLocation));
@@ -291,12 +294,7 @@
291 return;294 return;
292 }295 }
293296
294 bool scaleWasActive = wm.IsScaleActive();297 bool scale_was_active = wm.IsScaleActive();
295 if (scaleWasActive)
296 {
297 wm.TerminateScale();
298 }
299
300 bool active = IsActive();298 bool active = IsActive();
301 bool user_visible = IsRunning();299 bool user_visible = IsRunning();
302 /* We should check each child to see if there is300 /* We should check each child to see if there is
@@ -389,6 +387,7 @@
389 if (GetQuirk(Quirk::STARTING, arg.monitor))387 if (GetQuirk(Quirk::STARTING, arg.monitor))
390 return;388 return;
391389
390 wm.TerminateScale();
392 SetQuirk(Quirk::STARTING, true, arg.monitor);391 SetQuirk(Quirk::STARTING, true, arg.monitor);
393 OpenInstanceLauncherIcon(arg.timestamp);392 OpenInstanceLauncherIcon(arg.timestamp);
394 }393 }
@@ -396,8 +395,10 @@
396 {395 {
397 if (active)396 if (active)
398 {397 {
399 if (scaleWasActive) // #5 above398 if (scale_was_active) // #5 above
400 {399 {
400 wm.TerminateScale();
401
401 if (minimize_window_on_click())402 if (minimize_window_on_click())
402 {403 {
403 for (auto const& win : GetWindows(WindowFilter::ON_CURRENT_DESKTOP))404 for (auto const& win : GetWindows(WindowFilter::ON_CURRENT_DESKTOP))
@@ -414,7 +415,7 @@
414 {415 {
415 bool minimized = false;416 bool minimized = false;
416417
417 if (minimize_window_on_click)418 if (minimize_window_on_click())
418 {419 {
419 WindowList const& windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP);420 WindowList const& windows = GetWindows(WindowFilter::ON_CURRENT_DESKTOP);
420421
@@ -434,9 +435,13 @@
434 }435 }
435 else436 else
436 {437 {
437 if (scaleWasActive) // #4 above438 if (scale_was_active) // #4 above
438 {439 {
440 if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() <= 1)
441 wm.TerminateScale();
442
439 Focus(arg);443 Focus(arg);
444
440 if (arg.source != ActionArg::Source::SWITCHER)445 if (arg.source != ActionArg::Source::SWITCHER)
441 Spread(true, 0, false);446 Spread(true, 0, false);
442 }447 }
@@ -704,9 +709,8 @@
704{709{
705 std::vector<Window> windows;710 std::vector<Window> windows;
706 for (auto& window : GetWindows(current_desktop ? WindowFilter::ON_CURRENT_DESKTOP : 0))711 for (auto& window : GetWindows(current_desktop ? WindowFilter::ON_CURRENT_DESKTOP : 0))
707 {
708 windows.push_back(window->window_id());712 windows.push_back(window->window_id());
709 }713
710 return WindowManager::Default().ScaleWindowGroup(windows, state, force);714 return WindowManager::Default().ScaleWindowGroup(windows, state, force);
711}715}
712716
@@ -1171,7 +1175,10 @@
1171 auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;1175 auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
11721176
1173 _source_manager.AddTimeout(1000, [this, timestamp] {1177 _source_manager.AddTimeout(1000, [this, timestamp] {
1174 WindowManager::Default().TerminateScale();1178 bool to_spread = GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1;
1179
1180 if (!to_spread)
1181 WindowManager::Default().TerminateScale();
11751182
1176 if (!IsRunning())1183 if (!IsRunning())
1177 return false;1184 return false;
@@ -1179,7 +1186,7 @@
1179 UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);1186 UBusManager::SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
1180 Focus(ActionArg(ActionArg::Source::LAUNCHER, 1, timestamp));1187 Focus(ActionArg(ActionArg::Source::LAUNCHER, 1, timestamp));
11811188
1182 if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1)1189 if (to_spread)
1183 Spread(true, COMPIZ_SCALE_DND_SPREAD, false);1190 Spread(true, COMPIZ_SCALE_DND_SPREAD, false);
11841191
1185 return false;1192 return false;
11861193
=== modified file 'unity-shared/PluginAdapter.cpp'
--- unity-shared/PluginAdapter.cpp 2015-10-21 14:28:00 +0000
+++ unity-shared/PluginAdapter.cpp 2015-11-18 16:34:03 +0000
@@ -72,8 +72,10 @@
72PluginAdapter::PluginAdapter(CompScreen* screen)72PluginAdapter::PluginAdapter(CompScreen* screen)
73 : bias_active_to_viewport(false)73 : bias_active_to_viewport(false)
74 , m_Screen(screen)74 , m_Screen(screen)
75 , _scale_screen(ScaleScreen::get(screen))
75 , _coverage_area_before_automaximize(0.75)76 , _coverage_area_before_automaximize(0.75)
76 , _spread_state(false)77 , _spread_state(false)
78 , _spread_requested_state(false)
77 , _spread_windows_state(false)79 , _spread_windows_state(false)
78 , _expo_state(false)80 , _expo_state(false)
79 , _vp_switch_started(false)81 , _vp_switch_started(false)
@@ -95,6 +97,7 @@
95 if (!_spread_state && screen->grabExist("scale"))97 if (!_spread_state && screen->grabExist("scale"))
96 {98 {
97 _spread_state = true;99 _spread_state = true;
100 _spread_requested_state = true;
98 initiate_spread.emit();101 initiate_spread.emit();
99 }102 }
100103
@@ -110,6 +113,7 @@
110 if (_spread_state && !screen->grabExist("scale"))113 if (_spread_state && !screen->grabExist("scale"))
111 {114 {
112 _spread_state = false;115 _spread_state = false;
116 _spread_requested_state = false;
113 _spread_windows_state = false;117 _spread_windows_state = false;
114 terminate_spread.emit();118 terminate_spread.emit();
115 }119 }
@@ -216,6 +220,7 @@
216 if (_spread_state != new_state)220 if (_spread_state != new_state)
217 {221 {
218 _spread_state = new_state;222 _spread_state = new_state;
223 _spread_requested_state = new_state;
219 _spread_state ? initiate_spread.emit() : terminate_spread.emit();224 _spread_state ? initiate_spread.emit() : terminate_spread.emit();
220225
221 if (!_spread_state)226 if (!_spread_state)
@@ -230,10 +235,12 @@
230235
231 bool old_windows_state = _spread_windows_state;236 bool old_windows_state = _spread_windows_state;
232 _spread_state = false;237 _spread_state = false;
238 _spread_requested_state = false;
233 _spread_windows_state = false;239 _spread_windows_state = false;
234 terminate_spread.emit();240 terminate_spread.emit();
235241
236 _spread_state = true;242 _spread_state = true;
243 _spread_requested_state = true;
237 _spread_windows_state = old_windows_state;244 _spread_windows_state = old_windows_state;
238 initiate_spread.emit();245 initiate_spread.emit();
239 }246 }
@@ -391,16 +398,26 @@
391398
392void PluginAdapter::InitiateScale(std::string const& match, int state)399void PluginAdapter::InitiateScale(std::string const& match, int state)
393{400{
394 CompOption::Vector argument(1);401 if (!_spread_requested_state || !_scale_screen)
395 argument[0].setName("match", CompOption::TypeMatch);402 {
396 argument[0].value().set(CompMatch(match));403 _spread_requested_state = true;
397404 CompOption::Vector argument(1);
398 m_ScaleActionList.InitiateAll(argument, state);405 argument[0].setName("match", CompOption::TypeMatch);
406 argument[0].value().set(CompMatch(match));
407 m_ScaleActionList.InitiateAll(argument, state);
408 }
409 else
410 {
411 terminate_spread.emit();
412 _scale_screen->relayoutSlots(CompMatch(match));
413 initiate_spread.emit();
414 }
399}415}
400416
401void PluginAdapter::TerminateScale()417void PluginAdapter::TerminateScale()
402{418{
403 m_ScaleActionList.TerminateAll();419 m_ScaleActionList.TerminateAll();
420 _spread_requested_state = false;
404}421}
405422
406bool PluginAdapter::IsScaleActive() const423bool PluginAdapter::IsScaleActive() const
407424
=== modified file 'unity-shared/PluginAdapter.h'
--- unity-shared/PluginAdapter.h 2015-10-21 14:28:00 +0000
+++ unity-shared/PluginAdapter.h 2015-11-18 16:34:03 +0000
@@ -23,6 +23,7 @@
23/* Compiz */23/* Compiz */
24#include <core/core.h>24#include <core/core.h>
25#include <core/atoms.h>25#include <core/atoms.h>
26#include <scale/scale.h>
2627
27#include <NuxCore/Property.h>28#include <NuxCore/Property.h>
2829
@@ -214,11 +215,13 @@
214 bool IsCurrentViewportEmpty() const;215 bool IsCurrentViewportEmpty() const;
215216
216 CompScreen* m_Screen;217 CompScreen* m_Screen;
218 ScaleScreen* _scale_screen;
217 MultiActionList m_ExpoActionList;219 MultiActionList m_ExpoActionList;
218 MultiActionList m_ScaleActionList;220 MultiActionList m_ScaleActionList;
219221
220 float _coverage_area_before_automaximize;222 float _coverage_area_before_automaximize;
221 bool _spread_state;223 bool _spread_state;
224 bool _spread_requested_state;
222 bool _spread_windows_state;225 bool _spread_windows_state;
223 bool _expo_state;226 bool _expo_state;
224 bool _vp_switch_started;227 bool _vp_switch_started;
225228
=== modified file 'unity-shared/SpreadFilter.cpp'
--- unity-shared/SpreadFilter.cpp 2015-04-07 22:29:54 +0000
+++ unity-shared/SpreadFilter.cpp 2015-11-18 16:34:03 +0000
@@ -106,6 +106,8 @@
106 search_bar_->SetSearchFinished();106 search_bar_->SetSearchFinished();
107 }107 }
108 });108 });
109
110 ApplicationManager::Default().window_opened.connect(sigc::hide(sigc::mem_fun(this, &Filter::OnWindowChanged)));
109}111}
110112
111bool Filter::Visible() const113bool Filter::Visible() const
@@ -127,26 +129,37 @@
127{129{
128 auto const& lower_search = casefold_copy(text());130 auto const& lower_search = casefold_copy(text());
129 filtered_windows_.clear();131 filtered_windows_.clear();
132 title_connections_.Clear();
130133
131 if (lower_search.empty())134 if (lower_search.empty())
132 return;135 return;
133136
137 auto update_cb = sigc::hide(sigc::mem_fun(this, &Filter::OnWindowChanged));
138
134 for (auto const& app : ApplicationManager::Default().GetRunningApplications())139 for (auto const& app : ApplicationManager::Default().GetRunningApplications())
135 {140 {
141 title_connections_.Add(app->title.changed.connect(update_cb));
142
136 if (casefold_copy(app->title()).find(lower_search) != std::string::npos)143 if (casefold_copy(app->title()).find(lower_search) != std::string::npos)
137 {144 {
138 for (auto const& win : app->GetWindows())145 for (auto const& win : app->GetWindows())
139 filtered_windows_.insert(win->window_id());146 filtered_windows_.insert(win->window_id());
140147 }
141 continue;148 }
142 }149
143150 for (auto const& win : ApplicationManager::Default().GetWindowsForMonitor(-1))
144 for (auto const& win : app->GetWindows())151 {
145 {152 title_connections_.Add(win->title.changed.connect(update_cb));
146 if (casefold_copy(win->title()).find(lower_search) != std::string::npos)153
147 filtered_windows_.insert(win->window_id());154 if (casefold_copy(win->title()).find(lower_search) != std::string::npos)
148 }155 filtered_windows_.insert(win->window_id());
149 }156 }
157}
158
159void Filter::OnWindowChanged()
160{
161 UpdateFilteredWindows();
162 text.changed.emit(text);
150}163}
151164
152//165//
153166
=== modified file 'unity-shared/SpreadFilter.h'
--- unity-shared/SpreadFilter.h 2015-04-07 22:29:54 +0000
+++ unity-shared/SpreadFilter.h 2015-11-18 16:34:03 +0000
@@ -25,6 +25,7 @@
25#include <Nux/Nux.h>25#include <Nux/Nux.h>
26#include <Nux/BaseWindow.h>26#include <Nux/BaseWindow.h>
27#include <NuxCore/Animation.h>27#include <NuxCore/Animation.h>
28#include <UnityCore/ConnectionManager.h>
28#include "Introspectable.h"29#include "Introspectable.h"
2930
30namespace unity31namespace unity
@@ -54,12 +55,14 @@
54 void AddProperties(debug::IntrospectionData&);55 void AddProperties(debug::IntrospectionData&);
5556
56private:57private:
58 void OnWindowChanged();
57 void UpdateFilteredWindows();59 void UpdateFilteredWindows();
5860
59 nux::ObjectPtr<SearchBar> search_bar_;61 nux::ObjectPtr<SearchBar> search_bar_;
60 nux::ObjectPtr<nux::BaseWindow> view_window_;62 nux::ObjectPtr<nux::BaseWindow> view_window_;
61 nux::animation::AnimateValue<double> fade_animator_;63 nux::animation::AnimateValue<double> fade_animator_;
62 std::set<uint64_t> filtered_windows_;64 std::set<uint64_t> filtered_windows_;
65 connection::Manager title_connections_;
63};66};
6467
65} // namespace spread68} // namespace spread