Merge lp:~3v1n0/unity/input-monitor-lockscreen-controller into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 3838
Merged at revision: 4207
Proposed branch: lp:~3v1n0/unity/input-monitor-lockscreen-controller
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/input-monitor-lockscreen-blank-window
Diff against target: 189 lines (+34/-44)
7 files modified
lockscreen/KylinLockScreenShield.cpp (+0/-18)
lockscreen/KylinLockScreenShield.h (+0/-3)
lockscreen/LockScreenBaseShield.cpp (+13/-5)
lockscreen/LockScreenBaseShield.h (+1/-2)
lockscreen/LockScreenController.cpp (+18/-5)
lockscreen/LockScreenController.h (+1/-0)
lockscreen/LockScreenShield.cpp (+1/-11)
To merge this branch: bzr merge lp:~3v1n0/unity/input-monitor-lockscreen-controller
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+304396@code.launchpad.net

Commit message

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).

To post a comment you must log in.
3835. By Marco Trevisan (Treviño)

LockScreenController: use track_obj to monitor input events on primary shield

Once released the input monitor will do the needed work to remove it.

3836. By Marco Trevisan (Treviño)

LockScreenController: be simpler, just register and unregister monitors when needed

3837. By Marco Trevisan (Treviño)

LockScreenController: use track_obj to avoid calling input callbacks when primary shield is destroyed

3838. By Marco Trevisan (Treviño)

LockScreenShield: move the shared definition for FindKeyFocusArea to BaseShield

Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lockscreen/KylinLockScreenShield.cpp'
--- lockscreen/KylinLockScreenShield.cpp 2016-08-30 17:46:37 +0000
+++ lockscreen/KylinLockScreenShield.cpp 2016-08-30 17:46:38 +0000
@@ -77,23 +77,5 @@
77 main_layout->AddSpace(0, 10);77 main_layout->AddSpace(0, 10);
78}78}
7979
80nux::Area* KylinShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
81{
82 if (primary)
83 {
84 grab_key.emit(modifiers, keysym);
85
86 if (prompt_view_)
87 {
88 auto* focus_view = prompt_view_->focus_view();
89
90 if (focus_view && focus_view->GetInputEventSensitivity())
91 return focus_view;
92 }
93 }
94
95 return nullptr;
96}
97
98}80}
99}81}
10082
=== modified file 'lockscreen/KylinLockScreenShield.h'
--- lockscreen/KylinLockScreenShield.h 2015-12-07 03:09:28 +0000
+++ lockscreen/KylinLockScreenShield.h 2016-08-30 17:46:38 +0000
@@ -41,9 +41,6 @@
41 nux::ObjectPtr<AbstractUserPromptView> const&,41 nux::ObjectPtr<AbstractUserPromptView> const&,
42 int monitor, bool is_primary);42 int monitor, bool is_primary);
4343
44protected:
45 nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
46
47private:44private:
48 void ShowPrimaryView() override;45 void ShowPrimaryView() override;
49};46};
5047
=== modified file 'lockscreen/LockScreenBaseShield.cpp'
--- lockscreen/LockScreenBaseShield.cpp 2016-08-30 17:46:37 +0000
+++ lockscreen/LockScreenBaseShield.cpp 2016-08-30 17:46:38 +0000
@@ -81,11 +81,6 @@
81 background_layer_.reset();81 background_layer_.reset();
82 UpdateBackgroundTexture();82 UpdateBackgroundTexture();
83 });83 });
84
85 mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) {
86 auto const& abs_geo = GetAbsoluteGeometry();
87 grab_motion.emit(abs_geo.x + x, abs_geo.y + y);
88 });
89}84}
9085
91bool BaseShield::HasGrab() const86bool BaseShield::HasGrab() const
@@ -94,6 +89,19 @@
94 return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);89 return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);
95}90}
9691
92nux::Area* BaseShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
93{
94 if (primary && prompt_view_)
95 {
96 auto* focus_view = prompt_view_->focus_view();
97
98 if (focus_view && focus_view->GetInputEventSensitivity())
99 return focus_view;
100 }
101
102 return nullptr;
103}
104
97nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type)105nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type)
98{106{
99 nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type);107 nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type);
100108
=== modified file 'lockscreen/LockScreenBaseShield.h'
--- lockscreen/LockScreenBaseShield.h 2016-08-30 17:46:37 +0000
+++ lockscreen/LockScreenBaseShield.h 2016-08-30 17:46:38 +0000
@@ -54,14 +54,13 @@
5454
55 sigc::signal<void> grabbed;55 sigc::signal<void> grabbed;
56 sigc::signal<void> grab_failed;56 sigc::signal<void> grab_failed;
57 sigc::signal<void, int, int> grab_motion;
58 sigc::signal<void, unsigned long, unsigned long> grab_key;
5957
60protected:58protected:
61 virtual bool AcceptKeyNavFocus() { return false; }59 virtual bool AcceptKeyNavFocus() { return false; }
62 virtual void ShowPrimaryView() = 0;60 virtual void ShowPrimaryView() = 0;
63 virtual void ShowSecondaryView();61 virtual void ShowSecondaryView();
6462
63 nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
65 nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override;64 nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override;
6665
67 void GrabScreen(bool cancel_on_failure);66 void GrabScreen(bool cancel_on_failure);
6867
=== modified file 'lockscreen/LockScreenController.cpp'
--- lockscreen/LockScreenController.cpp 2016-08-30 17:46:37 +0000
+++ lockscreen/LockScreenController.cpp 2016-08-30 17:46:38 +0000
@@ -120,6 +120,8 @@
120120
121 if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD)121 if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD)
122 {122 {
123 auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_);
124 input::Monitor::Get().UnregisterClient(events_cb);
123 primary_shield_connections_.Clear();125 primary_shield_connections_.Clear();
124 uscreen_connection_->block();126 uscreen_connection_->block();
125 hidden_window_connection_->block();127 hidden_window_connection_->block();
@@ -199,6 +201,20 @@
199 break;201 break;
200 }202 }
201 }203 }
204}
205
206void Controller::OnLockScreenInputEvent(XEvent const& event)
207{
208 switch (event.type)
209 {
210 case MotionNotify:
211 case ButtonPress:
212 if (primary_shield_->IsIndicatorOpen())
213 break;
214 case ButtonRelease:
215 OnPrimaryShieldMotion(event.xmotion.x_root, event.xmotion.y_root);
216 break;
217 }
202218
203 ResetPostLockScreenSaver();219 ResetPostLockScreenSaver();
204}220}
@@ -210,11 +226,8 @@
210226
211 primary_shield_connections_.Clear();227 primary_shield_connections_.Clear();
212228
213 auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);229 auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_);
214 primary_shield_connections_.Add(primary_shield_->grab_motion.connect(move_cb));230 input::Monitor::Get().RegisterClient(input::Events::INPUT, events_cb);
215
216 auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
217 primary_shield_connections_.Add(primary_shield_->grab_key.connect(key_cb));
218231
219 if (!session_manager_->is_locked())232 if (!session_manager_->is_locked())
220 {233 {
221234
=== modified file 'lockscreen/LockScreenController.h'
--- lockscreen/LockScreenController.h 2016-08-30 17:46:37 +0000
+++ lockscreen/LockScreenController.h 2016-08-30 17:46:38 +0000
@@ -78,6 +78,7 @@
78 void OnPresenceStatusChanged(bool idle);78 void OnPresenceStatusChanged(bool idle);
79 void OnScreenSaverActivationRequest(bool activate);79 void OnScreenSaverActivationRequest(bool activate);
80 void OnPrimaryShieldMotion(int x, int y);80 void OnPrimaryShieldMotion(int x, int y);
81 void OnLockScreenInputEvent(XEvent const&);
81 void OnBlankWindowInputEvent(XEvent const&);82 void OnBlankWindowInputEvent(XEvent const&);
8283
83 std::vector<nux::ObjectPtr<BaseShield>> shields_;84 std::vector<nux::ObjectPtr<BaseShield>> shields_;
8485
=== modified file 'lockscreen/LockScreenShield.cpp'
--- lockscreen/LockScreenShield.cpp 2016-08-30 17:46:37 +0000
+++ lockscreen/LockScreenShield.cpp 2016-08-30 17:46:38 +0000
@@ -119,8 +119,6 @@
119{119{
120 if (primary)120 if (primary)
121 {121 {
122 grab_key.emit(modifiers, keysym);
123
124 if (accelerators_)122 if (accelerators_)
125 {123 {
126 if (etype == nux::EVENT_KEY_DOWN)124 if (etype == nux::EVENT_KEY_DOWN)
@@ -134,17 +132,9 @@
134 return panel_view_;132 return panel_view_;
135 }133 }
136 }134 }
137
138 if (prompt_view_)
139 {
140 auto* focus_view = prompt_view_->focus_view();
141
142 if (focus_view && focus_view->GetInputEventSensitivity())
143 return focus_view;
144 }
145 }135 }
146136
147 return nullptr;137 return BaseShield::FindKeyFocusArea(etype, keysym, modifiers);
148}138}
149139
150bool Shield::IsIndicatorOpen() const140bool Shield::IsIndicatorOpen() const