diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-06 03:25:27 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-03-06 03:25:27 +0100 |
| commit | 01c0f6c4d7858458b9afed1b46e4145322aa15e4 (patch) | |
| tree | 28c0541b2e56448770ff1eb7f6dc44a5aa967575 | |
| parent | a91d7f7b9206e935605fbc0dae332c283a3720c3 (diff) | |
LockScreenController: make sure we show the newly added views if we're visible
(bzr r3695.4.20)
| -rw-r--r-- | lockscreen/LockScreenController.cpp | 28 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.h | 2 | ||||
| -rw-r--r-- | tests/test_lockscreen_controller.cpp | 10 |
3 files changed, 26 insertions, 14 deletions
diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index d798c1077..85517f23d 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -49,8 +49,10 @@ Controller::Controller(session::Manager::Ptr const& session_manager, , fade_animator_(FADE_DURATION) , test_mode_(test_mode) { - auto* uscreen = UScreen::GetDefault(); - uscreen->changed.connect(sigc::mem_fun(this, &Controller::OnUScreenChanged)); + uscreen_connection_ = UScreen::GetDefault()->changed.connect([this] (int, std::vector<nux::Geometry> const& monitors) { + EnsureShields(monitors); + }); + uscreen_connection_->block(); session_manager_->lock_requested.connect(sigc::mem_fun(this, &Controller::OnLockRequested)); session_manager_->unlock_requested.connect(sigc::mem_fun(this, &Controller::OnUnlockRequested)); @@ -65,17 +67,12 @@ Controller::Controller(session::Manager::Ptr const& session_manager, if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD) { motion_connection_->disconnect(); + uscreen_connection_->block(); shields_.clear(); } }); } -void Controller::OnUScreenChanged(int primary, std::vector<nux::Geometry> const& monitors) -{ - if (IsLocked()) - EnsureShields(monitors); -} - void Controller::OnPrimaryShieldMotion(int x, int y) { if (!primary_shield_->GetAbsoluteGeometry().IsPointInside(x, y)) @@ -107,14 +104,24 @@ void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors) for (int i = 0; i < num_monitors; ++i) { auto& shield = shields_[i]; + bool is_new = false; if (i >= shields_size) + { shield = shield_factory_->CreateShield(session_manager_, i, i == primary); + is_new = true; + } - shield->primary = (i == primary); shield->SetGeometry(monitors[i]); shield->SetMinMaxSize(monitors[i].width, monitors[i].height); - shield->PushToFront(); + shield->primary = (i == primary); + + if (is_new && fade_animator_.GetCurrentValue() > 0) + { + shield->SetOpacity(fade_animator_.GetCurrentValue()); + shield->ShowWindow(true); + shield->PushToFront(); + } } if (unity_mode) @@ -180,6 +187,7 @@ void Controller::ShowShields() WindowManager::Default().SaveInputFocus(); EnsureShields(UScreen::GetDefault()->GetMonitors()); + uscreen_connection_->unblock(); std::for_each(shields_.begin(), shields_.end(), [] (nux::ObjectPtr<Shield> const& shield) { shield->SetOpacity(0.0f); diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h index 7ee09bb93..e3e20691f 100644 --- a/lockscreen/LockScreenController.h +++ b/lockscreen/LockScreenController.h @@ -52,7 +52,6 @@ private: void ShowShields(); void HideShields(); - void OnUScreenChanged(int primary, std::vector<nux::Geometry> const& monitors); void OnLockRequested(); void OnUnlockRequested(); void OnPrimaryShieldMotion(int x, int y); @@ -63,6 +62,7 @@ private: UpstartWrapper::Ptr upstart_wrapper_; ShieldFactoryInterface::Ptr shield_factory_; nux::animation::AnimateValue<double> fade_animator_; + connection::Wrapper uscreen_connection_; connection::Wrapper motion_connection_; bool test_mode_; BlurType old_blur_type_; diff --git a/tests/test_lockscreen_controller.cpp b/tests/test_lockscreen_controller.cpp index d82a7c2c9..1d4280368 100644 --- a/tests/test_lockscreen_controller.cpp +++ b/tests/test_lockscreen_controller.cpp @@ -253,7 +253,7 @@ TEST_F(TestLockScreenController, UnlockScreenTypeLightdmOnMultiMonitor) } TEST_F(TestLockScreenController, LockScreenOnSingleMonitor) -{ +{ session_manager->lock_requested.emit(); ASSERT_EQ(1, controller.shields_.size()); @@ -274,6 +274,7 @@ TEST_F(TestLockScreenController, LockScreenOnMultiMonitor) TEST_F(TestLockScreenController, SwitchToMultiMonitor) { session_manager->lock_requested.emit(); + tick_source.tick(ANIMATION_DURATION); ASSERT_EQ(1, controller.shields_.size()); EXPECT_EQ(uscreen.GetMonitors().at(0), controller.shields_.at(0)->GetGeometry()); @@ -283,7 +284,10 @@ TEST_F(TestLockScreenController, SwitchToMultiMonitor) ASSERT_EQ(monitors::MAX, controller.shields_.size()); for (unsigned int i=0; i < monitors::MAX; ++i) - EXPECT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); + { + ASSERT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); + ASSERT_TRUE(controller.shields_.at(i)->IsVisible()); + } } TEST_F(TestLockScreenController, SwitchToSingleMonitor) @@ -294,7 +298,7 @@ TEST_F(TestLockScreenController, SwitchToSingleMonitor) ASSERT_EQ(monitors::MAX, controller.shields_.size()); for (unsigned int i=0; i < monitors::MAX; ++i) - EXPECT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); + ASSERT_EQ(uscreen.GetMonitors().at(i), controller.shields_.at(i)->GetAbsoluteGeometry()); uscreen.Reset(/* emit_change */ true); |
