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: no longer in the source branch.
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.
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
1=== modified file 'lockscreen/KylinLockScreenShield.cpp'
2--- lockscreen/KylinLockScreenShield.cpp 2016-08-30 17:46:37 +0000
3+++ lockscreen/KylinLockScreenShield.cpp 2016-08-30 17:46:38 +0000
4@@ -77,23 +77,5 @@
5 main_layout->AddSpace(0, 10);
6 }
7
8-nux::Area* KylinShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
9-{
10- if (primary)
11- {
12- grab_key.emit(modifiers, keysym);
13-
14- if (prompt_view_)
15- {
16- auto* focus_view = prompt_view_->focus_view();
17-
18- if (focus_view && focus_view->GetInputEventSensitivity())
19- return focus_view;
20- }
21- }
22-
23- return nullptr;
24-}
25-
26 }
27 }
28
29=== modified file 'lockscreen/KylinLockScreenShield.h'
30--- lockscreen/KylinLockScreenShield.h 2015-12-07 03:09:28 +0000
31+++ lockscreen/KylinLockScreenShield.h 2016-08-30 17:46:38 +0000
32@@ -41,9 +41,6 @@
33 nux::ObjectPtr<AbstractUserPromptView> const&,
34 int monitor, bool is_primary);
35
36-protected:
37- nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
38-
39 private:
40 void ShowPrimaryView() override;
41 };
42
43=== modified file 'lockscreen/LockScreenBaseShield.cpp'
44--- lockscreen/LockScreenBaseShield.cpp 2016-08-30 17:46:37 +0000
45+++ lockscreen/LockScreenBaseShield.cpp 2016-08-30 17:46:38 +0000
46@@ -81,11 +81,6 @@
47 background_layer_.reset();
48 UpdateBackgroundTexture();
49 });
50-
51- mouse_move.connect([this] (int x, int y, int, int, unsigned long, unsigned long) {
52- auto const& abs_geo = GetAbsoluteGeometry();
53- grab_motion.emit(abs_geo.x + x, abs_geo.y + y);
54- });
55 }
56
57 bool BaseShield::HasGrab() const
58@@ -94,6 +89,19 @@
59 return (wc.GetPointerGrabArea() == this && wc.GetKeyboardGrabArea() == this);
60 }
61
62+nux::Area* BaseShield::FindKeyFocusArea(unsigned etype, unsigned long keysym, unsigned long modifiers)
63+{
64+ if (primary && prompt_view_)
65+ {
66+ auto* focus_view = prompt_view_->focus_view();
67+
68+ if (focus_view && focus_view->GetInputEventSensitivity())
69+ return focus_view;
70+ }
71+
72+ return nullptr;
73+}
74+
75 nux::Area* BaseShield::FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type)
76 {
77 nux::Area* area = BaseWindow::FindAreaUnderMouse(mouse, event_type);
78
79=== modified file 'lockscreen/LockScreenBaseShield.h'
80--- lockscreen/LockScreenBaseShield.h 2016-08-30 17:46:37 +0000
81+++ lockscreen/LockScreenBaseShield.h 2016-08-30 17:46:38 +0000
82@@ -54,14 +54,13 @@
83
84 sigc::signal<void> grabbed;
85 sigc::signal<void> grab_failed;
86- sigc::signal<void, int, int> grab_motion;
87- sigc::signal<void, unsigned long, unsigned long> grab_key;
88
89 protected:
90 virtual bool AcceptKeyNavFocus() { return false; }
91 virtual void ShowPrimaryView() = 0;
92 virtual void ShowSecondaryView();
93
94+ nux::Area* FindKeyFocusArea(unsigned int, unsigned long, unsigned long) override;
95 nux::Area* FindAreaUnderMouse(nux::Point const& mouse, nux::NuxEventType event_type) override;
96
97 void GrabScreen(bool cancel_on_failure);
98
99=== modified file 'lockscreen/LockScreenController.cpp'
100--- lockscreen/LockScreenController.cpp 2016-08-30 17:46:37 +0000
101+++ lockscreen/LockScreenController.cpp 2016-08-30 17:46:38 +0000
102@@ -120,6 +120,8 @@
103
104 if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD)
105 {
106+ auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_);
107+ input::Monitor::Get().UnregisterClient(events_cb);
108 primary_shield_connections_.Clear();
109 uscreen_connection_->block();
110 hidden_window_connection_->block();
111@@ -199,6 +201,20 @@
112 break;
113 }
114 }
115+}
116+
117+void Controller::OnLockScreenInputEvent(XEvent const& event)
118+{
119+ switch (event.type)
120+ {
121+ case MotionNotify:
122+ case ButtonPress:
123+ if (primary_shield_->IsIndicatorOpen())
124+ break;
125+ case ButtonRelease:
126+ OnPrimaryShieldMotion(event.xmotion.x_root, event.xmotion.y_root);
127+ break;
128+ }
129
130 ResetPostLockScreenSaver();
131 }
132@@ -210,11 +226,8 @@
133
134 primary_shield_connections_.Clear();
135
136- auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);
137- primary_shield_connections_.Add(primary_shield_->grab_motion.connect(move_cb));
138-
139- auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
140- primary_shield_connections_.Add(primary_shield_->grab_key.connect(key_cb));
141+ auto events_cb = sigc::track_obj(sigc::mem_fun(this, &Controller::OnLockScreenInputEvent), *primary_shield_);
142+ input::Monitor::Get().RegisterClient(input::Events::INPUT, events_cb);
143
144 if (!session_manager_->is_locked())
145 {
146
147=== modified file 'lockscreen/LockScreenController.h'
148--- lockscreen/LockScreenController.h 2016-08-30 17:46:37 +0000
149+++ lockscreen/LockScreenController.h 2016-08-30 17:46:38 +0000
150@@ -78,6 +78,7 @@
151 void OnPresenceStatusChanged(bool idle);
152 void OnScreenSaverActivationRequest(bool activate);
153 void OnPrimaryShieldMotion(int x, int y);
154+ void OnLockScreenInputEvent(XEvent const&);
155 void OnBlankWindowInputEvent(XEvent const&);
156
157 std::vector<nux::ObjectPtr<BaseShield>> shields_;
158
159=== modified file 'lockscreen/LockScreenShield.cpp'
160--- lockscreen/LockScreenShield.cpp 2016-08-30 17:46:37 +0000
161+++ lockscreen/LockScreenShield.cpp 2016-08-30 17:46:38 +0000
162@@ -119,8 +119,6 @@
163 {
164 if (primary)
165 {
166- grab_key.emit(modifiers, keysym);
167-
168 if (accelerators_)
169 {
170 if (etype == nux::EVENT_KEY_DOWN)
171@@ -134,17 +132,9 @@
172 return panel_view_;
173 }
174 }
175-
176- if (prompt_view_)
177- {
178- auto* focus_view = prompt_view_->focus_view();
179-
180- if (focus_view && focus_view->GetInputEventSensitivity())
181- return focus_view;
182- }
183 }
184
185- return nullptr;
186+ return BaseShield::FindKeyFocusArea(etype, keysym, modifiers);
187 }
188
189 bool Shield::IsIndicatorOpen() const