Merge lp:~3v1n0/unity/dnd-launcher-icon-fixes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3808
Proposed branch: lp:~3v1n0/unity/dnd-launcher-icon-fixes
Merge into: lp:unity
Diff against target: 313 lines (+76/-43)
10 files modified
dash/DashController.cpp (+3/-1)
hud/HudController.cpp (+1/-0)
launcher/AbstractLauncherIcon.h (+3/-2)
launcher/ApplicationLauncherIcon.cpp (+15/-14)
launcher/ApplicationLauncherIcon.h (+0/-1)
launcher/Launcher.cpp (+19/-2)
launcher/TrashLauncherIcon.cpp (+1/-0)
launcher/VolumeLauncherIcon.cpp (+1/-0)
plugins/unityshell/src/unityshell.cpp (+6/-15)
unity-shared/PluginAdapter.cpp (+27/-8)
To merge this branch: bzr merge lp:~3v1n0/unity/dnd-launcher-icon-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Townsend Approve
Brandon Schaefer (community) Approve
Review via email: mp+215993@code.launchpad.net

Commit message

ApplicationLauncherIcon: Focus and, in case, Spread the windows on DnD

After 1 second that an user is over an icon, that icon should focus the relative
application and Spread its windows if it has more than one opened.

Correctly handle the DnD scale in launcher, and apply glow to the icon under pointer.

Description of the change

To get all bugs properly fixed this needs lp:~3v1n0/compiz/scale-dndtarget-workarea-shape (not a strict dependency, though).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
Christopher Townsend (townsend) wrote :

Cool, looks good.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2014-03-21 05:23:42 +0000
3+++ dash/DashController.cpp 2014-04-16 02:02:27 +0000
4@@ -105,7 +105,9 @@
5 }
6 });
7
8- WindowManager::Default().initiate_spread.connect(sigc::mem_fun(this, &Controller::HideDash));
9+ auto& wm = WindowManager::Default();
10+ wm.initiate_spread.connect(sigc::mem_fun(this, &Controller::HideDash));
11+ wm.screen_viewport_switch_started.connect(sigc::mem_fun(this, &Controller::HideDash));
12
13 dbus_server_.AddObjects(dbus::INTROSPECTION, dbus::PATH);
14 dbus_server_.GetObjects().front()->SetMethodsCallsHandler([this] (std::string const& method, GVariant*) {
15
16=== modified file 'hud/HudController.cpp'
17--- hud/HudController.cpp 2014-02-28 16:56:19 +0000
18+++ hud/HudController.cpp 2014-04-16 02:02:27 +0000
19@@ -102,6 +102,7 @@
20 WindowManager& wm = WindowManager::Default();
21 wm.screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed));
22 wm.initiate_spread.connect(sigc::mem_fun(this, &Controller::HideHud));
23+ wm.screen_viewport_switch_started.connect(sigc::mem_fun(this, &Controller::HideHud));
24
25 hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished));
26 timeline_animator_.updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame));
27
28=== modified file 'launcher/AbstractLauncherIcon.h'
29--- launcher/AbstractLauncherIcon.h 2014-03-17 20:58:25 +0000
30+++ launcher/AbstractLauncherIcon.h 2014-04-16 02:02:27 +0000
31@@ -110,10 +110,11 @@
32 UNFOLDED,
33 STARTING,
34 SHIMMER,
35- CENTER_SAVED,
36+ DESAT,
37+ GLOW,
38 PROGRESS,
39- DESAT,
40 PULSE_ONCE,
41+ CENTER_SAVED,
42
43 LAST
44 };
45
46=== modified file 'launcher/ApplicationLauncherIcon.cpp'
47--- launcher/ApplicationLauncherIcon.cpp 2014-04-02 14:36:55 +0000
48+++ launcher/ApplicationLauncherIcon.cpp 2014-04-16 02:02:27 +0000
49@@ -49,9 +49,10 @@
50 // We use the "bamf-" prefix since the manager is protected, to avoid name clash
51 const std::string WINDOW_MOVE_TIMEOUT = "bamf-window-move";
52 const std::string ICON_REMOVE_TIMEOUT = "bamf-icon-remove";
53-//const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over";
54+const std::string ICON_DND_OVER_TIMEOUT = "bamf-icon-dnd-over";
55 const std::string DEFAULT_ICON = "application-default-icon";
56 const int MAXIMUM_QUICKLIST_WIDTH = 300;
57+const int COMPIZ_SCALE_DND_SPREAD = 1 << 7;
58
59 enum MenuItemType
60 {
61@@ -1157,28 +1158,28 @@
62 return _remote_uri;
63 }
64
65-void ApplicationLauncherIcon::OnDndHovered()
66-{
67- // for now, let's not do this, it turns out to be quite buggy
68- //if (IsRunning())
69- // Spread(CompAction::StateInitEdgeDnd, true);
70-}
71-
72 void ApplicationLauncherIcon::OnDndEnter()
73 {
74- /* Disabled, since the DND code is currently disabled as well.
75- _source_manager.AddTimeout(1000, [this] {
76- OnDndHovered();
77+ auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
78+
79+ _source_manager.AddTimeout(1000, [this, timestamp] {
80+ WindowManager::Default().TerminateScale();
81+
82+ if (!IsRunning())
83+ return false;
84+
85+ Focus(ActionArg(ActionArg::Source::LAUNCHER, 1, timestamp));
86+
87+ if (GetWindows(WindowFilter::ON_CURRENT_DESKTOP).size() > 1)
88+ Spread(true, COMPIZ_SCALE_DND_SPREAD, false);
89+
90 return false;
91 }, ICON_DND_OVER_TIMEOUT);
92- */
93 }
94
95 void ApplicationLauncherIcon::OnDndLeave()
96 {
97- /* Disabled, since the DND code is currently disabled as well.
98 _source_manager.Remove(ICON_DND_OVER_TIMEOUT);
99- */
100 }
101
102 bool ApplicationLauncherIcon::IsFileManager()
103
104=== modified file 'launcher/ApplicationLauncherIcon.h'
105--- launcher/ApplicationLauncherIcon.h 2014-03-06 21:19:21 +0000
106+++ launcher/ApplicationLauncherIcon.h 2014-04-16 02:02:27 +0000
107@@ -83,7 +83,6 @@
108 void AddProperties(debug::IntrospectionData&);
109 void OnAcceptDrop(DndData const& dnd_data);
110 void OnDndEnter();
111- void OnDndHovered();
112 void OnDndLeave();
113 void OpenInstanceLauncherIcon(Time timestamp) override;
114 void ToggleSticky();
115
116=== modified file 'launcher/Launcher.cpp'
117--- launcher/Launcher.cpp 2014-04-14 13:46:01 +0000
118+++ launcher/Launcher.cpp 2014-04-16 02:02:27 +0000
119@@ -157,6 +157,7 @@
120 hide_machine_.should_hide_changed.connect(sigc::mem_fun(this, &Launcher::SetHidden));
121 hide_machine_.reveal_progress.changed.connect(redraw_cb);
122 hover_machine_.should_hover_changed.connect(sigc::mem_fun(this, &Launcher::SetHover));
123+ bg_effect_helper_.enabled.changed.connect(redraw_cb);
124
125 mouse_down.connect(sigc::mem_fun(this, &Launcher::RecvMouseDown));
126 mouse_up.connect(sigc::mem_fun(this, &Launcher::RecvMouseUp));
127@@ -599,7 +600,7 @@
128 else
129 urgent_progress = CLAMP(urgent_progress * 3.0f - 2.0f, 0.0f, 1.0f); // we want to go 3x faster than the urgent normal cycle
130
131- arg.glow_intensity = urgent_progress;
132+ arg.glow_intensity = icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::GLOW, monitor()) + urgent_progress;
133
134 if (options()->urgent_animation() == URGENT_ANIMATION_WIGGLE)
135 {
136@@ -1171,6 +1172,9 @@
137 hide_machine_.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, active);
138 bg_effect_helper_.enabled = active;
139
140+ if (hide_machine_.GetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE))
141+ return;
142+
143 if (active && icon_under_mouse_)
144 icon_under_mouse_->HideTooltip();
145
146@@ -1592,6 +1596,7 @@
147 icon->SetQuirkDuration(AbstractLauncherIcon::Quirk::CENTER_SAVED, ANIM_DURATION, monitor());
148 icon->SetQuirkDuration(AbstractLauncherIcon::Quirk::PROGRESS, ANIM_DURATION, monitor());
149 icon->SetQuirkDuration(AbstractLauncherIcon::Quirk::DESAT, ANIM_DURATION_SHORT_SHORT, monitor());
150+ icon->SetQuirkDuration(AbstractLauncherIcon::Quirk::GLOW, ANIM_DURATION_SHORT, monitor());
151
152 if (options()->urgent_animation() == URGENT_ANIMATION_WIGGLE)
153 icon->SetQuirkDuration(AbstractLauncherIcon::Quirk::URGENT, (ANIM_DURATION_SHORT * WIGGLE_CYCLES), monitor());
154@@ -2523,7 +2528,10 @@
155 }
156
157 if (!steal_drag_ && dnd_hovered_icon_)
158+ {
159 dnd_hovered_icon_->SendDndLeave();
160+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::GLOW, false, monitor());
161+ }
162
163 steal_drag_ = false;
164 drag_edge_touching_ = false;
165@@ -2581,7 +2589,10 @@
166 mouse_position_.y <= (parent_->GetGeometry().height - icon_size_.CP(cv_) - 2 * SPACE_BETWEEN_ICONS.CP(cv_)))
167 {
168 if (dnd_hovered_icon_)
169- dnd_hovered_icon_->SendDndLeave();
170+ {
171+ dnd_hovered_icon_->SendDndLeave();
172+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::GLOW, false, monitor());
173+ }
174
175 animation::StartOrReverse(dnd_hide_animation_, animation::Direction::FORWARD);
176 drag_edge_touching_ = true;
177@@ -2640,6 +2651,9 @@
178 {
179 hovered_icon->SendDndEnter();
180 drag_action_ = hovered_icon->QueryAcceptDrop(dnd_data_);
181+
182+ if (drag_action_ != nux::DNDACTION_NONE)
183+ hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::GLOW, true, monitor());
184 }
185 else
186 {
187@@ -2647,7 +2661,10 @@
188 }
189
190 if (dnd_hovered_icon_)
191+ {
192 dnd_hovered_icon_->SendDndLeave();
193+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::GLOW, false, monitor());
194+ }
195
196 dnd_hovered_icon_ = hovered_icon;
197 }
198
199=== modified file 'launcher/TrashLauncherIcon.cpp'
200--- launcher/TrashLauncherIcon.cpp 2014-01-15 14:51:10 +0000
201+++ launcher/TrashLauncherIcon.cpp 2014-04-16 02:02:27 +0000
202@@ -173,6 +173,7 @@
203 }
204
205 SetQuirk(LauncherIcon::Quirk::PULSE_ONCE, true);
206+ FullyAnimateQuirkDelayed(100, LauncherIcon::Quirk::SHIMMER);
207 }
208
209 std::string TrashLauncherIcon::GetName() const
210
211=== modified file 'launcher/VolumeLauncherIcon.cpp'
212--- launcher/VolumeLauncherIcon.cpp 2014-02-13 10:14:20 +0000
213+++ launcher/VolumeLauncherIcon.cpp 2014-04-16 02:02:27 +0000
214@@ -410,6 +410,7 @@
215 auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
216 pimpl_->CopyFilesToVolume(dnd_data.Uris(), timestamp);
217 SetQuirk(Quirk::PULSE_ONCE, true);
218+ FullyAnimateQuirkDelayed(100, LauncherIcon::Quirk::SHIMMER);
219 }
220
221 //
222
223=== modified file 'plugins/unityshell/src/unityshell.cpp'
224--- plugins/unityshell/src/unityshell.cpp 2014-04-14 14:21:46 +0000
225+++ plugins/unityshell/src/unityshell.cpp 2014-04-16 02:02:27 +0000
226@@ -517,6 +517,7 @@
227
228 void UnityScreen::OnInitiateSpread()
229 {
230+ scale_just_activated_ = super_keypressed_;
231 spread_filter_ = std::make_shared<spread::Filter>();
232 spread_filter_->text.changed.connect([this] (std::string const& filter) {
233 if (filter.empty())
234@@ -1977,19 +1978,7 @@
235 {
236 PluginAdapter& adapter = PluginAdapter::Default();
237 adapter.NotifyCompizEvent(plugin, event, option);
238- compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::handleCompizEvent (plugin, event, option);
239-
240- if (launcher_controller_->IsOverlayOpen() && g_strcmp0(event, "start_viewport_switch") == 0)
241- {
242- ubus_manager_.SendMessage(UBUS_OVERLAY_CLOSE_REQUEST);
243- }
244-
245- if (super_keypressed_ && g_strcmp0(plugin, "scale") == 0 &&
246- g_strcmp0(event, "activate") == 0)
247- {
248- scale_just_activated_ = CompOption::getBoolOptionNamed(option, "active");
249- }
250-
251+ compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::handleCompizEvent(plugin, event, option);
252 screen->handleCompizEvent(plugin, event, option);
253 }
254
255@@ -3836,8 +3825,10 @@
256 CompOption::Value v(launcher_width);
257 screen->setOptionForPlugin("expo", "x_offset", v);
258
259- if (launcher_controller_->options()->hide_mode != LAUNCHER_HIDE_NEVER)
260- screen->setOptionForPlugin("scale", "x_offset", v);
261+ if (launcher_controller_->options()->hide_mode == LAUNCHER_HIDE_NEVER)
262+ v.set(0);
263+
264+ screen->setOptionForPlugin("scale", "x_offset", v);
265 };
266
267 for (auto const& launcher : launcher_controller_->launchers())
268
269=== modified file 'unity-shared/PluginAdapter.cpp'
270--- unity-shared/PluginAdapter.cpp 2014-04-02 21:42:12 +0000
271+++ unity-shared/PluginAdapter.cpp 2014-04-16 02:02:27 +0000
272@@ -190,15 +190,34 @@
273 _vp_switch_started = false;
274 screen_viewport_switch_ended.emit();
275 }
276- else if (IsScaleActive() && g_strcmp0(plugin, "scale") == 0 &&
277- g_strcmp0(event, "activate") == 0)
278+ else if (g_strcmp0(plugin, "scale") == 0 && g_strcmp0(event, "activate") == 0)
279 {
280- // If the scale plugin is activated again while is already grabbing the screen
281- // it means that is switching the view (i.e. switching from a spread application
282- // to another), so we need to notify our clients that it has really terminated
283- // and initiated again.
284- terminate_spread.emit();
285- initiate_spread.emit();
286+ bool new_state = CompOption::getBoolOptionNamed(option, "active");
287+
288+ if (_spread_state != new_state)
289+ {
290+ _spread_state = new_state;
291+ _spread_state ? initiate_spread.emit() : terminate_spread.emit();
292+
293+ if (!_spread_state)
294+ _spread_windows_state = false;
295+ }
296+ else if (_spread_state && new_state)
297+ {
298+ // If the scale plugin is activated again while is already grabbing the screen
299+ // it means that is switching the view (i.e. switching from a spread application
300+ // to another), so we need to notify our clients that it has really terminated
301+ // and initiated again.
302+
303+ bool old_windows_state = _spread_windows_state;
304+ _spread_state = false;
305+ _spread_windows_state = false;
306+ terminate_spread.emit();
307+
308+ _spread_state = true;
309+ _spread_windows_state = old_windows_state;
310+ initiate_spread.emit();
311+ }
312 }
313 }
314