diff options
| author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2016-11-11 16:00:53 +0000 |
|---|---|---|
| committer | Bileto Bot <ci-train-bot@canonical.com> | 2016-11-11 16:00:53 +0000 |
| commit | a38436ecf67d115a51de30612e3b33740877f6a5 (patch) | |
| tree | 25bb6e3ef58607723d003d7d71b27b15f425f063 | |
| parent | 6f95a8ce3f9b1e80195d860da35798f604df23f9 (diff) | |
| parent | 201a1fff61380dd1c96f5a19403126ccfe130e3d (diff) | |
LockScreenController: use input monitor to get the events to switch monitor
In this way we can safely switch the monitor also on button click (after closing a menu) or when moving over the panel (that wasn't properly handled before). (LP: #1316862) Approved by: Andrea Azzarone (bzr r4207)
| -rw-r--r-- | lockscreen/KylinLockScreenShield.cpp | 18 | ||||
| -rw-r--r-- | lockscreen/KylinLockScreenShield.h | 3 | ||||
| -rw-r--r-- | lockscreen/LockScreenBaseShield.cpp | 18 | ||||
| -rw-r--r-- | lockscreen/LockScreenBaseShield.h | 3 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.cpp | 23 | ||||
| -rw-r--r-- | lockscreen/LockScreenController.h | 1 | ||||
| -rw-r--r-- | lockscreen/LockScreenShield.cpp | 12 |
7 files changed, 34 insertions, 44 deletions
diff --git a/lockscreen/KylinLockScreenShield.cpp b/lockscreen/KylinLockScreenShield.cpp index 2545fabb7..8074f46cc 100644 --- a/lockscreen/KylinLockScreenShield.cpp +++ b/lockscreen/KylinLockScreenShield.cpp @@ -77,23 +77,5 @@ void KylinShield::ShowPrimaryView() main_layout->AddSpace(0, 10); } -nux::Area* KylinShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers) -{ - if (primary) - { - grab_key.emit(modifiers, keysym); - - if (prompt_view_) - { - auto* focus_view = prompt_view_->focus_view(); - - if (focus_view && focus_view->GetInputEventSensitivity()) - return focus_view; - } - } - - return nullptr; -} - } } diff --git a/lockscreen/KylinLockScreenShield.h b/lockscreen/KylinLockScreenShield.h index 93294521a..fb33706b0 100644 --- a/lockscreen/KylinLockScreenShield.h +++ b/lockscreen/KylinLockScreenShield.h @@ -41,9 +41,6 @@ public: nux::ObjectPtr<AbstractUserPromptView> const&, int monitor, bool is_primary); -protected: - nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override; - private: void ShowPrimaryView() override; }; diff --git a/lockscreen/LockScreenBaseShield.cpp b/lockscreen/LockScreenBaseShield.cpp index a3154c654..cfd56814c 100644 --- a/lockscreen/LockScreenBaseShield.cpp +++ b/lockscreen/LockScreenBaseShield.cpp @@ -81,11 +81,6 @@ BaseShield::BaseShield(session::Manager::Ptr const& session, background_layer_.reset(); UpdateBackgroundTexture(); }); - - mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) { - auto const& abs_geo = GetAbsoluteGeometry(); - grab_motion.emit(abs_geo.x + x, abs_geo.y + y); - }); } bool BaseShield::HasGrab() const @@ -94,6 +89,19 @@ bool BaseShield::HasGrab() const return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this); } +nux::Area* BaseShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers) +{ + if (primary && prompt_view_) + { + auto* focus_view = prompt_view_->focus_view(); + + if (focus_view && focus_view->GetInputEventSensitivity()) + return focus_view; + } + + return nullptr; +} + nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) { nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type); diff --git a/lockscreen/LockScreenBaseShield.h b/lockscreen/LockScreenBaseShield.h index bf2ff0288..9cd1e164e 100644 --- a/lockscreen/LockScreenBaseShield.h +++ b/lockscreen/LockScreenBaseShield.h @@ -54,14 +54,13 @@ public: 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; protected: virtual bool AcceptKeyNavFocus() { return false; } virtual void ShowPrimaryView() = 0; virtual void ShowSecondaryView(); + nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override; nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override; void GrabScreen(bool cancel_on_failure); diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index d8c7ecb3a..2ede0f7a7 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -121,6 +121,8 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager, if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD) { + auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_); + input::Monitor::Get().UnregisterClient(events_cb); primary_shield_connections_.Clear(); uscreen_connection_->block(); hidden_window_connection_->block(); @@ -200,6 +202,20 @@ void Controller::OnPrimaryShieldMotion(int x, int y) break; } } +} + +void Controller::OnLockScreenInputEvent(XEvent const& event) +{ + switch (event.type) + { + case MotionNotify: + case ButtonPress: + if (primary_shield_->IsIndicatorOpen()) + break; + case ButtonRelease: + OnPrimaryShieldMotion(event.xmotion.x_root, event.xmotion.y_root); + break; + } ResetPostLockScreenSaver(); } @@ -211,11 +227,8 @@ void Controller::SetupPrimaryShieldConnections() 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)); + auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_); + input::Monitor::Get().RegisterClient(input::Events::INPUT, events_cb); if (!session_manager_->is_locked()) { diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h index f3d3e2c55..f1b50426e 100644 --- a/lockscreen/LockScreenController.h +++ b/lockscreen/LockScreenController.h @@ -78,6 +78,7 @@ private: void OnPresenceStatusChanged(bool idle); void OnScreenSaverActivationRequest(bool activate); void OnPrimaryShieldMotion(int x, int y); + void OnLockScreenInputEvent(XEvent const&); void OnBlankWindowInputEvent(XEvent const&); std::vector<nux::ObjectPtr<BaseShield>> shields_; diff --git a/lockscreen/LockScreenShield.cpp b/lockscreen/LockScreenShield.cpp index ba6275eaa..77d8fc574 100644 --- a/lockscreen/LockScreenShield.cpp +++ b/lockscreen/LockScreenShield.cpp @@ -119,8 +119,6 @@ nux::Area* Shield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsign { if (primary) { - grab_key.emit(modifiers, keysym); - if (accelerators_) { if (etype == nux::EVENT_KEY_DOWN) @@ -134,17 +132,9 @@ nux::Area* Shield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsign return panel_view_; } } - - if (prompt_view_) - { - auto* focus_view = prompt_view_->focus_view(); - - if (focus_view && focus_view->GetInputEventSensitivity()) - return focus_view; - } } - return nullptr; + return BaseShield::FindKeyFocusArea(etype, keysym, modifiers); } bool Shield::IsIndicatorOpen() const |
