diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2016-07-14 19:49:04 +0200 |
|---|---|---|
| committer | Andrea Azzarone <azzaronea@gmail.com> | 2016-07-14 19:49:04 +0200 |
| commit | 7a89ba2107a2f3ea02536aaac3dc63ab9201c4e1 (patch) | |
| tree | ab57c66541d89a4607593306ccacd57c48853aac /plugins | |
| parent | 3d4e1573319c173b9d9e8858e2257a9a50aa3828 (diff) | |
Keep the screen locked if rebooting with autologin.
Fixes LP: #1600389 (bzr r4146.6.1)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 52 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 4 |
2 files changed, 39 insertions, 17 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index fb35b4886..54da52e11 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -27,7 +27,6 @@ #include <UnityCore/DBusIndicators.h> #include <UnityCore/DesktopUtilities.h> -#include <UnityCore/GnomeSessionManager.h> #include <UnityCore/ScopeProxyInterface.h> #include "CompizUtils.h" @@ -515,7 +514,10 @@ UnityScreen::~UnityScreen() unity_a11y_finalize(); QuicklistManager::Destroy(); decoration::DataPool::Reset(); - SaveLockStamp(false); + + if (!session_->GetAutomaticLogin()) + SaveLockStamp(false); + reset_glib_logging(); screen->addSupportedAtomsSetEnabled(this, false); @@ -3986,17 +3988,33 @@ void UnityScreen::OnScreenUnlocked() edge_barriers_->force_disable = false; } -void UnityScreen::SaveLockStamp(bool save) +std::string UnityScreen::GetLockStampFile() const { - auto const& cache_dir = DesktopUtilities::GetUserRuntimeDirectory(); + std::string user_name = session_->UserName(); + std::string cache_dir; + + if (session_->GetAutomaticLogin()) + cache_dir = DesktopUtilities::GetUserConfigDirectory(); + else + cache_dir = DesktopUtilities::GetUserRuntimeDirectory(); if (cache_dir.empty()) + return std::string(); + + return cache_dir+local::LOCKED_STAMP; +} + +void UnityScreen::SaveLockStamp(bool save) +{ + std::string file_path = GetLockStampFile(); + + if (file_path.empty()) return; if (save) { glib::Error error; - g_file_set_contents((cache_dir+local::LOCKED_STAMP).c_str(), "", 0, &error); + g_file_set_contents(file_path.c_str(), "", 0, &error); if (error) { @@ -4005,7 +4023,7 @@ void UnityScreen::SaveLockStamp(bool save) } else { - if (g_unlink((cache_dir+local::LOCKED_STAMP).c_str()) < 0) + if (g_unlink(file_path.c_str()) < 0) { LOG_ERROR(logger) << "Impossible to delete the unity locked stamp file"; } @@ -4081,24 +4099,24 @@ void UnityScreen::InitUnityComponents() ShowFirstRunHints(); // Setup Session Controller - auto session = std::make_shared<session::GnomeManager>(); - session->lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); - session->prompt_lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); - session->locked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenLocked)); - session->unlocked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenUnlocked)); - session_dbus_manager_ = std::make_shared<session::DBusManager>(session); - session_controller_ = std::make_shared<session::Controller>(session); + session_ = std::make_shared<session::GnomeManager>(); + session_->lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); + session_->prompt_lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested)); + session_->locked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenLocked)); + session_->unlocked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenUnlocked)); + session_dbus_manager_ = std::make_shared<session::DBusManager>(session_); + session_controller_ = std::make_shared<session::Controller>(session_); LOG_INFO(logger) << "InitUnityComponents-Session " << timer.ElapsedSeconds() << "s"; Introspectable::AddChild(session_controller_.get()); // Setup Lockscreen Controller - screensaver_dbus_manager_ = std::make_shared<lockscreen::DBusManager>(session); - lockscreen_controller_ = std::make_shared<lockscreen::Controller>(screensaver_dbus_manager_, session, menus_->KeyGrabber()); + screensaver_dbus_manager_ = std::make_shared<lockscreen::DBusManager>(session_); + lockscreen_controller_ = std::make_shared<lockscreen::Controller>(screensaver_dbus_manager_, session_, menus_->KeyGrabber()); UpdateActivateIndicatorsKey(); LOG_INFO(logger) << "InitUnityComponents-Lockscreen " << timer.ElapsedSeconds() << "s"; - if (g_file_test((DesktopUtilities::GetUserRuntimeDirectory()+local::LOCKED_STAMP).c_str(), G_FILE_TEST_EXISTS)) - session->PromptLockScreen(); + if (g_file_test(GetLockStampFile().c_str(), G_FILE_TEST_EXISTS)) + session_->PromptLockScreen(); auto on_launcher_size_changed = [this] (nux::Area* area, int w, int h) { /* The launcher geometry includes 1px used to draw the right/top margin diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 789e18aaf..a838e8731 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -75,6 +75,7 @@ #include "UnityShowdesktopHandler.h" #include "ThumbnailGenerator.h" #include "MenuManager.h" +#include "UnityCore/GnomeSessionManager.h" #include "compizminimizedwindowhandler.h" #include "BGHash.h" @@ -230,6 +231,7 @@ private: void OnScreenLocked(); void OnScreenUnlocked(); void SaveLockStamp(bool); + std::string GetLockStampFile() const; bool DoesPointIntersectUnityGeos(nux::Point const& pt); @@ -342,6 +344,8 @@ private: std::unique_ptr<BGHash> bghash_; spread::Filter::Ptr spread_filter_; + session::Manager::Ptr session_; + /* Subscription for gestures that manipulate Unity launcher */ std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_; |
