Merge lp:~azzar1/unity/lockscreen-grab-fixes into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3734
Proposed branch: lp:~azzar1/unity/lockscreen-grab-fixes
Merge into: lp:unity
Diff against target: 242 lines (+66/-31)
4 files modified
lockscreen/LockScreenController.cpp (+37/-20)
lockscreen/LockScreenController.h (+3/-0)
plugins/unityshell/src/unityshell.cpp (+4/-0)
tests/test_lockscreen_controller.cpp (+22/-11)
To merge this branch: bzr merge lp:~azzar1/unity/lockscreen-grab-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Stephen M. Webb (community) Approve
Brandon Schaefer (community) Approve
Review via email: mp+211654@code.launchpad.net

Commit message

Wait for the grab before showing the lockscreen.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM! Nice!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stephen M. Webb (bregma) wrote :

This has conflicts when merged into current trunk. Please resynch to trunk.

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

Conflicts fixed.

Revision history for this message
Stephen M. Webb (bregma) wrote :

OK

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 'lockscreen/LockScreenController.cpp'
2--- lockscreen/LockScreenController.cpp 2014-03-10 16:43:51 +0000
3+++ lockscreen/LockScreenController.cpp 2014-03-20 15:15:09 +0000
4@@ -20,6 +20,8 @@
5 #include "LockScreenController.h"
6
7 #include <UnityCore/DBusIndicators.h>
8+#include <NuxCore/Logger.h>
9+
10 #include "LockScreenShield.h"
11 #include "LockScreenSettings.h"
12 #include "unity-shared/AnimationUtils.h"
13@@ -40,6 +42,8 @@
14 const std::string DBUS_NAME = "com.canonical.Unity.Test.DisplayManager";
15 }
16
17+DECLARE_LOGGER(logger, "unity.locksreen");
18+
19 Controller::Controller(session::Manager::Ptr const& session_manager,
20 UpstartWrapper::Ptr const& upstart_wrapper,
21 ShieldFactoryInterface::Ptr const& shield_factory,
22@@ -145,26 +149,39 @@
23 void Controller::OnLockRequested()
24 {
25 if (IsLocked())
26- return;
27-
28- auto lockscreen_type = Settings::Instance().lockscreen_type();
29-
30- if (lockscreen_type == Type::NONE)
31- {
32- session_manager_->unlocked.emit();
33- return;
34- }
35-
36- if (lockscreen_type == Type::LIGHTDM)
37- {
38- LockScreenUsingDisplayManager();
39- }
40- else if (lockscreen_type == Type::UNITY)
41- {
42- LockScreenUsingUnity();
43- }
44-
45- session_manager_->locked.emit();
46+ {
47+ LOG_DEBUG(logger) << "Failed to lock screen: the screen is already locked.";
48+ return;
49+ }
50+
51+ lockscreen_timeout_.reset(new glib::Timeout(10, [this](){
52+ if (WindowManager::Default().IsScreenGrabbed())
53+ {
54+ LOG_DEBUG(logger) << "Failed to lock the screen: the screen is already grabbed.";
55+ return true; // keep trying
56+ }
57+
58+ auto lockscreen_type = Settings::Instance().lockscreen_type();
59+
60+ if (lockscreen_type == Type::NONE)
61+ {
62+ session_manager_->unlocked.emit();
63+ return false;
64+ }
65+
66+ if (lockscreen_type == Type::LIGHTDM)
67+ {
68+ LockScreenUsingDisplayManager();
69+ }
70+ else if (lockscreen_type == Type::UNITY)
71+ {
72+ LockScreenUsingUnity();
73+ }
74+
75+ session_manager_->locked.emit();
76+
77+ return false;
78+ }));
79 }
80
81 void Controller::LockScreenUsingDisplayManager()
82
83=== modified file 'lockscreen/LockScreenController.h'
84--- lockscreen/LockScreenController.h 2014-03-07 19:17:35 +0000
85+++ lockscreen/LockScreenController.h 2014-03-20 15:15:09 +0000
86@@ -22,6 +22,7 @@
87
88 #include <NuxCore/Animation.h>
89 #include <UnityCore/ConnectionManager.h>
90+#include <UnityCore/GLibSource.h>
91
92 #include "LockScreenShieldFactory.h"
93 #include "unity-shared/BackgroundEffectHelper.h"
94@@ -68,6 +69,8 @@
95 connection::Wrapper motion_connection_;
96 bool test_mode_;
97 BlurType old_blur_type_;
98+
99+ glib::Source::UniquePtr lockscreen_timeout_;
100 };
101
102 }
103
104=== modified file 'plugins/unityshell/src/unityshell.cpp'
105--- plugins/unityshell/src/unityshell.cpp 2014-03-18 23:53:41 +0000
106+++ plugins/unityshell/src/unityshell.cpp 2014-03-20 15:15:09 +0000
107@@ -3736,6 +3736,10 @@
108
109 launcher_controller_->ClearTooltips();
110
111+ auto& adapter = PluginAdapter::Default();
112+ if (adapter.IsScaleActive())
113+ adapter.TerminateScale();
114+
115 RaiseOSK();
116 }
117
118
119=== modified file 'tests/test_lockscreen_controller.cpp'
120--- tests/test_lockscreen_controller.cpp 2014-03-07 19:17:35 +0000
121+++ tests/test_lockscreen_controller.cpp 2014-03-20 15:15:09 +0000
122@@ -180,8 +180,8 @@
123 lockscreen_settings.lockscreen_type = Type::LIGHTDM;
124 session_manager->lock_requested.emit();
125
126- ASSERT_EQ(1, controller.shields_.size());
127- EXPECT_FALSE(controller.shields_.at(0)->primary());
128+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
129+ Utils::WaitUntilMSec([this]{ return controller.shields_.at(0)->primary() == false; });
130 Utils::WaitUntilMSec(lock_called);
131 }
132
133@@ -202,10 +202,10 @@
134 uscreen.SetupFakeMultiMonitor(/*primary*/ 0, /*emit_change*/ true);
135 session_manager->lock_requested.emit();
136
137- ASSERT_EQ(monitors::MAX, controller.shields_.size());
138+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; });
139
140 for (unsigned int i=0; i < monitors::MAX; ++i)
141- EXPECT_FALSE(controller.shields_.at(i)->primary());
142+ Utils::WaitUntilMSec([this, i]{ return controller.shields_.at(i)->primary() == false; });
143
144 Utils::WaitUntilMSec(lock_called);
145 }
146@@ -226,7 +226,7 @@
147 lockscreen_settings.lockscreen_type = Type::LIGHTDM;
148 session_manager->lock_requested.emit();
149
150- ASSERT_EQ(1, controller.shields_.size());
151+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
152 Utils::WaitUntilMSec(lock_called);
153
154 session_manager->unlock_requested.emit();
155@@ -252,7 +252,7 @@
156 uscreen.SetupFakeMultiMonitor(/*primary*/ 0, /*emit_change*/ true);
157 session_manager->lock_requested.emit();
158
159- ASSERT_EQ(monitors::MAX, controller.shields_.size());
160+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; });
161 Utils::WaitUntilMSec(lock_called);
162
163 session_manager->unlock_requested.emit();
164@@ -265,8 +265,8 @@
165 {
166 session_manager->lock_requested.emit();
167
168- ASSERT_EQ(1, controller.shields_.size());
169- EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry());
170+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
171+ Utils::WaitUntilMSec([this]{ return uscreen.GetMonitors().at(0) == controller.shields_.at(0)->GetGeometry(); });
172 }
173
174 TEST_F(TestLockScreenController, LockScreenOnMultiMonitor)
175@@ -274,28 +274,33 @@
176 uscreen.SetupFakeMultiMonitor();
177
178 session_manager->lock_requested.emit();
179+
180+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; });
181 ASSERT_EQ(monitors::MAX, controller.shields_.size());
182
183 for (unsigned int i=0; i < monitors::MAX; ++i)
184+ {
185+ Utils::WaitUntilMSec([this, i]{ return uscreen.GetMonitors().at(i) == controller.shields_.at(i)->GetGeometry(); });
186 EXPECT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry());
187+ }
188 }
189
190 TEST_F(TestLockScreenController, SwitchToMultiMonitor)
191 {
192 session_manager->lock_requested.emit();
193- tick_source.tick(ANIMATION_DURATION);
194
195+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
196 ASSERT_EQ(1, controller.shields_.size());
197+
198+ Utils::WaitUntilMSec([this]{ return uscreen.GetMonitors().at(0) == controller.shields_.at(0)->GetGeometry(); });
199 EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry());
200
201 uscreen.SetupFakeMultiMonitor(/* primary */ 0, /* emit_change */ true);
202-
203 ASSERT_EQ(monitors::MAX, controller.shields_.size());
204
205 for (unsigned int i=0; i < monitors::MAX; ++i)
206 {
207 ASSERT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry());
208- ASSERT_TRUE(controller.shields_.at(i)->IsVisible());
209 }
210 }
211
212@@ -304,10 +309,14 @@
213 uscreen.SetupFakeMultiMonitor(/* primary */ 0, /* emit_change */ true);
214 session_manager->lock_requested.emit();
215
216+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; });
217 ASSERT_EQ(monitors::MAX, controller.shields_.size());
218
219 for (unsigned int i=0; i < monitors::MAX; ++i)
220+ {
221+ Utils::WaitUntilMSec([this, i]{ return uscreen.GetMonitors().at(i) == controller.shields_.at(i)->GetGeometry(); });
222 ASSERT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry());
223+ }
224
225 uscreen.Reset(/* emit_change */ true);
226
227@@ -319,6 +328,7 @@
228 {
229 session_manager->lock_requested.emit();
230
231+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; });
232 ASSERT_EQ(1, controller.shields_.size());
233
234 session_manager->unlock_requested.emit();
235@@ -332,6 +342,7 @@
236 uscreen.SetupFakeMultiMonitor(/* primary */ 0, /* emit_change */ true);
237 session_manager->lock_requested.emit();
238
239+ Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; });
240 ASSERT_EQ(monitors::MAX, controller.shields_.size());
241
242 session_manager->unlock_requested.emit();