diff options
| author | Andrea Azzarone <azzaronea@gmail.com> | 2014-10-21 15:56:00 +0200 |
|---|---|---|
| committer | Andrea Azzarone <azzaronea@gmail.com> | 2014-10-21 15:56:00 +0200 |
| commit | 06c1b560df36e5ebf7a66c4187dfba4d3c7b78fe (patch) | |
| tree | f91160c61bfe5127a17c943922f92ff36cb9f96e /lockscreen | |
| parent | b62a16430805b529eae136e7f9f7265ed6f5bd3a (diff) | |
| parent | 349a6b9030a3643e578858e4c7cbbe0b94bc79d0 (diff) | |
Merge lp:unity.
(bzr r3874.1.8)
Diffstat (limited to 'lockscreen')
| -rw-r--r-- | lockscreen/LockScreenAbstractShield.h | 3 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.cpp | 44 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.h | 4 | ||||
| -rw-r--r-- | lockscreen/LockScreenPanel.cpp | 29 | ||||
| -rw-r--r-- | lockscreen/LockScreenShield.cpp | 14 | ||||
| -rw-r--r-- | lockscreen/LockScreenShield.h | 1 |
6 files changed, 76 insertions, 19 deletions
diff --git a/lockscreen/LockScreenAbstractShield.h b/lockscreen/LockScreenAbstractShield.h index df9bbaf16..71bc64fec 100644 --- a/lockscreen/LockScreenAbstractShield.h +++ b/lockscreen/LockScreenAbstractShield.h @@ -57,9 +57,12 @@ public: nux::Property<double> scale; using MockableBaseWindow::RemoveLayout; + virtual bool HasGrab() const = 0; virtual bool IsIndicatorOpen() const = 0; virtual void ActivatePanel() = 0; + sigc::signal<void> grabbed; + sigc::signal<void> grab_failed; sigc::signal<void, int, int> grab_motion; sigc::signal<void, unsigned long, unsigned long> grab_key; diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index 124f6fc77..69b5b6f59 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -107,8 +107,7 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager, fade_animator_.finished.connect([this] { if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD) { - motion_connection_->disconnect(); - key_connection_->disconnect(); + primary_shield_connections_.Clear(); uscreen_connection_->block(); hidden_window_connection_->block(); session_manager_->is_locked = false; @@ -180,10 +179,7 @@ void Controller::OnPrimaryShieldMotion(int x, int y) primary_shield_ = shield; shield->primary = true; nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer()); - auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion); - motion_connection_ = shield->grab_motion.connect(move_cb); - auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver))); - key_connection_ = shield->grab_key.connect(key_cb); + SetupPrimaryShieldConnections(); break; } } @@ -191,6 +187,35 @@ void Controller::OnPrimaryShieldMotion(int x, int y) ResetPostLockScreenSaver(); } +void Controller::SetupPrimaryShieldConnections() +{ + if (!primary_shield_.IsValid()) + return; + + primary_shield_connections_.Clear(); + + auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion); + primary_shield_connections_.Add(primary_shield_->grab_motion.connect(move_cb)); + + auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver))); + primary_shield_connections_.Add(primary_shield_->grab_key.connect(key_cb)); + + if (!session_manager_->is_locked()) + { + primary_shield_connections_.Add(primary_shield_->grabbed.connect([this] { + session_manager_->is_locked = true; + })); + + primary_shield_connections_.Add(primary_shield_->grab_failed.connect([this] { + if (!session_manager_->is_locked()) + { + LOG_ERROR(logger) << "Impossible to get the grab to lock the screen"; + session_manager_->unlock_requested.emit(); + } + })); + } +} + void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors) { int num_monitors = monitors.size(); @@ -240,10 +265,7 @@ void Controller::EnsureShields(std::vector<nux::Geometry> const& monitors) primary_shield_ = shields_[primary]; primary_shield_->primary = true; - auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion); - motion_connection_ = primary_shield_->grab_motion.connect(move_cb); - auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver))); - key_connection_ = primary_shield_->grab_key.connect(key_cb); + SetupPrimaryShieldConnections(); } void Controller::EnsureBlankWindow() @@ -365,7 +387,6 @@ void Controller::OnLockRequested(bool prompt) HideBlankWindow(); LockScreen(); - session_manager_->is_locked = true; if (prompt_activation_) { @@ -455,6 +476,7 @@ void Controller::ShowShields() shield->PushToFront(); }); + session_manager_->is_locked = primary_shield_->HasGrab(); nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer()); animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD); } diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h index b49dd7112..8c49693db 100644 --- a/lockscreen/LockScreenController.h +++ b/lockscreen/LockScreenController.h @@ -68,6 +68,7 @@ private: void BlankWindowGrabEnable(bool grab); void SimulateActivity(); void ResetPostLockScreenSaver(); + void SetupPrimaryShieldConnections(); void ActivatePanel(); void OnLockRequested(bool prompt); @@ -100,8 +101,7 @@ private: connection::Wrapper uscreen_connection_; connection::Wrapper suspend_connection_; connection::Wrapper hidden_window_connection_; - connection::Wrapper motion_connection_; - connection::Wrapper key_connection_; + connection::Manager primary_shield_connections_; glib::Source::UniquePtr lockscreen_timeout_; glib::Source::UniquePtr lockscreen_delay_timeout_; diff --git a/lockscreen/LockScreenPanel.cpp b/lockscreen/LockScreenPanel.cpp index 9c8e66439..2020420ac 100644 --- a/lockscreen/LockScreenPanel.cpp +++ b/lockscreen/LockScreenPanel.cpp @@ -110,12 +110,39 @@ void Panel::AddIndicator(Indicator::Ptr const& indicator) return; indicators_view_->AddIndicator(indicator); + + if (!active) + { + for (auto const& entry : indicator->GetEntries()) + { + if (entry->active()) + { + active = true; + indicators_view_->ActivateEntry(entry->id()); + OnEntryActivated(GetPanelName(), entry->id(), entry->geometry()); + break; + } + } + } + QueueRelayout(); QueueDraw(); } void Panel::RemoveIndicator(indicator::Indicator::Ptr const& indicator) { + if (active) + { + for (auto const& entry : indicator->GetEntries()) + { + if (entry->active()) + { + active = false; + break; + } + } + } + indicators_view_->RemoveIndicator(indicator); QueueRelayout(); QueueDraw(); @@ -123,7 +150,7 @@ void Panel::RemoveIndicator(indicator::Indicator::Ptr const& indicator) std::string Panel::GetPanelName() const { - return "LockScreenPanel" + std::to_string(monitor); + return "LockScreenPanel"; } void Panel::OnIndicatorViewUpdated() diff --git a/lockscreen/LockScreenShield.cpp b/lockscreen/LockScreenShield.cpp index 6ffca3591..a8d412105 100644 --- a/lockscreen/LockScreenShield.cpp +++ b/lockscreen/LockScreenShield.cpp @@ -19,7 +19,6 @@ #include "LockScreenShield.h" -#include <NuxCore/Logger.h> #include <Nux/VLayout.h> #include <Nux/HLayout.h> #include <Nux/PaintLayer.h> @@ -39,8 +38,7 @@ namespace lockscreen { namespace { -DECLARE_LOGGER(logger, "unity.lockscreen.shield"); -const unsigned MAX_GRAB_WAIT = 50; +const unsigned MAX_GRAB_WAIT = 100; } Shield::Shield(session::Manager::Ptr const& session_manager, @@ -123,6 +121,7 @@ void Shield::GrabScreen(bool cancel_on_failure) { regrab_conn_->disconnect(); regrab_timeout_.reset(); + grabbed.emit(); } else { @@ -132,14 +131,19 @@ void Shield::GrabScreen(bool cancel_on_failure) if (cancel_on_failure) { regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] { - LOG_ERROR(logger) << "Impossible to get the grab to lock the screen"; - session_manager_->unlock_requested.emit(); + grab_failed.emit(); return false; })); } } } +bool Shield::HasGrab() const +{ + auto& wc = nux::GetWindowCompositor(); + return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this); +} + void Shield::ShowPrimaryView() { if (primary_layout_) diff --git a/lockscreen/LockScreenShield.h b/lockscreen/LockScreenShield.h index 02d0739a3..967cca9c1 100644 --- a/lockscreen/LockScreenShield.h +++ b/lockscreen/LockScreenShield.h @@ -44,6 +44,7 @@ public: nux::ObjectPtr<UserPromptView> const&, int monitor, bool is_primary); + bool HasGrab() const override; bool IsIndicatorOpen() const override; void ActivatePanel() override; |
