Merge lp:~sjakthol/unity/fix-1292154 into lp:unity

Proposed by Sami Jaktholm
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3765
Proposed branch: lp:~sjakthol/unity/fix-1292154
Merge into: lp:unity
Diff against target: 76 lines (+35/-1)
2 files modified
UnityCore/GnomeSessionManager.cpp (+9/-1)
tests/test_gnome_session_manager.cpp (+26/-0)
To merge this branch: bzr merge lp:~sjakthol/unity/fix-1292154
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Review via email: mp+214420@code.launchpad.net

Commit message

Session: Don't lock the screen if screen locking is disabled by
org.gnome.desktop.lockdown disable-lock-screen.

Description of the change

To test:
1. Run 'gsettings set org.gnome.desktop.lockdown disable-lock-screen true'
2. Press Super+L

The 'disable-lock-screen' is only ignored when the locking is initiated by Unity (e.g. when using the keybinding specified in Unity or possibly when requests are coming from logind). Normally (e.g. CTRL+ALT+L or session menu) all lock requests are forwarded to Unity by gnome-screensaver which performs the neccesary checks before asking Unity to lock the screen.

These changes should make Unity follow the behavior of gnome-screensaver by ignoring all locking requests if lock screen is disabled.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Hi, thanks for this, just one thing... Imho it's not needed to cache the value in this case, nor to monitor its changes.

So inside GnomeManager::LockScreen, just do something like:

glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));

if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()))
  return;

Revision history for this message
Sami Jaktholm (sjakthol) wrote :

Good point. I'll modify the branch!

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Cool, looks good to me. Thanks!

review: Approve

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-03-20 15:42:43 +0000
3+++ UnityCore/GnomeSessionManager.cpp 2014-04-06 13:37:22 +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@@ -416,7 +419,12 @@
15 impl_->EnsureCancelPendingAction();
16
17 // FIXME (andy) we should ask gnome-session to emit the logind signal
18- if (UserName().find("guest-") == 0)
19+ glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
20+
21+ if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str())) {
22+ return;
23+ }
24+ else if (UserName().find("guest-") == 0)
25 {
26 LOG_INFO(logger) << "Impossible to lock a guest session";
27 return;
28
29=== modified file 'tests/test_gnome_session_manager.cpp'
30--- tests/test_gnome_session_manager.cpp 2014-03-21 03:42:28 +0000
31+++ tests/test_gnome_session_manager.cpp 2014-04-06 13:37:22 +0000
32@@ -44,6 +44,9 @@
33
34 const std::string SESSION_OPTIONS = "com.canonical.indicator.session";
35 const std::string SUPPRESS_DIALOGS_KEY = "suppress-logout-restart-shutdown";
36+
37+const std::string GNOME_LOCKDOWN_OPTIONS = "org.gnome.desktop.lockdown";
38+const std::string DISABLE_LOCKSCREEN_KEY = "disable-lock-screen";
39 }
40
41 namespace introspection
42@@ -291,6 +294,12 @@
43 g_settings_set_boolean(setting, SUPPRESS_DIALOGS_KEY.c_str(), enable ? FALSE : TRUE);
44 }
45
46+ void DisableScreenLocking(bool disable)
47+ {
48+ glib::Object<GSettings> setting(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
49+ g_settings_set_boolean(setting, DISABLE_LOCKSCREEN_KEY.c_str(), disable ? TRUE : FALSE);
50+ }
51+
52 enum class Action : unsigned
53 {
54 LOGOUT = 0,
55@@ -1010,4 +1019,21 @@
56 EXPECT_TRUE(unlock_emitted);
57 }
58
59+TEST_F(TestGnomeSessionManager, NoLockWhenLockingDisabled)
60+{
61+ bool lock_emitted = false;
62+
63+ manager->lock_requested.connect([&lock_emitted]()
64+ {
65+ lock_emitted = true;
66+ });
67+
68+ DisableScreenLocking(true);
69+
70+ manager->LockScreen();
71+ EXPECT_FALSE(lock_emitted);
72+
73+ DisableScreenLocking(false);
74+}
75+
76 } // Namespace