Merge lp:~3v1n0/unity/lockscreen-keys-disable into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3792
Proposed branch: lp:~3v1n0/unity/lockscreen-keys-disable
Merge into: lp:unity
Diff against target: 311 lines (+93/-26)
8 files modified
lockscreen/LockScreenController.cpp (+12/-3)
lockscreen/LockScreenController.h (+1/-0)
lockscreen/LockScreenShield.cpp (+14/-2)
lockscreen/LockScreenShield.h (+1/-0)
plugins/unityshell/src/unityshell.cpp (+54/-15)
plugins/unityshell/src/unityshell.h (+2/-0)
shutdown/SessionController.cpp (+7/-5)
tests/test_session_controller.cpp (+2/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/lockscreen-keys-disable
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+217528@code.launchpad.net

Commit message

UnityScreen: toggle activation of all the unity compiz actions when locking the screen

Also, make sure that the lockscreen views are treated as "always-on-front" windows by nux
(and this applies to both visibility and events).

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Sweet. Confirmed working, and way better then my workaround. This will work for all possibly compiz actions, so this is now impossible to happen!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lockscreen/LockScreenController.cpp'
2--- lockscreen/LockScreenController.cpp 2014-04-11 07:26:11 +0000
3+++ lockscreen/LockScreenController.cpp 2014-04-30 15:34:13 +0000
4@@ -69,9 +69,14 @@
5 EnsureShields(monitors);
6 EnsureBlankWindow();
7 });
8-
9 uscreen_connection_->block();
10
11+ hidden_window_connection_ = nux::GetWindowCompositor().sigHiddenViewWindow.connect([this] (nux::BaseWindow*) {
12+ // Another view (i.e. the shutdown dialog) might have taken the role of AlwaysOnFront window
13+ nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer());
14+ });
15+ hidden_window_connection_->block();
16+
17 suspend_connection_ = uscreen->suspending.connect([this] {
18 if (Settings::Instance().lock_on_suspend())
19 session_manager_->PromptLockScreen();
20@@ -98,6 +103,7 @@
21 motion_connection_->disconnect();
22 key_connection_->disconnect();
23 uscreen_connection_->block();
24+ hidden_window_connection_->block();
25 session_manager_->unlocked.emit();
26
27 std::for_each(shields_.begin(), shields_.end(), [](nux::ObjectPtr<Shield> const& shield) {
28@@ -160,6 +166,7 @@
29 primary_shield_ = shield;
30 primary_shield_->CheckCapsLockPrompt();
31 shield->primary = true;
32+ nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer());
33 auto move_cb = sigc::mem_fun(this, &Controller::OnPrimaryShieldMotion);
34 motion_connection_ = shield->grab_motion.connect(move_cb);
35 auto key_cb = sigc::hide(sigc::hide(sigc::mem_fun(this, &Controller::ResetPostLockScreenSaver)));
36@@ -220,7 +227,7 @@
37 blank_window_->SetBackgroundLayer(new nux::ColorLayer(nux::color::Black, true));
38 blank_window_->SetOpacity(blank_window_animator_.GetCurrentValue());
39 blank_window_->ShowWindow(true);
40- blank_window_->PushToFront();
41+ nux::GetWindowCompositor().SetAlwaysOnFrontWindow(blank_window_.GetPointer());
42 }
43
44 blank_window_->SetGeometry(screen_geo);
45@@ -264,7 +271,7 @@
46 blank_window_->EnableInputWindow(true);
47 blank_window_->GrabPointer();
48 blank_window_->GrabKeyboard();
49- blank_window_->PushToFront();
50+ nux::GetWindowCompositor().SetAlwaysOnFrontWindow(blank_window_.GetPointer());
51
52 blank_window_->mouse_move.connect([this](int, int, int dx, int dy, unsigned long, unsigned long) {
53 if ((dx || dy) && !lockscreen_timeout_) HideBlankWindow();
54@@ -401,6 +408,7 @@
55 WindowManager::Default().SaveInputFocus();
56 EnsureShields(UScreen::GetDefault()->GetMonitors());
57 uscreen_connection_->unblock();
58+ hidden_window_connection_->unblock();
59
60 std::for_each(shields_.begin(), shields_.end(), [] (nux::ObjectPtr<Shield> const& shield) {
61 shield->SetOpacity(0.0f);
62@@ -408,6 +416,7 @@
63 shield->PushToFront();
64 });
65
66+ nux::GetWindowCompositor().SetAlwaysOnFrontWindow(primary_shield_.GetPointer());
67 animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
68 }
69
70
71=== modified file 'lockscreen/LockScreenController.h'
72--- lockscreen/LockScreenController.h 2014-04-10 06:36:43 +0000
73+++ lockscreen/LockScreenController.h 2014-04-30 15:34:13 +0000
74@@ -86,6 +86,7 @@
75
76 connection::Wrapper uscreen_connection_;
77 connection::Wrapper suspend_connection_;
78+ connection::Wrapper hidden_window_connection_;
79 connection::Wrapper motion_connection_;
80 connection::Wrapper key_connection_;
81
82
83=== modified file 'lockscreen/LockScreenShield.cpp'
84--- lockscreen/LockScreenShield.cpp 2014-04-10 17:43:34 +0000
85+++ lockscreen/LockScreenShield.cpp 2014-04-30 15:34:13 +0000
86@@ -149,13 +149,25 @@
87 {
88 if (active)
89 {
90+ regrab_conn_->disconnect();
91 UnGrabPointer();
92 UnGrabKeyboard();
93 }
94 else
95 {
96- GrabPointer();
97- GrabKeyboard();
98+ auto& wc = nux::GetWindowCompositor();
99+
100+ if (!wc.GrabPointerAdd(this) || !wc.GrabKeyboardAdd(this))
101+ {
102+ regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect([this] {
103+ if (primary())
104+ {
105+ GrabPointer();
106+ GrabKeyboard();
107+ }
108+ regrab_conn_->disconnect();
109+ });
110+ }
111 }
112 }
113 });
114
115=== modified file 'lockscreen/LockScreenShield.h'
116--- lockscreen/LockScreenShield.h 2014-04-09 17:09:18 +0000
117+++ lockscreen/LockScreenShield.h 2014-04-30 15:34:13 +0000
118@@ -58,6 +58,7 @@
119 nux::ObjectPtr<nux::Layout> primary_layout_;
120 nux::ObjectPtr<nux::Layout> cof_layout_;
121 connection::Wrapper panel_active_conn_;
122+ connection::Wrapper regrab_conn_;
123 UserPromptView* prompt_view_;
124 Panel* panel_view_;
125 };
126
127=== modified file 'plugins/unityshell/src/unityshell.cpp'
128--- plugins/unityshell/src/unityshell.cpp 2014-04-17 18:53:52 +0000
129+++ plugins/unityshell/src/unityshell.cpp 2014-04-30 15:34:13 +0000
130@@ -2027,9 +2027,6 @@
131 CompAction::State state,
132 CompOption::Vector& options)
133 {
134- if (lockscreen_controller_->IsLocked())
135- return true;
136-
137 // to receive the Terminate event
138 if (state & CompAction::StateInitKey)
139 action->setState(action->state() | CompAction::StateTermKey);
140@@ -2226,9 +2223,6 @@
141
142 void UnityScreen::SetUpAndShowSwitcher(switcher::ShowMode show_mode)
143 {
144- if(lockscreen_controller_->IsLocked())
145- return;
146-
147 RaiseInputWindows();
148
149 if (!optionGetAltTabBiasViewport())
150@@ -2481,8 +2475,7 @@
151 return false; // early exit if the switcher is open
152 }
153
154- if (PluginAdapter::Default().IsTopWindowFullscreenOnMonitorWithMouse() ||
155- lockscreen_controller_->IsLocked())
156+ if (PluginAdapter::Default().IsTopWindowFullscreenOnMonitorWithMouse())
157 {
158 return false;
159 }
160@@ -3734,24 +3727,70 @@
161 void UnityScreen::OnLockScreenRequested()
162 {
163 if (switcher_controller_->Visible())
164- {
165 switcher_controller_->Hide(false);
166- }
167- else if (launcher_controller_->IsOverlayOpen())
168- {
169+
170+ if (dash_controller_->IsVisible())
171 dash_controller_->HideDash();
172+
173+ if (hud_controller_->IsVisible())
174 hud_controller_->HideHud();
175- }
176
177 launcher_controller_->ClearTooltips();
178
179+ if (launcher_controller_->KeyNavIsActive())
180+ launcher_controller_->KeyNavTerminate(false);
181+
182+ if (QuicklistManager::Default()->Current())
183+ QuicklistManager::Default()->Current()->Hide();
184+
185 auto& wm = WindowManager::Default();
186+
187 if (wm.IsScaleActive())
188 wm.TerminateScale();
189
190+ if (wm.IsExpoActive())
191+ wm.TerminateExpo();
192+
193 RaiseOSK();
194 }
195
196+void UnityScreen::OnScreenLocked()
197+{
198+ SaveLockStamp(true);
199+
200+ for (auto& option : getOptions())
201+ {
202+ if (option.isAction())
203+ {
204+ auto& value = option.value();
205+
206+ if (value != mOptions[UnityshellOptions::PanelFirstMenu].value())
207+ screen->removeAction(&value.action());
208+ }
209+ }
210+
211+ for (auto& action : getActions())
212+ screen->removeAction(&action);
213+
214+ // We notify that super/alt have been released, to avoid to leave unity in inconsistent state
215+ showLauncherKeyTerminate(&optionGetShowLauncher(), CompAction::StateTermKey, getOptions());
216+ showMenuBarTerminate(&optionGetShowMenuBar(), CompAction::StateTermKey, getOptions());
217+}
218+
219+void UnityScreen::OnScreenUnlocked()
220+{
221+ SaveLockStamp(false);
222+
223+ for (auto& option : getOptions())
224+ {
225+ if (option.isAction())
226+ screen->addAction(&option.value().action());
227+ }
228+
229+ for (auto& action : getActions())
230+ screen->addAction(&action);
231+}
232+
233 void UnityScreen::SaveLockStamp(bool save)
234 {
235 auto const& cache_dir = DesktopUtilities::GetUserRuntimeDirectory();
236@@ -3845,8 +3884,8 @@
237 auto manager = std::make_shared<session::GnomeManager>();
238 manager->lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested));
239 manager->prompt_lock_requested.connect(sigc::mem_fun(this, &UnityScreen::OnLockScreenRequested));
240- manager->locked.connect(sigc::bind(sigc::mem_fun(this, &UnityScreen::SaveLockStamp), true));
241- manager->unlocked.connect(sigc::bind(sigc::mem_fun(this, &UnityScreen::SaveLockStamp), false));
242+ manager->locked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenLocked));
243+ manager->unlocked.connect(sigc::mem_fun(this, &UnityScreen::OnScreenUnlocked));
244 session_dbus_manager_ = std::make_shared<session::DBusManager>(manager);
245 session_controller_ = std::make_shared<session::Controller>(manager);
246 AddChild(session_controller_.get());
247
248=== modified file 'plugins/unityshell/src/unityshell.h'
249--- plugins/unityshell/src/unityshell.h 2014-04-16 22:17:50 +0000
250+++ plugins/unityshell/src/unityshell.h 2014-04-30 15:34:13 +0000
251@@ -233,6 +233,8 @@
252 void OnMinimizeDurationChanged();
253
254 void OnLockScreenRequested();
255+ void OnScreenLocked();
256+ void OnScreenUnlocked();
257 void SaveLockStamp(bool);
258
259 switcher::Controller::Ptr switcher_controller();
260
261=== modified file 'shutdown/SessionController.cpp'
262--- shutdown/SessionController.cpp 2014-01-06 19:50:53 +0000
263+++ shutdown/SessionController.cpp 2014-04-30 15:34:13 +0000
264@@ -101,8 +101,8 @@
265 view_->live_background = true;
266
267 view_window_->ShowWindow(true);
268- view_window_->PushToFront();
269 view_window_->SetInputFocus();
270+ nux::GetWindowCompositor().SetAlwaysOnFrontWindow(view_window_.GetPointer());
271 nux::GetWindowCompositor().SetKeyFocusArea(view_->key_focus_area());
272 animation::StartOrReverse(fade_animator_, animation::Direction::FORWARD);
273 }
274@@ -175,17 +175,19 @@
275
276 void Controller::Hide()
277 {
278- animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
279+ if (view_window_)
280+ animation::StartOrReverse(fade_animator_, animation::Direction::BACKWARD);
281 }
282
283 void Controller::CloseWindow()
284 {
285- view_window_->PushToBack();
286- view_window_->ShowWindow(false);
287 view_window_->UnGrabPointer();
288 view_window_->UnGrabKeyboard();
289+ view_window_->ShowWindow(false);
290 view_window_->EnableInputWindow(false);
291- view_->live_background = false;
292+
293+ view_ = nullptr;
294+ view_window_ = nullptr;
295
296 nux::GetWindowCompositor().SetKeyFocusArea(nullptr);
297 WindowManager::Default().RestoreInputFocus();
298
299=== modified file 'tests/test_session_controller.cpp'
300--- tests/test_session_controller.cpp 2014-03-21 04:40:12 +0000
301+++ tests/test_session_controller.cpp 2014-04-30 15:34:13 +0000
302@@ -105,7 +105,8 @@
303 tick_source.tick(ANIMATION_DURATION);
304
305 EXPECT_FALSE(controller.Visible());
306- EXPECT_FALSE(controller.view_->live_background());
307+ EXPECT_FALSE(controller.view_window_.IsValid());
308+ EXPECT_FALSE(controller.view_.IsValid());
309 }
310
311 struct Inhibited : TestSessionController, testing::WithParamInterface<bool> {};