Merge lp:~unity-team/unity/trusty-1368427 into lp:unity/7.2

Proposed by Stephen M. Webb
Status: Rejected
Rejected by: Stephen M. Webb
Proposed branch: lp:~unity-team/unity/trusty-1368427
Merge into: lp:unity/7.2
Diff against target: 432 lines (+124/-19)
16 files modified
UnityCore/DBusIndicators.cpp (+11/-0)
UnityCore/DBusIndicators.h (+1/-0)
UnityCore/Indicators.h (+1/-0)
debian/changelog (+7/-0)
lockscreen/LockScreenAbstractShield.h (+3/-0)
lockscreen/LockScreenController.cpp (+33/-11)
lockscreen/LockScreenController.h (+2/-2)
lockscreen/LockScreenPanel.cpp (+28/-1)
lockscreen/LockScreenShield.cpp (+9/-5)
lockscreen/LockScreenShield.h (+1/-0)
plugins/unityshell/src/unityshell.cpp (+1/-0)
services/panel-main.c (+8/-0)
services/panel-service.c (+15/-0)
services/panel-service.h (+2/-0)
tests/mock_indicators.h (+1/-0)
tests/test_lockscreen_controller.cpp (+1/-0)
To merge this branch: bzr merge lp:~unity-team/unity/trusty-1368427
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+244161@code.launchpad.net

Commit message

LockScreenController: wait for the primary shield to get the grab before setting the session locked

Description of the change

LockScreenController: waits for the primary shield to get the grab before setting the session locked (fixes #1368427, #1371764).

This change is cherry-picked from trunk for SRUing into Ubuntu 14.04 LTS.

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/DBusIndicators.cpp'
2--- UnityCore/DBusIndicators.cpp 2014-03-05 17:19:50 +0000
3+++ UnityCore/DBusIndicators.cpp 2014-12-09 15:45:13 +0000
4@@ -55,6 +55,7 @@
5 void Sync(GVariant* args, glib::Error const&);
6 void SyncGeometries(std::string const& name, EntryLocationMap const& locations);
7 void ShowEntriesDropdown(Indicator::Entries const&, Entry::Ptr const&, unsigned xid, int x, int y);
8+ void CloseActiveEntry();
9
10 void OnConnected();
11 void OnDisconnected();
12@@ -313,6 +314,11 @@
13 gproxy_.Call("ScrollEntry", g_variant_new("(si)", entry_id.c_str(), delta));
14 }
15
16+void DBusIndicators::Impl::CloseActiveEntry()
17+{
18+ gproxy_.Call("CloseActiveEntry");
19+}
20+
21 void DBusIndicators::Impl::Sync(GVariant* args, glib::Error const& error)
22 {
23 if (!args || error)
24@@ -489,6 +495,11 @@
25 pimpl->ShowEntriesDropdown(entries, selected, xid, x, y);
26 }
27
28+void DBusIndicators::CloseActiveEntry()
29+{
30+ pimpl->CloseActiveEntry();
31+}
32+
33 void DBusIndicators::OnEntryScroll(std::string const& entry_id, int delta)
34 {
35 pimpl->OnEntryScroll(entry_id, delta);
36
37=== modified file 'UnityCore/DBusIndicators.h'
38--- UnityCore/DBusIndicators.h 2014-03-04 13:14:12 +0000
39+++ UnityCore/DBusIndicators.h 2014-12-09 15:45:13 +0000
40@@ -40,6 +40,7 @@
41 std::vector<std::string> const& IconPaths() const;
42 void ShowEntriesDropdown(Indicator::Entries const&, Entry::Ptr const&, unsigned xid, int x, int y);
43 void SyncGeometries(std::string const& name, EntryLocationMap const& locations);
44+ void CloseActiveEntry();
45
46 protected:
47 virtual void OnEntryScroll(std::string const& entry_id, int delta);
48
49=== modified file 'UnityCore/Indicators.h'
50--- UnityCore/Indicators.h 2014-02-28 05:16:10 +0000
51+++ UnityCore/Indicators.h 2014-12-09 15:45:13 +0000
52@@ -44,6 +44,7 @@
53
54 virtual void SyncGeometries(std::string const& panel, EntryLocationMap const&) = 0;
55 virtual void ShowEntriesDropdown(Indicator::Entries const&, Entry::Ptr const&, unsigned xid, int x, int y) = 0;
56+ virtual void CloseActiveEntry() = 0;
57
58 // Signals
59 sigc::signal<void, Indicator::Ptr const&> on_object_added;
60
61=== modified file 'debian/changelog'
62--- debian/changelog 2014-08-26 13:49:00 +0000
63+++ debian/changelog 2014-12-09 15:45:13 +0000
64@@ -1,3 +1,10 @@
65+unity (7.2.3+14.04.20140826-0ubuntu2) UNRELEASED; urgency=medium
66+
67+ * LockScreenController: wait for the primary shield to get the grab
68+ before setting the session locked (lp: #1368427) (lp: #1371764).
69+
70+ -- Marco Trevisan (TreviƱo) <mail@3v1n0.net> Tue, 09 Dec 2014 10:35:42 -0500
71+
72 unity (7.2.3+14.04.20140826-0ubuntu1) trusty; urgency=medium
73
74 [ Andrea Azzarone ]
75
76=== modified file 'lockscreen/LockScreenAbstractShield.h'
77--- lockscreen/LockScreenAbstractShield.h 2014-06-23 19:42:24 +0000
78+++ lockscreen/LockScreenAbstractShield.h 2014-12-09 15:45:13 +0000
79@@ -48,9 +48,12 @@
80 nux::Property<int> monitor;
81
82 using MockableBaseWindow::RemoveLayout;
83+ virtual bool HasGrab() const = 0;
84 virtual bool IsIndicatorOpen() const = 0;
85 virtual void ActivatePanel() = 0;
86
87+ sigc::signal<void> grabbed;
88+ sigc::signal<void> grab_failed;
89 sigc::signal<void, int, int> grab_motion;
90 sigc::signal<void, unsigned long, unsigned long> grab_key;
91
92
93=== modified file 'lockscreen/LockScreenController.cpp'
94--- lockscreen/LockScreenController.cpp 2014-08-06 14:11:17 +0000
95+++ lockscreen/LockScreenController.cpp 2014-12-09 15:45:13 +0000
96@@ -100,8 +100,7 @@
97 fade_animator_.finished.connect([this] {
98 if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD)
99 {
100- motion_connection_->disconnect();
101- key_connection_->disconnect();
102+ primary_shield_connections_.Clear();
103 uscreen_connection_->block();
104 hidden_window_connection_->block();
105 session_manager_->is_locked = false;
106@@ -173,10 +172,7 @@
107 primary_shield_ = shield;
108 shield->primary = true;
109 nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer());
110- auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);
111- motion_connection_ = shield->grab_motion.connect(move_cb);
112- auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
113- key_connection_ = shield->grab_key.connect(key_cb);
114+ SetupPrimaryShieldConnections();
115 break;
116 }
117 }
118@@ -184,6 +180,35 @@
119 ResetPostLockScreenSaver();
120 }
121
122+void Controller::SetupPrimaryShieldConnections()
123+{
124+ if (!primary_shield_.IsValid())
125+ return;
126+
127+ primary_shield_connections_.Clear();
128+
129+ auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);
130+ primary_shield_connections_.Add(primary_shield_->grab_motion.connect(move_cb));
131+
132+ auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
133+ primary_shield_connections_.Add(primary_shield_->grab_key.connect(key_cb));
134+
135+ if (!session_manager_->is_locked())
136+ {
137+ primary_shield_connections_.Add(primary_shield_->grabbed.connect([this] {
138+ session_manager_->is_locked = true;
139+ }));
140+
141+ primary_shield_connections_.Add(primary_shield_->grab_failed.connect([this] {
142+ if (!session_manager_->is_locked())
143+ {
144+ LOG_ERROR(logger) << "Impossible to get the grab to lock the screen";
145+ session_manager_->unlock_requested.emit();
146+ }
147+ }));
148+ }
149+}
150+
151 void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors)
152 {
153 int num_monitors = monitors.size();
154@@ -224,10 +249,7 @@
155
156 primary_shield_ = shields_[primary];
157 primary_shield_->primary = true;
158- auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);
159- motion_connection_ = primary_shield_->grab_motion.connect(move_cb);
160- auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
161- key_connection_ = primary_shield_->grab_key.connect(key_cb);
162+ SetupPrimaryShieldConnections();
163 }
164
165 void Controller::EnsureBlankWindow()
166@@ -349,7 +371,6 @@
167 HideBlankWindow();
168
169 LockScreen();
170- session_manager_->is_locked = true;
171
172 if (prompt_activation_)
173 {
174@@ -435,6 +456,7 @@
175 shield->PushToFront();
176 });
177
178+ session_manager_->is_locked = primary_shield_->HasGrab();
179 nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer());
180 animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
181 }
182
183=== modified file 'lockscreen/LockScreenController.h'
184--- lockscreen/LockScreenController.h 2014-06-23 19:21:17 +0000
185+++ lockscreen/LockScreenController.h 2014-12-09 15:45:13 +0000
186@@ -61,6 +61,7 @@
187 void BlankWindowGrabEnable(bool grab);
188 void SimulateActivity();
189 void ResetPostLockScreenSaver();
190+ void SetupPrimaryShieldConnections();
191 void ActivatePanel();
192
193 void OnLockRequested(bool prompt);
194@@ -90,8 +91,7 @@
195 connection::Wrapper uscreen_connection_;
196 connection::Wrapper suspend_connection_;
197 connection::Wrapper hidden_window_connection_;
198- connection::Wrapper motion_connection_;
199- connection::Wrapper key_connection_;
200+ connection::Manager primary_shield_connections_;
201
202 glib::Source::UniquePtr lockscreen_timeout_;
203 glib::Source::UniquePtr lockscreen_delay_timeout_;
204
205=== modified file 'lockscreen/LockScreenPanel.cpp'
206--- lockscreen/LockScreenPanel.cpp 2014-06-23 15:29:36 +0000
207+++ lockscreen/LockScreenPanel.cpp 2014-12-09 15:45:13 +0000
208@@ -108,12 +108,39 @@
209 return;
210
211 indicators_view_->AddIndicator(indicator);
212+
213+ if (!active)
214+ {
215+ for (auto const& entry : indicator->GetEntries())
216+ {
217+ if (entry->active())
218+ {
219+ active = true;
220+ indicators_view_->ActivateEntry(entry->id());
221+ OnEntryActivated(GetPanelName(), entry->id(), entry->geometry());
222+ break;
223+ }
224+ }
225+ }
226+
227 QueueRelayout();
228 QueueDraw();
229 }
230
231 void Panel::RemoveIndicator(indicator::Indicator::Ptr const& indicator)
232 {
233+ if (active)
234+ {
235+ for (auto const& entry : indicator->GetEntries())
236+ {
237+ if (entry->active())
238+ {
239+ active = false;
240+ break;
241+ }
242+ }
243+ }
244+
245 indicators_view_->RemoveIndicator(indicator);
246 QueueRelayout();
247 QueueDraw();
248@@ -121,7 +148,7 @@
249
250 std::string Panel::GetPanelName() const
251 {
252- return "LockScreenPanel" + std::to_string(monitor);
253+ return "LockScreenPanel";
254 }
255
256 void Panel::OnIndicatorViewUpdated()
257
258=== modified file 'lockscreen/LockScreenShield.cpp'
259--- lockscreen/LockScreenShield.cpp 2014-08-06 14:11:17 +0000
260+++ lockscreen/LockScreenShield.cpp 2014-12-09 15:45:13 +0000
261@@ -19,7 +19,6 @@
262
263 #include "LockScreenShield.h"
264
265-#include <NuxCore/Logger.h>
266 #include <Nux/VLayout.h>
267 #include <Nux/HLayout.h>
268 #include <Nux/PaintLayer.h>
269@@ -38,8 +37,7 @@
270 {
271 namespace
272 {
273-DECLARE_LOGGER(logger, "unity.lockscreen.shield");
274-const unsigned MAX_GRAB_WAIT = 50;
275+const unsigned MAX_GRAB_WAIT = 100;
276 }
277
278 Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, Accelerators::Ptr const& accelerators, int monitor_num, bool is_primary)
279@@ -95,6 +93,7 @@
280 {
281 regrab_conn_->disconnect();
282 regrab_timeout_.reset();
283+ grabbed.emit();
284 }
285 else
286 {
287@@ -104,14 +103,19 @@
288 if (cancel_on_failure)
289 {
290 regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] {
291- LOG_ERROR(logger) << "Impossible to get the grab to lock the screen";
292- session_manager_->unlock_requested.emit();
293+ grab_failed.emit();
294 return false;
295 }));
296 }
297 }
298 }
299
300+bool Shield::HasGrab() const
301+{
302+ auto& wc = nux::GetWindowCompositor();
303+ return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);
304+}
305+
306 void Shield::ShowPrimaryView()
307 {
308 if (primary_layout_)
309
310=== modified file 'lockscreen/LockScreenShield.h'
311--- lockscreen/LockScreenShield.h 2014-08-06 14:11:17 +0000
312+++ lockscreen/LockScreenShield.h 2014-12-09 15:45:13 +0000
313@@ -39,6 +39,7 @@
314 public:
315 Shield(session::Manager::Ptr const&, indicator::Indicators::Ptr const&, Accelerators::Ptr const&, int monitor, bool is_primary);
316
317+ bool HasGrab() const override;
318 bool IsIndicatorOpen() const override;
319 void ActivatePanel() override;
320
321
322=== modified file 'plugins/unityshell/src/unityshell.cpp'
323--- plugins/unityshell/src/unityshell.cpp 2014-08-06 14:19:10 +0000
324+++ plugins/unityshell/src/unityshell.cpp 2014-12-09 15:45:13 +0000
325@@ -3781,6 +3781,7 @@
326 if (hud_controller_->IsVisible())
327 hud_controller_->HideHud();
328
329+ menus_->Indicators()->CloseActiveEntry();
330 launcher_controller_->ClearTooltips();
331
332 if (launcher_controller_->KeyNavIsActive())
333
334=== modified file 'services/panel-main.c'
335--- services/panel-main.c 2014-03-05 17:19:50 +0000
336+++ services/panel-main.c 2014-12-09 15:45:13 +0000
337@@ -82,6 +82,9 @@
338 " <arg type='i' name='delta' direction='in'/>"
339 " </method>"
340 ""
341+ ""
342+ " <method name='CloseActiveEntry' />"
343+ ""
344 " <signal name='EntryActivated'>"
345 " <arg type='s' name='panel_id' />"
346 " <arg type='s' name='entry_id' />"
347@@ -254,6 +257,11 @@
348 g_dbus_method_invocation_return_value (invocation, NULL);
349 g_free(entry_id);
350 }
351+ else if (g_strcmp0 (method_name, "CloseActiveEntry") == 0)
352+ {
353+ panel_service_close_active_entry (service);
354+ g_dbus_method_invocation_return_value (invocation, NULL);
355+ }
356 }
357
358 static void
359
360=== modified file 'services/panel-service.c'
361--- services/panel-service.c 2014-08-06 14:19:10 +0000
362+++ services/panel-service.c 2014-12-09 15:45:13 +0000
363@@ -2383,6 +2383,8 @@
364 IndicatorObject *object;
365 IndicatorObjectEntry *entry;
366
367+ g_return_if_fail (PANEL_IS_SERVICE (self));
368+
369 entry = get_indicator_entry_by_id (self, entry_id);
370 g_return_if_fail (entry);
371
372@@ -2399,6 +2401,8 @@
373 IndicatorObject *object;
374 IndicatorObjectEntry *entry;
375
376+ g_return_if_fail (PANEL_IS_SERVICE (self));
377+
378 entry = get_indicator_entry_by_id (self, entry_id);
379 g_return_if_fail (entry);
380
381@@ -2427,3 +2431,14 @@
382 entry, 1, direction);
383 }
384 }
385+
386+void
387+panel_service_close_active_entry (PanelService *self)
388+{
389+ g_return_if_fail (PANEL_IS_SERVICE (self));
390+
391+ if (GTK_IS_MENU (self->priv->last_menu))
392+ {
393+ gtk_menu_popdown (GTK_MENU (self->priv->last_menu));
394+ }
395+}
396
397=== modified file 'services/panel-service.h'
398--- services/panel-service.h 2014-02-06 12:02:48 +0000
399+++ services/panel-service.h 2014-12-09 15:45:13 +0000
400@@ -122,6 +122,8 @@
401 const gchar *entry_id,
402 gint32 delta);
403
404+void panel_service_close_active_entry (PanelService *self);
405+
406 G_END_DECLS
407
408 #endif /* _PANEL_SERVICE_H_ */
409
410=== modified file 'tests/mock_indicators.h'
411--- tests/mock_indicators.h 2014-02-28 05:16:10 +0000
412+++ tests/mock_indicators.h 2014-12-09 15:45:13 +0000
413@@ -36,6 +36,7 @@
414 // Implementing Indicators virtual functions
415 MOCK_METHOD2(SyncGeometries, void(std::string const&, EntryLocationMap const&));
416 MOCK_METHOD5(ShowEntriesDropdown, void(Indicator::Entries const&, Entry::Ptr const&, unsigned xid, int x, int y));
417+ MOCK_METHOD0(CloseActiveEntry, void());
418 MOCK_CONST_METHOD0(IconPaths, std::vector<std::string> const&());
419 MOCK_METHOD2(OnEntryScroll, void(std::string const&, int delta));
420 MOCK_METHOD5(OnEntryShowMenu, void(std::string const&, unsigned xid, int x, int y, unsigned button));
421
422=== modified file 'tests/test_lockscreen_controller.cpp'
423--- tests/test_lockscreen_controller.cpp 2014-06-23 19:42:24 +0000
424+++ tests/test_lockscreen_controller.cpp 2014-12-09 15:45:13 +0000
425@@ -57,6 +57,7 @@
426
427 MOCK_CONST_METHOD0(IsIndicatorOpen, bool());
428 MOCK_METHOD0(ActivatePanel, void());
429+ MOCK_CONST_METHOD0(HasGrab, bool());
430 };
431
432 struct ShieldFactoryMock : ShieldFactoryInterface

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: