diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2014-03-20 23:51:34 +0000 |
|---|---|---|
| committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-03-20 23:51:34 +0000 |
| commit | 483be700822054fa70918c2465c02950fe8eb3b8 (patch) | |
| tree | 15deaf71df6fe4a842d144ff341892e8118c4cb9 | |
| parent | 8787fe72864edef07ad9fbd83589516d6097096b (diff) | |
| parent | c004077727d277ca9d13c8ca4d0dad13cbc6cef2 (diff) | |
Wait for the grab before showing the lockscreen. Fixes: 1291497, 1291547, 1292225
(bzr r3734)
| -rw-r--r-- | lockscreen/LockScreenController.cpp | 47 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.h | 3 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 4 | ||||
| -rw-r--r-- | tests/test_lockscreen_controller.cpp | 33 |
4 files changed, 61 insertions, 26 deletions
diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index 8b4487906..dabe12948 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -20,6 +20,8 @@ #include "LockScreenController.h" #include <UnityCore/DBusIndicators.h> +#include <NuxCore/Logger.h> + #include "LockScreenShield.h" #include "LockScreenSettings.h" #include "unity-shared/AnimationUtils.h" @@ -40,6 +42,8 @@ namespace testing const std::string DBUS_NAME = "com.canonical.Unity.Test.DisplayManager"; } +DECLARE_LOGGER(logger, "unity.locksreen"); + Controller::Controller(session::Manager::Ptr const& session_manager, UpstartWrapper::Ptr const& upstart_wrapper, ShieldFactoryInterface::Ptr const& shield_factory, @@ -145,26 +149,39 @@ void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors) void Controller::OnLockRequested() { if (IsLocked()) - return; - - auto lockscreen_type = Settings::Instance().lockscreen_type(); - - if (lockscreen_type == Type::NONE) { - session_manager_->unlocked.emit(); + LOG_DEBUG(logger) << "Failed to lock screen: the screen is already locked."; return; } - if (lockscreen_type == Type::LIGHTDM) - { - LockScreenUsingDisplayManager(); - } - else if (lockscreen_type == Type::UNITY) - { - LockScreenUsingUnity(); - } + lockscreen_timeout_.reset(new glib::Timeout(10, [this](){ + if (WindowManager::Default().IsScreenGrabbed()) + { + LOG_DEBUG(logger) << "Failed to lock the screen: the screen is already grabbed."; + return true; // keep trying + } + + auto lockscreen_type = Settings::Instance().lockscreen_type(); + + if (lockscreen_type == Type::NONE) + { + session_manager_->unlocked.emit(); + return false; + } + + if (lockscreen_type == Type::LIGHTDM) + { + LockScreenUsingDisplayManager(); + } + else if (lockscreen_type == Type::UNITY) + { + LockScreenUsingUnity(); + } + + session_manager_->locked.emit(); - session_manager_->locked.emit(); + return false; + })); } void Controller::LockScreenUsingDisplayManager() diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h index 3e42bfd52..4ae971270 100644 --- a/lockscreen/LockScreenController.h +++ b/lockscreen/LockScreenController.h @@ -22,6 +22,7 @@ #include <NuxCore/Animation.h> #include <UnityCore/ConnectionManager.h> +#include <UnityCore/GLibSource.h> #include "LockScreenShieldFactory.h" #include "unity-shared/BackgroundEffectHelper.h" @@ -68,6 +69,8 @@ private: connection::Wrapper motion_connection_; bool test_mode_; BlurType old_blur_type_; + + glib::Source::UniquePtr lockscreen_timeout_; }; } diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 2c3f4b3eb..89c772025 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -3736,6 +3736,10 @@ void UnityScreen::LockscreenRequested() launcher_controller_->ClearTooltips(); + auto& adapter = PluginAdapter::Default(); + if (adapter.IsScaleActive()) + adapter.TerminateScale(); + RaiseOSK(); } diff --git a/tests/test_lockscreen_controller.cpp b/tests/test_lockscreen_controller.cpp index 7e817cff6..606936273 100644 --- a/tests/test_lockscreen_controller.cpp +++ b/tests/test_lockscreen_controller.cpp @@ -180,8 +180,8 @@ TEST_F(TestLockScreenController, LockScreenTypeLightdmOnSingleMonitor) lockscreen_settings.lockscreen_type = Type::LIGHTDM; session_manager->lock_requested.emit(); - ASSERT_EQ(1, controller.shields_.size()); - EXPECT_FALSE(controller.shields_.at(0)->primary()); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; }); + Utils::WaitUntilMSec([this]{ return controller.shields_.at(0)->primary() == false; }); Utils::WaitUntilMSec(lock_called); } @@ -202,10 +202,10 @@ TEST_F(TestLockScreenController, LockScreenTypeLightdmOnMultiMonitor) uscreen.SetupFakeMultiMonitor(/*primary*/ 0, /*emit_change*/ true); session_manager->lock_requested.emit(); - ASSERT_EQ(monitors::MAX, controller.shields_.size()); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; }); for (unsigned int i=0; i < monitors::MAX; ++i) - EXPECT_FALSE(controller.shields_.at(i)->primary()); + Utils::WaitUntilMSec([this, i]{ return controller.shields_.at(i)->primary() == false; }); Utils::WaitUntilMSec(lock_called); } @@ -226,7 +226,7 @@ TEST_F(TestLockScreenController, UnlockScreenTypeLightdmOnSingleMonitor) lockscreen_settings.lockscreen_type = Type::LIGHTDM; session_manager->lock_requested.emit(); - ASSERT_EQ(1, controller.shields_.size()); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; }); Utils::WaitUntilMSec(lock_called); session_manager->unlock_requested.emit(); @@ -252,7 +252,7 @@ TEST_F(TestLockScreenController, UnlockScreenTypeLightdmOnMultiMonitor) uscreen.SetupFakeMultiMonitor(/*primary*/ 0, /*emit_change*/ true); session_manager->lock_requested.emit(); - ASSERT_EQ(monitors::MAX, controller.shields_.size()); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; }); Utils::WaitUntilMSec(lock_called); session_manager->unlock_requested.emit(); @@ -265,8 +265,8 @@ TEST_F(TestLockScreenController, LockScreenOnSingleMonitor) { session_manager->lock_requested.emit(); - ASSERT_EQ(1, controller.shields_.size()); - EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry()); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; }); + Utils::WaitUntilMSec([this]{ return uscreen.GetMonitors().at(0) == controller.shields_.at(0)->GetGeometry(); }); } TEST_F(TestLockScreenController, LockScreenOnMultiMonitor) @@ -274,28 +274,33 @@ TEST_F(TestLockScreenController, LockScreenOnMultiMonitor) uscreen.SetupFakeMultiMonitor(); session_manager->lock_requested.emit(); + + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; }); ASSERT_EQ(monitors::MAX, controller.shields_.size()); for (unsigned int i=0; i < monitors::MAX; ++i) + { + Utils::WaitUntilMSec([this, i]{ return uscreen.GetMonitors().at(i) == controller.shields_.at(i)->GetGeometry(); }); EXPECT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); + } } TEST_F(TestLockScreenController, SwitchToMultiMonitor) { session_manager->lock_requested.emit(); - tick_source.tick(ANIMATION_DURATION); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; }); ASSERT_EQ(1, controller.shields_.size()); + + Utils::WaitUntilMSec([this]{ return uscreen.GetMonitors().at(0) == controller.shields_.at(0)->GetGeometry(); }); EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry()); uscreen.SetupFakeMultiMonitor(/* primary */ 0, /* emit_change */ true); - ASSERT_EQ(monitors::MAX, controller.shields_.size()); for (unsigned int i=0; i < monitors::MAX; ++i) { ASSERT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); - ASSERT_TRUE(controller.shields_.at(i)->IsVisible()); } } @@ -304,10 +309,14 @@ TEST_F(TestLockScreenController, SwitchToSingleMonitor) uscreen.SetupFakeMultiMonitor(/* primary */ 0, /* emit_change */ true); session_manager->lock_requested.emit(); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; }); ASSERT_EQ(monitors::MAX, controller.shields_.size()); for (unsigned int i=0; i < monitors::MAX; ++i) + { + Utils::WaitUntilMSec([this, i]{ return uscreen.GetMonitors().at(i) == controller.shields_.at(i)->GetGeometry(); }); ASSERT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); + } uscreen.Reset(/* emit_change */ true); @@ -319,6 +328,7 @@ TEST_F(TestLockScreenController, UnlockScreenOnSingleMonitor) { session_manager->lock_requested.emit(); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == 1; }); ASSERT_EQ(1, controller.shields_.size()); session_manager->unlock_requested.emit(); @@ -332,6 +342,7 @@ TEST_F(TestLockScreenController, UnlockScreenOnMultiMonitor) uscreen.SetupFakeMultiMonitor(/* primary */ 0, /* emit_change */ true); session_manager->lock_requested.emit(); + Utils::WaitUntilMSec([this]{ return controller.shields_.size() == monitors::MAX; }); ASSERT_EQ(monitors::MAX, controller.shields_.size()); session_manager->unlock_requested.emit(); |
