Merge lp:~3v1n0/unity/lockscreen-prompt-activation into lp:unity
- lockscreen-prompt-activation
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3765 |
Proposed branch: | lp:~3v1n0/unity/lockscreen-prompt-activation |
Merge into: | lp:unity |
Prerequisite: | lp:~3v1n0/unity/lockscreen-disable-with-osk |
Diff against target: |
742 lines (+236/-121) 14 files modified
UnityCore/GnomeSessionManager.cpp (+42/-10) UnityCore/GnomeSessionManager.h (+3/-0) UnityCore/GnomeSessionManagerImpl.h (+1/-0) UnityCore/SessionManager.h (+5/-0) lockscreen/BackgroundSettings.cpp (+1/-1) lockscreen/LockScreenController.cpp (+120/-90) lockscreen/LockScreenController.h (+3/-3) lockscreen/ScreenSaverDBusManager.cpp (+10/-14) lockscreen/ScreenSaverDBusManager.h (+0/-2) plugins/unityshell/src/unityshell.cpp (+1/-1) shutdown/SessionDBusManager.cpp (+18/-0) shutdown/StandaloneSession.cpp (+3/-0) tests/test_gnome_session_manager.cpp (+26/-0) tests/test_mock_session_manager.h (+3/-0) |
To merge this branch: | bzr merge lp:~3v1n0/unity/lockscreen-prompt-activation |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+215075@code.launchpad.net |
Commit message
LockScreen: add ability to show without fading in on some system calls
Also, if locking is not enabled, calling Lock causes the screensaver to be initiated.
Many cleanups and misc fixes.
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3778
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'UnityCore/GnomeSessionManager.cpp' |
2 | --- UnityCore/GnomeSessionManager.cpp 2014-04-10 06:37:15 +0000 |
3 | +++ UnityCore/GnomeSessionManager.cpp 2014-04-10 06:37:15 +0000 |
4 | @@ -72,6 +72,9 @@ |
5 | { |
6 | const std::string SESSION_OPTIONS = "com.canonical.indicator.session"; |
7 | const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown"; |
8 | + |
9 | +const std::string GNOME_LOCKDOWN_OPTIONS = "org.gnome.desktop.lockdown"; |
10 | +const std::string DISABLE_LOCKSCREEN_KEY = "disable-lock-screen"; |
11 | } |
12 | |
13 | GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode) |
14 | @@ -96,7 +99,7 @@ |
15 | test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM); |
16 | |
17 | login_proxy_->Connect("Lock", [this](GVariant*){ |
18 | - manager_->LockScreen(); |
19 | + manager_->PromptLockScreen(); |
20 | }); |
21 | |
22 | login_proxy_->Connect("Unlock", [this](GVariant*){ |
23 | @@ -397,6 +400,28 @@ |
24 | }); |
25 | } |
26 | |
27 | +void GnomeManager::Impl::LockScreen(bool prompt) |
28 | +{ |
29 | + EnsureCancelPendingAction(); |
30 | + |
31 | + // FIXME (andy) we should ask gnome-session to emit the logind signal |
32 | + glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str())); |
33 | + |
34 | + if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str())) |
35 | + { |
36 | + manager_->ScreenSaverActivate(); |
37 | + return; |
38 | + } |
39 | + else if (manager_->UserName().find("guest-") == 0) |
40 | + { |
41 | + LOG_INFO(logger) << "Impossible to lock a guest session"; |
42 | + manager_->ScreenSaverActivate(); |
43 | + return; |
44 | + } |
45 | + |
46 | + prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit(); |
47 | +} |
48 | + |
49 | // Public implementation |
50 | |
51 | GnomeManager::GnomeManager() |
52 | @@ -430,17 +455,24 @@ |
53 | return glib::gchar_to_string(g_get_host_name()); |
54 | } |
55 | |
56 | +void GnomeManager::ScreenSaverActivate() |
57 | +{ |
58 | + screensaver_requested.emit(true); |
59 | +} |
60 | + |
61 | +void GnomeManager::ScreenSaverDeactivate() |
62 | +{ |
63 | + screensaver_requested.emit(false); |
64 | +} |
65 | + |
66 | void GnomeManager::LockScreen() |
67 | { |
68 | - impl_->EnsureCancelPendingAction(); |
69 | + impl_->LockScreen(false); |
70 | +} |
71 | |
72 | - // FIXME (andy) we should ask gnome-session to emit the logind signal |
73 | - if (UserName().find("guest-") == 0) |
74 | - { |
75 | - LOG_INFO(logger) << "Impossible to lock a guest session"; |
76 | - return; |
77 | - } |
78 | - lock_requested.emit(); |
79 | +void GnomeManager::PromptLockScreen() |
80 | +{ |
81 | + impl_->LockScreen(true); |
82 | } |
83 | |
84 | void GnomeManager::Logout() |
85 | @@ -538,7 +570,7 @@ |
86 | impl_->EnsureCancelPendingAction(); |
87 | impl_->CallLogindMethod("Suspend", g_variant_new("(b)", FALSE), [this] (GVariant* variant, glib::Error const& err) { |
88 | // fallback to UPower |
89 | - if (err) |
90 | + if (err) |
91 | impl_->CallUPowerMethod("Suspend"); |
92 | }); |
93 | } |
94 | |
95 | === modified file 'UnityCore/GnomeSessionManager.h' |
96 | --- UnityCore/GnomeSessionManager.h 2014-03-06 07:15:19 +0000 |
97 | +++ UnityCore/GnomeSessionManager.h 2014-04-10 06:37:15 +0000 |
98 | @@ -37,7 +37,10 @@ |
99 | std::string UserName() const; |
100 | std::string HostName() const; |
101 | |
102 | + void ScreenSaverActivate(); |
103 | + void ScreenSaverDeactivate(); |
104 | void LockScreen(); |
105 | + void PromptLockScreen(); |
106 | void Logout(); |
107 | void Reboot(); |
108 | void Shutdown(); |
109 | |
110 | === modified file 'UnityCore/GnomeSessionManagerImpl.h' |
111 | --- UnityCore/GnomeSessionManagerImpl.h 2014-04-10 06:37:15 +0000 |
112 | +++ UnityCore/GnomeSessionManagerImpl.h 2014-04-10 06:37:15 +0000 |
113 | @@ -52,6 +52,7 @@ |
114 | void CancelAction(); |
115 | void ClosedDialog(); |
116 | void EnsureCancelPendingAction(); |
117 | + void LockScreen(bool prompt); |
118 | |
119 | GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters); |
120 | void CallGnomeSessionMethod(std::string const& method, GVariant* parameters = nullptr, |
121 | |
122 | === modified file 'UnityCore/SessionManager.h' |
123 | --- UnityCore/SessionManager.h 2014-04-10 06:37:15 +0000 |
124 | +++ UnityCore/SessionManager.h 2014-04-10 06:37:15 +0000 |
125 | @@ -40,7 +40,10 @@ |
126 | virtual std::string UserName() const = 0; |
127 | virtual std::string HostName() const = 0; |
128 | |
129 | + virtual void ScreenSaverActivate() = 0; |
130 | + virtual void ScreenSaverDeactivate() = 0; |
131 | virtual void LockScreen() = 0; |
132 | + virtual void PromptLockScreen() = 0; |
133 | virtual void Logout() = 0; |
134 | virtual void Reboot() = 0; |
135 | virtual void Shutdown() = 0; |
136 | @@ -59,12 +62,14 @@ |
137 | |
138 | sigc::signal<void> lock_requested; |
139 | sigc::signal<void> unlock_requested; |
140 | + sigc::signal<void> prompt_lock_requested; |
141 | sigc::signal<void> locked; |
142 | sigc::signal<void> unlocked; |
143 | sigc::signal<void, bool /* inhibitors */> logout_requested; |
144 | sigc::signal<void, bool /* inhibitors */> reboot_requested; |
145 | sigc::signal<void, bool /* inhibitors */> shutdown_requested; |
146 | sigc::signal<void, bool /* is_idle */> presence_status_changed; |
147 | + sigc::signal<void, bool /* active */> screensaver_requested; |
148 | |
149 | sigc::signal<void> cancel_requested; |
150 | }; |
151 | |
152 | === modified file 'lockscreen/BackgroundSettings.cpp' |
153 | --- lockscreen/BackgroundSettings.cpp 2014-03-07 18:34:03 +0000 |
154 | +++ lockscreen/BackgroundSettings.cpp 2014-04-10 06:37:15 +0000 |
155 | @@ -110,7 +110,7 @@ |
156 | int width = geo.width; |
157 | int height = geo.height; |
158 | int grid_x_offset = GetGridOffset(width); |
159 | - int grid_y_offset = GetGridOffset(height) + panel::Style().Instance().PanelHeight(monitor); |
160 | + int grid_y_offset = GetGridOffset(height) + panel::Style::Instance().PanelHeight(monitor); |
161 | |
162 | // overlay grid |
163 | cairo_surface_t* overlay_surface = cairo_surface_create_similar(cairo_graphics.GetSurface(), |
164 | |
165 | === modified file 'lockscreen/LockScreenController.cpp' |
166 | --- lockscreen/LockScreenController.cpp 2014-04-10 06:37:15 +0000 |
167 | +++ lockscreen/LockScreenController.cpp 2014-04-10 06:37:15 +0000 |
168 | @@ -36,7 +36,15 @@ |
169 | { |
170 | const unsigned int IDLE_FADE_DURATION = 10000; |
171 | const unsigned int LOCK_FADE_DURATION = 400; |
172 | -const unsigned int POST_LOCK_SCREENSAVER_WAIT = 2000; |
173 | +const unsigned int POST_LOCK_SCREENSAVER_WAIT = 2; |
174 | + |
175 | +class BlankWindow : public nux::BaseWindow |
176 | +{ |
177 | +public: |
178 | + BlankWindow() : nux::BaseWindow("UnityScreensaver") {} |
179 | + bool AcceptKeyNavFocus() override { return true; } |
180 | + bool InspectKeyEvent(unsigned int, unsigned int, const char*) override { return true; }; |
181 | +}; |
182 | } |
183 | |
184 | DECLARE_LOGGER(logger, "unity.lockscreen"); |
185 | @@ -54,7 +62,7 @@ |
186 | , fade_animator_(LOCK_FADE_DURATION) |
187 | , blank_window_animator_(IDLE_FADE_DURATION) |
188 | , test_mode_(test_mode) |
189 | - , skip_animation_(false) |
190 | + , prompt_activation_(false) |
191 | { |
192 | auto* uscreen = UScreen::GetDefault(); |
193 | uscreen_connection_ = uscreen->changed.connect([this] (int, std::vector<nux::Geometry> const& monitors) { |
194 | @@ -66,12 +74,13 @@ |
195 | |
196 | suspend_connection_ = uscreen->suspending.connect([this] { |
197 | if (Settings::Instance().lock_on_suspend()) |
198 | - RequestPromptScreenLock(); |
199 | + session_manager_->PromptLockScreen(); |
200 | }); |
201 | |
202 | dbus_manager_->simulate_activity.connect(sigc::mem_fun(this, &Controller::SimulateActivity)); |
203 | - dbus_manager_->request_activate.connect(sigc::mem_fun(this, &Controller::OnScreenSaverActivationRequest)); |
204 | - session_manager_->lock_requested.connect(sigc::mem_fun(this, &Controller::OnLockRequested)); |
205 | + session_manager_->screensaver_requested.connect(sigc::mem_fun(this, &Controller::OnScreenSaverActivationRequest)); |
206 | + session_manager_->lock_requested.connect(sigc::bind(sigc::mem_fun(this, &Controller::OnLockRequested), false)); |
207 | + session_manager_->prompt_lock_requested.connect(sigc::bind(sigc::mem_fun(this, &Controller::OnLockRequested), true)); |
208 | session_manager_->unlock_requested.connect(sigc::mem_fun(this, &Controller::OnUnlockRequested)); |
209 | session_manager_->presence_status_changed.connect(sigc::mem_fun(this, &Controller::OnPresenceStatusChanged)); |
210 | |
211 | @@ -100,6 +109,13 @@ |
212 | upstart_wrapper_->Emit("desktop-unlock"); |
213 | indicators_.reset(); |
214 | } |
215 | + else if (!prompt_activation_) |
216 | + { |
217 | + screensaver_post_lock_timeout_.reset(new glib::TimeoutSeconds(POST_LOCK_SCREENSAVER_WAIT, [this] { |
218 | + OnPresenceStatusChanged(true); |
219 | + return false; |
220 | + })); |
221 | + } |
222 | }); |
223 | |
224 | blank_window_animator_.updated.connect([this](double value) { |
225 | @@ -108,67 +124,26 @@ |
226 | }); |
227 | |
228 | blank_window_animator_.finished.connect([this] { |
229 | - if (blank_window_animator_.GetCurrentValue() == 1.0) |
230 | - { |
231 | - dbus_manager_->active = true; |
232 | - |
233 | - if (Settings::Instance().lock_on_blank()) |
234 | - { |
235 | - int lock_delay = Settings::Instance().lock_delay(); |
236 | - |
237 | - lockscreen_delay_timeout_.reset(new glib::TimeoutSeconds(lock_delay, [this] { |
238 | - RequestPromptScreenLock(); |
239 | - return false; |
240 | - })); |
241 | - } |
242 | - |
243 | - std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr<Shield> const& shield) { |
244 | - shield->UnGrabPointer(); |
245 | - shield->UnGrabKeyboard(); |
246 | - }); |
247 | - |
248 | - if (blank_window_) |
249 | - { |
250 | - blank_window_->EnableInputWindow(true); |
251 | - blank_window_->GrabPointer(); |
252 | - blank_window_->GrabKeyboard(); |
253 | - blank_window_->PushToFront(); |
254 | - blank_window_->mouse_move.connect([this](int, int, int dx, int dy, unsigned long, unsigned long) { |
255 | - if (dx || dy) |
256 | - { |
257 | - HideBlankWindow(); |
258 | - lockscreen_delay_timeout_.reset(); |
259 | - } |
260 | - }); |
261 | - } |
262 | - } |
263 | - else |
264 | - { |
265 | - dbus_manager_->active = false; |
266 | - lockscreen_delay_timeout_.reset(); |
267 | - |
268 | - if (blank_window_) |
269 | - { |
270 | - blank_window_->UnGrabPointer(); |
271 | - blank_window_->UnGrabKeyboard(); |
272 | - } |
273 | - |
274 | - std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr<Shield> const& shield) { |
275 | - if (!shield->primary()) |
276 | - return; |
277 | - |
278 | - shield->GrabPointer(); |
279 | - shield->GrabKeyboard(); |
280 | - }); |
281 | + bool shown = blank_window_animator_.GetCurrentValue() == 1.0; |
282 | + BlankWindowGrabEnable(shown); |
283 | + dbus_manager_->active = shown; |
284 | + lockscreen_delay_timeout_.reset(); |
285 | + |
286 | + if (shown && Settings::Instance().lock_on_blank()) |
287 | + { |
288 | + int lock_delay = Settings::Instance().lock_delay(); |
289 | + |
290 | + lockscreen_delay_timeout_.reset(new glib::TimeoutSeconds(lock_delay, [this] { |
291 | + session_manager_->PromptLockScreen(); |
292 | + return false; |
293 | + })); |
294 | } |
295 | }); |
296 | } |
297 | |
298 | void Controller::ResetPostLockScreenSaver() |
299 | { |
300 | - if (opacity() == 1.0) |
301 | - screensaver_post_lock_timeout_.reset(); |
302 | - |
303 | + screensaver_post_lock_timeout_.reset(); |
304 | HideBlankWindow(); |
305 | } |
306 | |
307 | @@ -240,7 +215,7 @@ |
308 | |
309 | if (!blank_window_) |
310 | { |
311 | - blank_window_ = new nux::BaseWindow(); |
312 | + blank_window_ = new BlankWindow(); |
313 | blank_window_->SetBackgroundLayer(new nux::ColorLayer(nux::color::Black, true)); |
314 | blank_window_->SetOpacity(blank_window_animator_.GetCurrentValue()); |
315 | blank_window_->ShowWindow(true); |
316 | @@ -251,15 +226,11 @@ |
317 | blank_window_->SetMinMaxSize(screen_geo.width, screen_geo.height); |
318 | } |
319 | |
320 | -void Controller::RequestPromptScreenLock() |
321 | -{ |
322 | - skip_animation_ = true; |
323 | - session_manager_->LockScreen(); |
324 | - skip_animation_ = false; |
325 | -} |
326 | - |
327 | void Controller::ShowBlankWindow() |
328 | { |
329 | + if (blank_window_ && blank_window_->GetOpacity() == 1.0) |
330 | + return; |
331 | + |
332 | EnsureBlankWindow(); |
333 | animation::StartOrReverse(blank_window_animator_, animation::Direction::FORWARD); |
334 | } |
335 | @@ -272,15 +243,58 @@ |
336 | blank_window_->ShowWindow(false); |
337 | blank_window_.Release(); |
338 | animation::SetValue(blank_window_animator_, animation::Direction::BACKWARD); |
339 | -} |
340 | - |
341 | -void Controller::OnLockRequested() |
342 | + lockscreen_delay_timeout_.reset(); |
343 | +} |
344 | + |
345 | +void Controller::BlankWindowGrabEnable(bool grab) |
346 | +{ |
347 | + if (!blank_window_) |
348 | + return; |
349 | + |
350 | + if (grab) |
351 | + { |
352 | + for (auto const& shield : shields_) |
353 | + { |
354 | + shield->UnGrabPointer(); |
355 | + shield->UnGrabKeyboard(); |
356 | + } |
357 | + |
358 | + blank_window_->EnableInputWindow(true); |
359 | + blank_window_->GrabPointer(); |
360 | + blank_window_->GrabKeyboard(); |
361 | + blank_window_->PushToFront(); |
362 | + |
363 | + blank_window_->mouse_move.connect([this](int, int, int dx, int dy, unsigned long, unsigned long) { |
364 | + if ((dx || dy) && !lockscreen_timeout_) HideBlankWindow(); |
365 | + }); |
366 | + blank_window_->key_down.connect([this] (unsigned long, unsigned long e, unsigned long, const char*, unsigned short) { |
367 | + if (!lockscreen_timeout_) HideBlankWindow(); |
368 | + }); |
369 | + blank_window_->mouse_down.connect([this] (int, int, unsigned long, unsigned long) { |
370 | + if (!lockscreen_timeout_) HideBlankWindow(); |
371 | + }); |
372 | + } |
373 | + else |
374 | + { |
375 | + blank_window_->UnGrabPointer(); |
376 | + blank_window_->UnGrabKeyboard(); |
377 | + |
378 | + for (auto const& shield : shields_) |
379 | + { |
380 | + if (!shield->primary()) |
381 | + continue; |
382 | + |
383 | + shield->GrabPointer(); |
384 | + shield->GrabKeyboard(); |
385 | + } |
386 | + } |
387 | +} |
388 | + |
389 | +void Controller::OnLockRequested(bool prompt) |
390 | { |
391 | if (Settings::Instance().use_legacy()) |
392 | { |
393 | auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver"); |
394 | - // By passing the proxy to the lambda we ensure that it will stay alive |
395 | - // until we get the last callback. |
396 | proxy->CallBegin("Lock", nullptr, [proxy] (GVariant*, glib::Error const&) {}); |
397 | return; |
398 | } |
399 | @@ -291,44 +305,51 @@ |
400 | return; |
401 | } |
402 | |
403 | - HideBlankWindow(); |
404 | - bool skip_animation = skip_animation_; |
405 | - |
406 | - lockscreen_timeout_.reset(new glib::Timeout(10, [this, skip_animation] { |
407 | + if (prompt) |
408 | + { |
409 | + EnsureBlankWindow(); |
410 | + blank_window_->SetOpacity(1.0); |
411 | + } |
412 | + |
413 | + prompt_activation_ = prompt; |
414 | + |
415 | + lockscreen_timeout_.reset(new glib::Timeout(30, [this] { |
416 | bool grabbed_by_blank = (blank_window_ && blank_window_->OwnsPointerGrab()); |
417 | |
418 | if (WindowManager::Default().IsScreenGrabbed() && !grabbed_by_blank) |
419 | { |
420 | + HideBlankWindow(); |
421 | LOG_DEBUG(logger) << "Failed to lock the screen: the screen is already grabbed."; |
422 | return true; // keep trying |
423 | } |
424 | |
425 | + if (!prompt_activation_) |
426 | + HideBlankWindow(); |
427 | + |
428 | LockScreen(); |
429 | session_manager_->locked.emit(); |
430 | |
431 | - if (skip_animation) |
432 | + if (prompt_activation_) |
433 | { |
434 | animation::Skip(fade_animator_); |
435 | - } |
436 | - else |
437 | - { |
438 | - screensaver_post_lock_timeout_.reset(new glib::Timeout(POST_LOCK_SCREENSAVER_WAIT, [this] { |
439 | - OnPresenceStatusChanged(true); |
440 | - return false; |
441 | - })); |
442 | + HideBlankWindow(); |
443 | } |
444 | |
445 | + lockscreen_timeout_.reset(); |
446 | return false; |
447 | })); |
448 | } |
449 | |
450 | void Controller::OnPresenceStatusChanged(bool is_idle) |
451 | { |
452 | + if (Settings::Instance().use_legacy()) |
453 | + return; |
454 | + |
455 | if (is_idle) |
456 | { |
457 | ShowBlankWindow(); |
458 | } |
459 | - else |
460 | + else if (!lockscreen_timeout_) |
461 | { |
462 | HideBlankWindow(); |
463 | } |
464 | @@ -336,9 +357,17 @@ |
465 | |
466 | void Controller::OnScreenSaverActivationRequest(bool activate) |
467 | { |
468 | + if (Settings::Instance().use_legacy()) |
469 | + { |
470 | + auto proxy = std::make_shared<glib::DBusProxy>("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver"); |
471 | + proxy->CallBegin("SetActive", g_variant_new("(b)", activate != FALSE), [proxy] (GVariant*, glib::Error const&) {}); |
472 | + return; |
473 | + } |
474 | + |
475 | // It looks we need to do this after a small delay, not to get the screen back on |
476 | screensaver_activation_timeout_.reset(new glib::Timeout(100, [this, activate] { |
477 | - dbus_manager_->active = activate; |
478 | + if (dbus_manager_->active() == activate) |
479 | + return false; |
480 | |
481 | if (activate) |
482 | { |
483 | @@ -391,14 +420,15 @@ |
484 | lockscreen_timeout_.reset(); |
485 | screensaver_post_lock_timeout_.reset(); |
486 | |
487 | - if (!IsLocked()) |
488 | - return; |
489 | - |
490 | + HideBlankWindow(); |
491 | HideShields(); |
492 | } |
493 | |
494 | void Controller::HideShields() |
495 | { |
496 | + if (!IsLocked()) |
497 | + return; |
498 | + |
499 | std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr<Shield> const& shield) { |
500 | shield->UnGrabPointer(); |
501 | shield->UnGrabKeyboard(); |
502 | |
503 | === modified file 'lockscreen/LockScreenController.h' |
504 | --- lockscreen/LockScreenController.h 2014-04-10 06:37:15 +0000 |
505 | +++ lockscreen/LockScreenController.h 2014-04-10 06:37:15 +0000 |
506 | @@ -57,11 +57,11 @@ |
507 | void HideShields(); |
508 | void ShowBlankWindow(); |
509 | void HideBlankWindow(); |
510 | - void RequestPromptScreenLock(); |
511 | + void BlankWindowGrabEnable(bool grab); |
512 | void SimulateActivity(); |
513 | void ResetPostLockScreenSaver(); |
514 | |
515 | - void OnLockRequested(); |
516 | + void OnLockRequested(bool prompt); |
517 | void OnUnlockRequested(); |
518 | void OnPresenceStatusChanged(bool idle); |
519 | void OnScreenSaverActivationRequest(bool activate); |
520 | @@ -81,7 +81,7 @@ |
521 | nux::animation::AnimateValue<double> blank_window_animator_; |
522 | |
523 | bool test_mode_; |
524 | - bool skip_animation_; |
525 | + bool prompt_activation_; |
526 | BlurType old_blur_type_; |
527 | |
528 | connection::Wrapper uscreen_connection_; |
529 | |
530 | === modified file 'lockscreen/ScreenSaverDBusManager.cpp' |
531 | --- lockscreen/ScreenSaverDBusManager.cpp 2014-04-10 06:37:15 +0000 |
532 | +++ lockscreen/ScreenSaverDBusManager.cpp 2014-04-10 06:37:15 +0000 |
533 | @@ -64,25 +64,25 @@ |
534 | // This is a workaround we use to fallback to use gnome-screensaver if the screen reader is enabled |
535 | Settings::Instance().use_legacy.changed.connect(sigc::hide(sigc::mem_fun(this, &DBusManager::EnsureService))); |
536 | |
537 | - object_->SetMethodsCallsHandler([this] (std::string const& method, GVariant* variant) -> GVariant* { |
538 | + object_->SetMethodsCallsHandler([this] (std::string const& method, GVariant* parameters) -> GVariant* { |
539 | if (method == "Lock") |
540 | { |
541 | session_->LockScreen(); |
542 | } |
543 | else if (method == "GetActive") |
544 | { |
545 | - return g_variant_new("(b)", active_ ? TRUE : FALSE); |
546 | + return g_variant_new("(b)", active() ? TRUE : FALSE); |
547 | } |
548 | else if (method == "GetActiveTime") |
549 | { |
550 | - if (time_) |
551 | - return g_variant_new("(u)", time(nullptr) - time_); |
552 | + return g_variant_new("(u)", time_ ? (time(nullptr) - time_) : 0); |
553 | + } |
554 | + else if (method == "SetActive") |
555 | + { |
556 | + if (glib::Variant(parameters).GetBool()) |
557 | + session_->ScreenSaverActivate(); |
558 | else |
559 | - return g_variant_new("(u)", 0); |
560 | - } |
561 | - else if (method == "SetActive") |
562 | - { |
563 | - request_activate.emit(glib::Variant(variant).GetBool()); |
564 | + session_->ScreenSaverDeactivate(); |
565 | } |
566 | else if (method == "SimulateUserActivity") |
567 | { |
568 | @@ -117,11 +117,7 @@ |
569 | |
570 | void DBusManager::SetActive(bool active) |
571 | { |
572 | - if (active) |
573 | - time_ = time(nullptr); |
574 | - else |
575 | - time_ = 0; |
576 | - |
577 | + time_ = active ? time(nullptr) : 0; |
578 | object_->EmitSignal("ActiveChanged", g_variant_new("(b)", active ? TRUE : FALSE)); |
579 | } |
580 | |
581 | |
582 | === modified file 'lockscreen/ScreenSaverDBusManager.h' |
583 | --- lockscreen/ScreenSaverDBusManager.h 2014-04-10 06:37:15 +0000 |
584 | +++ lockscreen/ScreenSaverDBusManager.h 2014-04-10 06:37:15 +0000 |
585 | @@ -39,7 +39,6 @@ |
586 | nux::Property<bool> active; |
587 | |
588 | sigc::signal<void> simulate_activity; |
589 | - sigc::signal<void, bool> request_activate; |
590 | |
591 | private: |
592 | void SetActive(bool active); |
593 | @@ -49,7 +48,6 @@ |
594 | glib::DBusServer::Ptr server_; |
595 | glib::DBusObject::Ptr object_; |
596 | |
597 | - bool active_; |
598 | time_t time_; |
599 | }; |
600 | |
601 | |
602 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
603 | --- plugins/unityshell/src/unityshell.cpp 2014-04-10 06:37:15 +0000 |
604 | +++ plugins/unityshell/src/unityshell.cpp 2014-04-10 06:37:15 +0000 |
605 | @@ -2874,6 +2874,7 @@ |
606 | gWindow->glPaintSetCurrentIndex(MAXSHORT); |
607 | bool ret = gWindow->glPaint(wAttrib, matrix, region, mask); |
608 | gWindow->glPaintSetCurrentIndex(old_index); |
609 | + deco_win_->Paint(matrix, wAttrib, region, mask); |
610 | return ret; |
611 | } |
612 | } |
613 | @@ -3820,7 +3821,6 @@ |
614 | // Setup Lockscreen Controller |
615 | screensaver_dbus_manager_ = std::make_shared<lockscreen::DBusManager>(manager); |
616 | lockscreen_controller_ = std::make_shared<lockscreen::Controller>(screensaver_dbus_manager_, manager); |
617 | - lockscreen_controller_->opacity.changed.connect(sigc::hide(sigc::mem_fun(cScreen, &CompositeScreen::damageScreen))); |
618 | UpdateActivateIndicatorsKey(); |
619 | |
620 | auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) { |
621 | |
622 | === modified file 'shutdown/SessionDBusManager.cpp' |
623 | --- shutdown/SessionDBusManager.cpp 2014-03-07 05:24:32 +0000 |
624 | +++ shutdown/SessionDBusManager.cpp 2014-04-10 06:37:15 +0000 |
625 | @@ -41,6 +41,9 @@ |
626 | <arg type="s" direction="out" name="hostname" /> |
627 | </method> |
628 | <method name="Lock" /> |
629 | + <method name="PromptLock" /> |
630 | + <method name="ActivateScreenSaver" /> |
631 | + <method name="DeactivateScreenSaver" /> |
632 | <method name="Logout" /> |
633 | <method name="RequestLogout" /> |
634 | <method name="Reboot" /> |
635 | @@ -100,6 +103,18 @@ |
636 | { |
637 | session_->LockScreen(); |
638 | } |
639 | + else if (method == "PromptLock") |
640 | + { |
641 | + session_->PromptLockScreen(); |
642 | + } |
643 | + else if (method == "ActivateScreenSaver") |
644 | + { |
645 | + session_->ScreenSaverActivate(); |
646 | + } |
647 | + else if (method == "DeactivateScreenSaver") |
648 | + { |
649 | + session_->ScreenSaverDeactivate(); |
650 | + } |
651 | else if (method == "Logout") |
652 | { |
653 | session_->Logout(); |
654 | @@ -156,6 +171,9 @@ |
655 | connections_.Add(session_->lock_requested.connect([this] { |
656 | object_->EmitSignal("LockRequested"); |
657 | })); |
658 | + connections_.Add(session_->prompt_lock_requested.connect([this] { |
659 | + object_->EmitSignal("LockRequested"); |
660 | + })); |
661 | connections_.Add(session_->locked.connect([this] { |
662 | object_->EmitSignal("Locked"); |
663 | })); |
664 | |
665 | === modified file 'shutdown/StandaloneSession.cpp' |
666 | --- shutdown/StandaloneSession.cpp 2014-03-07 02:01:38 +0000 |
667 | +++ shutdown/StandaloneSession.cpp 2014-04-10 06:37:15 +0000 |
668 | @@ -40,7 +40,10 @@ |
669 | std::string UserName() const { return "marco"; } |
670 | std::string HostName() const { return "tricky"; } |
671 | |
672 | + void ScreenSaverActivate() { std::cout << "ScreenSaverActivate" << std::endl; } |
673 | + void ScreenSaverDeactivate() { std::cout << "ScreenSaverDeactivate" << std::endl; } |
674 | void LockScreen() { std::cout << "LockScreen" << std::endl; } |
675 | + void PromptLockScreen() { std::cout << "PromptLockScreen" << std::endl; } |
676 | void Logout() { std::cout << "Logout" << std::endl; } |
677 | void Reboot() { std::cout << "Reboot" << std::endl; } |
678 | void Shutdown() { std::cout << "Shutdown" << std::endl; } |
679 | |
680 | === modified file 'tests/test_gnome_session_manager.cpp' |
681 | --- tests/test_gnome_session_manager.cpp 2014-03-21 03:42:28 +0000 |
682 | +++ tests/test_gnome_session_manager.cpp 2014-04-10 06:37:15 +0000 |
683 | @@ -44,6 +44,9 @@ |
684 | |
685 | const std::string SESSION_OPTIONS = "com.canonical.indicator.session"; |
686 | const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown"; |
687 | + |
688 | +const std::string GNOME_LOCKDOWN_OPTIONS = "org.gnome.desktop.lockdown"; |
689 | +const std::string DISABLE_LOCKSCREEN_KEY = "disable-lock-screen"; |
690 | } |
691 | |
692 | namespace introspection |
693 | @@ -291,6 +294,12 @@ |
694 | g_settings_set_boolean(setting, SUPPRESS_DIALOGS_KEY.c_str(), enable ? FALSE : TRUE); |
695 | } |
696 | |
697 | + void DisableScreenLocking(bool disable) |
698 | + { |
699 | + glib::Object<GSettings> setting(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str())); |
700 | + g_settings_set_boolean(setting, DISABLE_LOCKSCREEN_KEY.c_str(), disable ? TRUE : FALSE); |
701 | + } |
702 | + |
703 | enum class Action : unsigned |
704 | { |
705 | LOGOUT = 0, |
706 | @@ -1010,4 +1019,21 @@ |
707 | EXPECT_TRUE(unlock_emitted); |
708 | } |
709 | |
710 | +TEST_F(TestGnomeSessionManager, NoLockWhenLockingDisabled) |
711 | +{ |
712 | + bool lock_emitted = false; |
713 | + |
714 | + manager->lock_requested.connect([&lock_emitted]() |
715 | + { |
716 | + lock_emitted = true; |
717 | + }); |
718 | + |
719 | + DisableScreenLocking(true); |
720 | + |
721 | + manager->LockScreen(); |
722 | + EXPECT_FALSE(lock_emitted); |
723 | + |
724 | + DisableScreenLocking(false); |
725 | +} |
726 | + |
727 | } // Namespace |
728 | |
729 | === modified file 'tests/test_mock_session_manager.h' |
730 | --- tests/test_mock_session_manager.h 2014-03-06 19:29:17 +0000 |
731 | +++ tests/test_mock_session_manager.h 2014-04-10 06:37:15 +0000 |
732 | @@ -33,7 +33,10 @@ |
733 | MOCK_CONST_METHOD0(UserName, std::string()); |
734 | MOCK_CONST_METHOD0(HostName, std::string()); |
735 | |
736 | + MOCK_METHOD0(ScreenSaverActivate, void()); |
737 | + MOCK_METHOD0(ScreenSaverDeactivate, void()); |
738 | MOCK_METHOD0(LockScreen, void()); |
739 | + MOCK_METHOD0(PromptLockScreen, void()); |
740 | MOCK_METHOD0(Logout, void()); |
741 | MOCK_METHOD0(Reboot, void()); |
742 | MOCK_METHOD0(Shutdown, void()); |
LGTM