Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 3837 | ||||
Proposed branch: | lp:~azzar1/unity/sh-72 | ||||
Merge into: | lp:unity/7.2 | ||||
Diff against target: |
1030 lines (+242/-469) 25 files modified
UnityCore/GnomeSessionManager.cpp (+8/-2) UnityCore/SessionManager.h (+1/-0) lockscreen/CMakeLists.txt (+1/-2) lockscreen/LockScreenAbstractShield.h (+3/-5) lockscreen/LockScreenAcceleratorController.h (+1/-1) lockscreen/LockScreenController.cpp (+26/-9) lockscreen/LockScreenController.h (+3/-5) lockscreen/LockScreenPanel.h (+3/-3) lockscreen/LockScreenShieldFactory.h (+2/-0) lockscreen/ShutdownNotifier.cpp (+0/-152) lockscreen/ShutdownNotifier.h (+0/-51) lockscreen/SuspendInhibitorManager.cpp (+131/-0) lockscreen/SuspendInhibitorManager.h (+54/-0) lockscreen/SuspendNotifier.cpp (+0/-153) lockscreen/SuspendNotifier.h (+0/-51) lockscreen/UserPromptView.h (+1/-1) lockscreen/pch/lockscreen_pch.hh (+2/-2) shutdown/SessionController.h (+1/-1) shutdown/SessionDBusManager.h (+3/-3) shutdown/SessionView.h (+1/-1) tests/test_mock_session_manager.h (+1/-1) unity-shared/PluginAdapter.cpp (+0/-20) unity-shared/PluginAdapter.h (+0/-1) unity-shared/StandaloneWindowManager.h (+0/-2) unity-shared/WindowManager.h (+0/-3) |
||||
To merge this branch: | bzr merge lp:~azzar1/unity/sh-72 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Review via email: mp+291231@code.launchpad.net |
Commit message
Improve the "lock on suspend" logic to always keep in sync the inhibitor with the lockscreen.
Description of the change
To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'UnityCore/GnomeSessionManager.cpp' | |||
2 | --- UnityCore/GnomeSessionManager.cpp 2015-10-21 15:54:37 +0000 | |||
3 | +++ UnityCore/GnomeSessionManager.cpp 2016-04-07 11:57:30 +0000 | |||
4 | @@ -115,8 +115,14 @@ | |||
5 | 115 | manager_->unlock_requested.emit(); | 115 | manager_->unlock_requested.emit(); |
6 | 116 | }); | 116 | }); |
7 | 117 | 117 | ||
10 | 118 | login_proxy_->ConnectProperty("Active", [this] (GVariant* active) { | 118 | login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) { |
11 | 119 | manager_->screensaver_requested.emit(!glib::Variant(active).GetBool()); | 119 | bool active = glib::Variant(variant).GetBool(); |
12 | 120 | manager_->screensaver_requested.emit(!active); | ||
13 | 121 | manager_->is_session_active.changed.emit(active); | ||
14 | 122 | }); | ||
15 | 123 | |||
16 | 124 | manager_->is_session_active.SetGetterFunction([this] { | ||
17 | 125 | return login_proxy_->GetProperty("Active").GetBool(); | ||
18 | 120 | }); | 126 | }); |
19 | 121 | } | 127 | } |
20 | 122 | 128 | ||
21 | 123 | 129 | ||
22 | === modified file 'UnityCore/SessionManager.h' | |||
23 | --- UnityCore/SessionManager.h 2014-07-23 18:56:11 +0000 | |||
24 | +++ UnityCore/SessionManager.h 2016-04-07 11:57:30 +0000 | |||
25 | @@ -40,6 +40,7 @@ | |||
26 | 40 | 40 | ||
27 | 41 | nux::ROProperty<bool> have_other_open_sessions; | 41 | nux::ROProperty<bool> have_other_open_sessions; |
28 | 42 | nux::Property<bool> is_locked; | 42 | nux::Property<bool> is_locked; |
29 | 43 | nux::ROProperty<bool> is_session_active; | ||
30 | 43 | 44 | ||
31 | 44 | virtual std::string RealName() const = 0; | 45 | virtual std::string RealName() const = 0; |
32 | 45 | virtual std::string UserName() const = 0; | 46 | virtual std::string UserName() const = 0; |
33 | 46 | 47 | ||
34 | === modified file 'lockscreen/CMakeLists.txt' | |||
35 | --- lockscreen/CMakeLists.txt 2014-12-16 19:27:36 +0000 | |||
36 | +++ lockscreen/CMakeLists.txt 2016-04-07 11:57:30 +0000 | |||
37 | @@ -27,8 +27,7 @@ | |||
38 | 27 | LockScreenAcceleratorController.cpp | 27 | LockScreenAcceleratorController.cpp |
39 | 28 | LockScreenAccelerators.cpp | 28 | LockScreenAccelerators.cpp |
40 | 29 | ScreenSaverDBusManager.cpp | 29 | ScreenSaverDBusManager.cpp |
43 | 30 | ShutdownNotifier.cpp | 30 | SuspendInhibitorManager.cpp |
42 | 31 | SuspendNotifier.cpp | ||
44 | 32 | UserAuthenticatorPam.cpp | 31 | UserAuthenticatorPam.cpp |
45 | 33 | UserPromptView.cpp | 32 | UserPromptView.cpp |
46 | 34 | ) | 33 | ) |
47 | 35 | 34 | ||
48 | === modified file 'lockscreen/LockScreenAbstractShield.h' | |||
49 | --- lockscreen/LockScreenAbstractShield.h 2014-12-15 19:12:07 +0000 | |||
50 | +++ lockscreen/LockScreenAbstractShield.h 2016-04-07 11:57:30 +0000 | |||
51 | @@ -21,19 +21,17 @@ | |||
52 | 21 | #define UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H | 21 | #define UNITY_LOCKSCREEN_ABSTRACT_SHIELD_H |
53 | 22 | 22 | ||
54 | 23 | #include <NuxCore/Property.h> | 23 | #include <NuxCore/Property.h> |
58 | 24 | #include <UnityCore/SessionManager.h> | 24 | #include "UnityCore/SessionManager.h" |
59 | 25 | #include <UnityCore/Indicators.h> | 25 | #include "UnityCore/Indicators.h" |
57 | 26 | |||
60 | 27 | #include "unity-shared/MockableBaseWindow.h" | 26 | #include "unity-shared/MockableBaseWindow.h" |
61 | 28 | #include "LockScreenAccelerators.h" | 27 | #include "LockScreenAccelerators.h" |
62 | 28 | #include "UserPromptView.h" | ||
63 | 29 | 29 | ||
64 | 30 | namespace unity | 30 | namespace unity |
65 | 31 | { | 31 | { |
66 | 32 | namespace lockscreen | 32 | namespace lockscreen |
67 | 33 | { | 33 | { |
68 | 34 | 34 | ||
69 | 35 | class UserPromptView; | ||
70 | 36 | |||
71 | 37 | class AbstractShield : public MockableBaseWindow | 35 | class AbstractShield : public MockableBaseWindow |
72 | 38 | { | 36 | { |
73 | 39 | public: | 37 | public: |
74 | 40 | 38 | ||
75 | === modified file 'lockscreen/LockScreenAcceleratorController.h' | |||
76 | --- lockscreen/LockScreenAcceleratorController.h 2014-07-23 18:56:11 +0000 | |||
77 | +++ lockscreen/LockScreenAcceleratorController.h 2016-04-07 11:57:30 +0000 | |||
78 | @@ -20,7 +20,7 @@ | |||
79 | 20 | #ifndef UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER | 20 | #ifndef UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER |
80 | 21 | #define UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER | 21 | #define UNITY_LOCKSCREEN_ACCELERATOR_CONTROLLER |
81 | 22 | 22 | ||
83 | 23 | #include <UnityCore/SessionManager.h> | 23 | #include "UnityCore/SessionManager.h" |
84 | 24 | #include "LockScreenAccelerators.h" | 24 | #include "LockScreenAccelerators.h" |
85 | 25 | 25 | ||
86 | 26 | namespace unity | 26 | namespace unity |
87 | 27 | 27 | ||
88 | === modified file 'lockscreen/LockScreenController.cpp' | |||
89 | --- lockscreen/LockScreenController.cpp 2015-05-15 19:39:03 +0000 | |||
90 | +++ lockscreen/LockScreenController.cpp 2016-04-07 11:57:30 +0000 | |||
91 | @@ -25,6 +25,7 @@ | |||
92 | 25 | 25 | ||
93 | 26 | #include "LockScreenShield.h" | 26 | #include "LockScreenShield.h" |
94 | 27 | #include "LockScreenSettings.h" | 27 | #include "LockScreenSettings.h" |
95 | 28 | #include "UserPromptView.h" | ||
96 | 28 | #include "unity-shared/AnimationUtils.h" | 29 | #include "unity-shared/AnimationUtils.h" |
97 | 29 | #include "unity-shared/UScreen.h" | 30 | #include "unity-shared/UScreen.h" |
98 | 30 | #include "unity-shared/WindowManager.h" | 31 | #include "unity-shared/WindowManager.h" |
99 | @@ -60,7 +61,7 @@ | |||
100 | 60 | , session_manager_(session_manager) | 61 | , session_manager_(session_manager) |
101 | 61 | , upstart_wrapper_(upstart_wrapper) | 62 | , upstart_wrapper_(upstart_wrapper) |
102 | 62 | , shield_factory_(shield_factory) | 63 | , shield_factory_(shield_factory) |
104 | 63 | , suspend_notifier_(std::make_shared<SuspendNotifier>()) | 64 | , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>()) |
105 | 64 | , fade_animator_(LOCK_FADE_DURATION) | 65 | , fade_animator_(LOCK_FADE_DURATION) |
106 | 65 | , blank_window_animator_(IDLE_FADE_DURATION) | 66 | , blank_window_animator_(IDLE_FADE_DURATION) |
107 | 66 | , test_mode_(test_mode) | 67 | , test_mode_(test_mode) |
108 | @@ -79,17 +80,22 @@ | |||
109 | 79 | }); | 80 | }); |
110 | 80 | hidden_window_connection_->block(); | 81 | hidden_window_connection_->block(); |
111 | 81 | 82 | ||
113 | 82 | suspend_notifier_->RegisterInterest([this](){ | 83 | suspend_inhibitor_manager_->about_to_suspend.connect([this] () { |
114 | 83 | if (Settings::Instance().lock_on_suspend()) | 84 | if (Settings::Instance().lock_on_suspend()) |
115 | 84 | session_manager_->PromptLockScreen(); | 85 | session_manager_->PromptLockScreen(); |
116 | 85 | }); | 86 | }); |
117 | 86 | 87 | ||
118 | 88 | Settings::Instance().lock_on_suspend.changed.connect(sigc::hide(sigc::mem_fun(this, &Controller::SyncInhibitor))); | ||
119 | 89 | Settings::Instance().use_legacy.changed.connect(sigc::hide(sigc::mem_fun(this, &Controller::SyncInhibitor))); | ||
120 | 90 | suspend_inhibitor_manager_->connected.connect(sigc::mem_fun(this, &Controller::SyncInhibitor)); | ||
121 | 91 | |||
122 | 87 | dbus_manager_->simulate_activity.connect(sigc::mem_fun(this, &Controller::SimulateActivity)); | 92 | dbus_manager_->simulate_activity.connect(sigc::mem_fun(this, &Controller::SimulateActivity)); |
123 | 88 | session_manager_->screensaver_requested.connect(sigc::mem_fun(this, &Controller::OnScreenSaverActivationRequest)); | 93 | session_manager_->screensaver_requested.connect(sigc::mem_fun(this, &Controller::OnScreenSaverActivationRequest)); |
124 | 89 | session_manager_->lock_requested.connect(sigc::bind(sigc::mem_fun(this, &Controller::OnLockRequested), false)); | 94 | session_manager_->lock_requested.connect(sigc::bind(sigc::mem_fun(this, &Controller::OnLockRequested), false)); |
125 | 90 | session_manager_->prompt_lock_requested.connect(sigc::bind(sigc::mem_fun(this, &Controller::OnLockRequested), true)); | 95 | session_manager_->prompt_lock_requested.connect(sigc::bind(sigc::mem_fun(this, &Controller::OnLockRequested), true)); |
126 | 91 | session_manager_->unlock_requested.connect(sigc::mem_fun(this, &Controller::OnUnlockRequested)); | 96 | session_manager_->unlock_requested.connect(sigc::mem_fun(this, &Controller::OnUnlockRequested)); |
127 | 92 | session_manager_->presence_status_changed.connect(sigc::mem_fun(this, &Controller::OnPresenceStatusChanged)); | 97 | session_manager_->presence_status_changed.connect(sigc::mem_fun(this, &Controller::OnPresenceStatusChanged)); |
128 | 98 | session_manager_->is_session_active.changed.connect(sigc::hide(sigc::mem_fun(this, &Controller::SyncInhibitor))); | ||
129 | 93 | 99 | ||
130 | 94 | fade_animator_.updated.connect([this](double value) { | 100 | fade_animator_.updated.connect([this](double value) { |
131 | 95 | std::for_each(shields_.begin(), shields_.end(), [value](nux::ObjectPtr<Shield> const& shield) { | 101 | std::for_each(shields_.begin(), shields_.end(), [value](nux::ObjectPtr<Shield> const& shield) { |
132 | @@ -100,6 +106,8 @@ | |||
133 | 100 | }); | 106 | }); |
134 | 101 | 107 | ||
135 | 102 | fade_animator_.finished.connect([this] { | 108 | fade_animator_.finished.connect([this] { |
136 | 109 | SyncInhibitor(); | ||
137 | 110 | |||
138 | 103 | if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD) | 111 | if (animation::GetDirection(fade_animator_) == animation::Direction::BACKWARD) |
139 | 104 | { | 112 | { |
140 | 105 | primary_shield_connections_.Clear(); | 113 | primary_shield_connections_.Clear(); |
141 | @@ -147,6 +155,8 @@ | |||
142 | 147 | })); | 155 | })); |
143 | 148 | } | 156 | } |
144 | 149 | }); | 157 | }); |
145 | 158 | |||
146 | 159 | SyncInhibitor(); | ||
147 | 150 | } | 160 | } |
148 | 151 | 161 | ||
149 | 152 | void Controller::ActivatePanel() | 162 | void Controller::ActivatePanel() |
150 | @@ -444,11 +454,6 @@ | |||
151 | 444 | indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>(); | 454 | indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>(); |
152 | 445 | upstart_wrapper_->Emit("desktop-lock"); | 455 | upstart_wrapper_->Emit("desktop-lock"); |
153 | 446 | 456 | ||
154 | 447 | shutdown_notifier_ = std::make_shared<ShutdownNotifier>(); | ||
155 | 448 | shutdown_notifier_->RegisterInterest([](){ | ||
156 | 449 | WindowManager::Default().UnmapAllNoNuxWindowsSync(); | ||
157 | 450 | }); | ||
158 | 451 | |||
159 | 452 | accelerator_controller_ = std::make_shared<AcceleratorController>(session_manager_); | 457 | accelerator_controller_ = std::make_shared<AcceleratorController>(session_manager_); |
160 | 453 | auto activate_key = WindowManager::Default().activate_indicators_key(); | 458 | auto activate_key = WindowManager::Default().activate_indicators_key(); |
161 | 454 | auto accelerator = std::make_shared<Accelerator>(activate_key.second, 0, activate_key.first); | 459 | auto accelerator = std::make_shared<Accelerator>(activate_key.second, 0, activate_key.first); |
162 | @@ -487,8 +492,6 @@ | |||
163 | 487 | 492 | ||
164 | 488 | void Controller::OnUnlockRequested() | 493 | void Controller::OnUnlockRequested() |
165 | 489 | { | 494 | { |
166 | 490 | shutdown_notifier_.reset(); | ||
167 | 491 | |||
168 | 492 | lockscreen_timeout_.reset(); | 495 | lockscreen_timeout_.reset(); |
169 | 493 | screensaver_post_lock_timeout_.reset(); | 496 | screensaver_post_lock_timeout_.reset(); |
170 | 494 | 497 | ||
171 | @@ -522,5 +525,19 @@ | |||
172 | 522 | return primary_shield_.IsValid() ? primary_shield_->IsIndicatorOpen() : false; | 525 | return primary_shield_.IsValid() ? primary_shield_->IsIndicatorOpen() : false; |
173 | 523 | } | 526 | } |
174 | 524 | 527 | ||
175 | 528 | void Controller::SyncInhibitor() | ||
176 | 529 | { | ||
177 | 530 | bool locked = IsLocked() && primary_shield_.IsValid() && primary_shield_->GetOpacity() == 1.0f; | ||
178 | 531 | bool inhibit = session_manager_->is_session_active() && | ||
179 | 532 | !locked && | ||
180 | 533 | Settings::Instance().lock_on_suspend() && | ||
181 | 534 | !Settings::Instance().use_legacy(); | ||
182 | 535 | |||
183 | 536 | if (inhibit) | ||
184 | 537 | suspend_inhibitor_manager_->Inhibit("Unity needs to lock the screen"); | ||
185 | 538 | else | ||
186 | 539 | suspend_inhibitor_manager_->Uninhibit(); | ||
187 | 540 | } | ||
188 | 541 | |||
189 | 525 | } // lockscreen | 542 | } // lockscreen |
190 | 526 | } // unity | 543 | } // unity |
191 | 527 | 544 | ||
192 | === modified file 'lockscreen/LockScreenController.h' | |||
193 | --- lockscreen/LockScreenController.h 2014-12-16 19:27:36 +0000 | |||
194 | +++ lockscreen/LockScreenController.h 2016-04-07 11:57:30 +0000 | |||
195 | @@ -26,10 +26,8 @@ | |||
196 | 26 | 26 | ||
197 | 27 | #include "LockScreenShieldFactory.h" | 27 | #include "LockScreenShieldFactory.h" |
198 | 28 | #include "LockScreenAcceleratorController.h" | 28 | #include "LockScreenAcceleratorController.h" |
199 | 29 | #include "SuspendInhibitorManager.h" | ||
200 | 29 | #include "ScreenSaverDBusManager.h" | 30 | #include "ScreenSaverDBusManager.h" |
201 | 30 | #include "ShutdownNotifier.h" | ||
202 | 31 | #include "SuspendNotifier.h" | ||
203 | 32 | #include "UserPromptView.h" | ||
204 | 33 | #include "unity-shared/BackgroundEffectHelper.h" | 31 | #include "unity-shared/BackgroundEffectHelper.h" |
205 | 34 | #include "unity-shared/UpstartWrapper.h" | 32 | #include "unity-shared/UpstartWrapper.h" |
206 | 35 | 33 | ||
207 | @@ -70,6 +68,7 @@ | |||
208 | 70 | void ResetPostLockScreenSaver(); | 68 | void ResetPostLockScreenSaver(); |
209 | 71 | void SetupPrimaryShieldConnections(); | 69 | void SetupPrimaryShieldConnections(); |
210 | 72 | void ActivatePanel(); | 70 | void ActivatePanel(); |
211 | 71 | void SyncInhibitor(); | ||
212 | 73 | 72 | ||
213 | 74 | void OnLockRequested(bool prompt); | 73 | void OnLockRequested(bool prompt); |
214 | 75 | void OnUnlockRequested(); | 74 | void OnUnlockRequested(); |
215 | @@ -88,8 +87,7 @@ | |||
216 | 88 | AcceleratorController::Ptr accelerator_controller_; | 87 | AcceleratorController::Ptr accelerator_controller_; |
217 | 89 | UpstartWrapper::Ptr upstart_wrapper_; | 88 | UpstartWrapper::Ptr upstart_wrapper_; |
218 | 90 | ShieldFactoryInterface::Ptr shield_factory_; | 89 | ShieldFactoryInterface::Ptr shield_factory_; |
221 | 91 | ShutdownNotifier::Ptr shutdown_notifier_; | 90 | SuspendInhibitorManager::Ptr suspend_inhibitor_manager_; |
220 | 92 | SuspendNotifier::Ptr suspend_notifier_; | ||
222 | 93 | 91 | ||
223 | 94 | nux::animation::AnimateValue<double> fade_animator_; | 92 | nux::animation::AnimateValue<double> fade_animator_; |
224 | 95 | nux::animation::AnimateValue<double> blank_window_animator_; | 93 | nux::animation::AnimateValue<double> blank_window_animator_; |
225 | 96 | 94 | ||
226 | === modified file 'lockscreen/LockScreenPanel.h' | |||
227 | --- lockscreen/LockScreenPanel.h 2014-04-30 00:45:17 +0000 | |||
228 | +++ lockscreen/LockScreenPanel.h 2016-04-07 11:57:30 +0000 | |||
229 | @@ -22,9 +22,9 @@ | |||
230 | 22 | 22 | ||
231 | 23 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
232 | 24 | #include <Nux/View.h> | 24 | #include <Nux/View.h> |
236 | 25 | #include <UnityCore/Indicators.h> | 25 | #include "UnityCore/Indicators.h" |
237 | 26 | #include <UnityCore/GLibSource.h> | 26 | #include "UnityCore/GLibSource.h" |
238 | 27 | #include <UnityCore/SessionManager.h> | 27 | #include "UnityCore/SessionManager.h" |
239 | 28 | 28 | ||
240 | 29 | namespace unity | 29 | namespace unity |
241 | 30 | { | 30 | { |
242 | 31 | 31 | ||
243 | === modified file 'lockscreen/LockScreenShieldFactory.h' | |||
244 | --- lockscreen/LockScreenShieldFactory.h 2014-12-08 21:56:36 +0000 | |||
245 | +++ lockscreen/LockScreenShieldFactory.h 2016-04-07 11:57:30 +0000 | |||
246 | @@ -22,6 +22,8 @@ | |||
247 | 22 | 22 | ||
248 | 23 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
249 | 24 | #include "LockScreenAbstractShield.h" | 24 | #include "LockScreenAbstractShield.h" |
250 | 25 | #include "UnityCore/SessionManager.h" | ||
251 | 26 | #include "UnityCore/Indicators.h" | ||
252 | 25 | 27 | ||
253 | 26 | namespace unity | 28 | namespace unity |
254 | 27 | { | 29 | { |
255 | 28 | 30 | ||
256 | === removed file 'lockscreen/ShutdownNotifier.cpp' | |||
257 | --- lockscreen/ShutdownNotifier.cpp 2014-12-16 19:27:36 +0000 | |||
258 | +++ lockscreen/ShutdownNotifier.cpp 1970-01-01 00:00:00 +0000 | |||
259 | @@ -1,152 +0,0 @@ | |||
260 | 1 | /* | ||
261 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
262 | 3 | * | ||
263 | 4 | * This program is free software: you can redistribute it and/or modify | ||
264 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
265 | 6 | * published by the Free Software Foundation. | ||
266 | 7 | * | ||
267 | 8 | * This program is distributed in the hope that it will be useful, | ||
268 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
269 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
270 | 11 | * GNU General Public License for more details. | ||
271 | 12 | * | ||
272 | 13 | * You should have received a copy of the GNU General Public License | ||
273 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
274 | 15 | * | ||
275 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
276 | 17 | */ | ||
277 | 18 | |||
278 | 19 | #include "ShutdownNotifier.h" | ||
279 | 20 | |||
280 | 21 | #include <NuxCore/Logger.h> | ||
281 | 22 | #include "UnityCore/GLibDBusProxy.h" | ||
282 | 23 | |||
283 | 24 | namespace unity | ||
284 | 25 | { | ||
285 | 26 | namespace lockscreen | ||
286 | 27 | { | ||
287 | 28 | |||
288 | 29 | DECLARE_LOGGER(logger, "unity.lockscreen.shutdownnotifier"); | ||
289 | 30 | |||
290 | 31 | // | ||
291 | 32 | // Private Implementation | ||
292 | 33 | // | ||
293 | 34 | |||
294 | 35 | class ShutdownNotifier::Impl | ||
295 | 36 | { | ||
296 | 37 | public: | ||
297 | 38 | Impl(); | ||
298 | 39 | ~Impl(); | ||
299 | 40 | |||
300 | 41 | bool RegisterInterest(ShutdownCallback const& cb); | ||
301 | 42 | void UnregisterInterest(); | ||
302 | 43 | |||
303 | 44 | void Inhibit(); | ||
304 | 45 | void Uninhibit(); | ||
305 | 46 | bool IsInhibited() const; | ||
306 | 47 | |||
307 | 48 | private: | ||
308 | 49 | std::shared_ptr<glib::DBusProxy> logind_proxy_; | ||
309 | 50 | ShutdownCallback cb_; | ||
310 | 51 | gint delay_inhibit_fd_; | ||
311 | 52 | }; | ||
312 | 53 | |||
313 | 54 | ShutdownNotifier::Impl::Impl() | ||
314 | 55 | : logind_proxy_(std::make_shared<glib::DBusProxy>("org.freedesktop.login1", | ||
315 | 56 | "/org/freedesktop/login1", | ||
316 | 57 | "org.freedesktop.login1.Manager", | ||
317 | 58 | G_BUS_TYPE_SYSTEM)) | ||
318 | 59 | , delay_inhibit_fd_(-1) | ||
319 | 60 | {} | ||
320 | 61 | |||
321 | 62 | ShutdownNotifier::Impl::~Impl() | ||
322 | 63 | { | ||
323 | 64 | UnregisterInterest(); | ||
324 | 65 | } | ||
325 | 66 | |||
326 | 67 | bool ShutdownNotifier::Impl::RegisterInterest(ShutdownCallback const& cb) | ||
327 | 68 | { | ||
328 | 69 | if (!cb or cb_) | ||
329 | 70 | return false; | ||
330 | 71 | |||
331 | 72 | cb_ = cb; | ||
332 | 73 | |||
333 | 74 | Inhibit(); | ||
334 | 75 | |||
335 | 76 | logind_proxy_->Connect("PrepareForShutdown", [this](GVariant* variant) { | ||
336 | 77 | bool active = glib::Variant(variant).GetBool(); | ||
337 | 78 | |||
338 | 79 | if (active) | ||
339 | 80 | { | ||
340 | 81 | cb_(); | ||
341 | 82 | UnregisterInterest(); | ||
342 | 83 | } | ||
343 | 84 | }); | ||
344 | 85 | |||
345 | 86 | return true; | ||
346 | 87 | } | ||
347 | 88 | |||
348 | 89 | void ShutdownNotifier::Impl::UnregisterInterest() | ||
349 | 90 | { | ||
350 | 91 | if (!cb_) | ||
351 | 92 | return; | ||
352 | 93 | |||
353 | 94 | Uninhibit(); | ||
354 | 95 | |||
355 | 96 | logind_proxy_->DisconnectSignal("PrepareForShutdown"); | ||
356 | 97 | cb_ = nullptr; | ||
357 | 98 | } | ||
358 | 99 | |||
359 | 100 | void ShutdownNotifier::Impl::Inhibit() | ||
360 | 101 | { | ||
361 | 102 | if (IsInhibited()) | ||
362 | 103 | return; | ||
363 | 104 | |||
364 | 105 | GVariant* args = g_variant_new("(ssss)", "shutdown", "Unity Lockscreen", "Screen is locked", "delay"); | ||
365 | 106 | |||
366 | 107 | logind_proxy_->CallWithUnixFdList("Inhibit", args, [this] (GVariant* variant, glib::Error const& e) { | ||
367 | 108 | if (e) | ||
368 | 109 | { | ||
369 | 110 | LOG_ERROR(logger) << "Failed to inhbit suspend"; | ||
370 | 111 | } | ||
371 | 112 | delay_inhibit_fd_ = glib::Variant(variant).GetInt32(); | ||
372 | 113 | }); | ||
373 | 114 | } | ||
374 | 115 | |||
375 | 116 | void ShutdownNotifier::Impl::Uninhibit() | ||
376 | 117 | { | ||
377 | 118 | if (!IsInhibited()) | ||
378 | 119 | return; | ||
379 | 120 | |||
380 | 121 | close(delay_inhibit_fd_); | ||
381 | 122 | delay_inhibit_fd_ = -1; | ||
382 | 123 | } | ||
383 | 124 | |||
384 | 125 | bool ShutdownNotifier::Impl::IsInhibited() const | ||
385 | 126 | { | ||
386 | 127 | return delay_inhibit_fd_ != -1; | ||
387 | 128 | } | ||
388 | 129 | |||
389 | 130 | // | ||
390 | 131 | // End Private Implementation | ||
391 | 132 | // | ||
392 | 133 | |||
393 | 134 | ShutdownNotifier::ShutdownNotifier() | ||
394 | 135 | : pimpl_(new(Impl)) | ||
395 | 136 | {} | ||
396 | 137 | |||
397 | 138 | ShutdownNotifier::~ShutdownNotifier() | ||
398 | 139 | {} | ||
399 | 140 | |||
400 | 141 | bool ShutdownNotifier::RegisterInterest(ShutdownCallback const& cb) | ||
401 | 142 | { | ||
402 | 143 | return pimpl_->RegisterInterest(cb); | ||
403 | 144 | } | ||
404 | 145 | |||
405 | 146 | void ShutdownNotifier::UnregisterInterest() | ||
406 | 147 | { | ||
407 | 148 | pimpl_->UnregisterInterest(); | ||
408 | 149 | } | ||
409 | 150 | |||
410 | 151 | } | ||
411 | 152 | } | ||
412 | 153 | 0 | ||
413 | === removed file 'lockscreen/ShutdownNotifier.h' | |||
414 | --- lockscreen/ShutdownNotifier.h 2014-12-16 19:27:36 +0000 | |||
415 | +++ lockscreen/ShutdownNotifier.h 1970-01-01 00:00:00 +0000 | |||
416 | @@ -1,51 +0,0 @@ | |||
417 | 1 | /* | ||
418 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
419 | 3 | * | ||
420 | 4 | * This program is free software: you can redistribute it and/or modify | ||
421 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
422 | 6 | * published by the Free Software Foundation. | ||
423 | 7 | * | ||
424 | 8 | * This program is distributed in the hope that it will be useful, | ||
425 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
426 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
427 | 11 | * GNU General Public License for more details. | ||
428 | 12 | * | ||
429 | 13 | * You should have received a copy of the GNU General Public License | ||
430 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
431 | 15 | * | ||
432 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
433 | 17 | */ | ||
434 | 18 | |||
435 | 19 | #ifndef UNITY_LOCKSCREEN_SHUTDOWN_NOTIFIER | ||
436 | 20 | #define UNITY_LOCKSCREEN_SHUTDOWN_NOTIFIER | ||
437 | 21 | |||
438 | 22 | #include <memory> | ||
439 | 23 | #include <functional> | ||
440 | 24 | |||
441 | 25 | namespace unity | ||
442 | 26 | { | ||
443 | 27 | namespace lockscreen | ||
444 | 28 | { | ||
445 | 29 | |||
446 | 30 | typedef std::function<void()> ShutdownCallback; | ||
447 | 31 | |||
448 | 32 | class ShutdownNotifier | ||
449 | 33 | { | ||
450 | 34 | public: | ||
451 | 35 | typedef std::shared_ptr<ShutdownNotifier> Ptr; | ||
452 | 36 | |||
453 | 37 | ShutdownNotifier(); | ||
454 | 38 | ~ShutdownNotifier(); | ||
455 | 39 | |||
456 | 40 | bool RegisterInterest(ShutdownCallback const&); | ||
457 | 41 | void UnregisterInterest(); | ||
458 | 42 | |||
459 | 43 | private: | ||
460 | 44 | class Impl; | ||
461 | 45 | std::unique_ptr<Impl> pimpl_; | ||
462 | 46 | }; | ||
463 | 47 | |||
464 | 48 | } | ||
465 | 49 | } | ||
466 | 50 | |||
467 | 51 | #endif | ||
468 | 52 | 0 | ||
469 | === added file 'lockscreen/SuspendInhibitorManager.cpp' | |||
470 | --- lockscreen/SuspendInhibitorManager.cpp 1970-01-01 00:00:00 +0000 | |||
471 | +++ lockscreen/SuspendInhibitorManager.cpp 2016-04-07 11:57:30 +0000 | |||
472 | @@ -0,0 +1,131 @@ | |||
473 | 1 | /* | ||
474 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
475 | 3 | * | ||
476 | 4 | * This program is free software: you can redistribute it and/or modify | ||
477 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
478 | 6 | * published by the Free Software Foundation. | ||
479 | 7 | * | ||
480 | 8 | * This program is distributed in the hope that it will be useful, | ||
481 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
482 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
483 | 11 | * GNU General Public License for more details. | ||
484 | 12 | * | ||
485 | 13 | * You should have received a copy of the GNU General Public License | ||
486 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
487 | 15 | * | ||
488 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
489 | 17 | */ | ||
490 | 18 | |||
491 | 19 | #include "SuspendInhibitorManager.h" | ||
492 | 20 | |||
493 | 21 | #include <NuxCore/Logger.h> | ||
494 | 22 | #include "UnityCore/GLibDBusProxy.h" | ||
495 | 23 | |||
496 | 24 | namespace unity | ||
497 | 25 | { | ||
498 | 26 | namespace lockscreen | ||
499 | 27 | { | ||
500 | 28 | |||
501 | 29 | DECLARE_LOGGER(logger, "unity.lockscreen.suspendinhibitormanager"); | ||
502 | 30 | |||
503 | 31 | // | ||
504 | 32 | // Private Implementation | ||
505 | 33 | // | ||
506 | 34 | |||
507 | 35 | class SuspendInhibitorManager::Impl | ||
508 | 36 | { | ||
509 | 37 | public: | ||
510 | 38 | Impl(SuspendInhibitorManager *parent); | ||
511 | 39 | ~Impl(); | ||
512 | 40 | |||
513 | 41 | void Inhibit(std::string const&); | ||
514 | 42 | void Uninhibit(); | ||
515 | 43 | bool IsInhibited(); | ||
516 | 44 | |||
517 | 45 | private: | ||
518 | 46 | SuspendInhibitorManager *parent_; | ||
519 | 47 | std::shared_ptr<glib::DBusProxy> lm_proxy_; | ||
520 | 48 | gint inhibitor_handler_; | ||
521 | 49 | }; | ||
522 | 50 | |||
523 | 51 | SuspendInhibitorManager::Impl::Impl(SuspendInhibitorManager *parent) | ||
524 | 52 | : parent_(parent) | ||
525 | 53 | , inhibitor_handler_(-1) | ||
526 | 54 | { | ||
527 | 55 | lm_proxy_ = std::make_shared<glib::DBusProxy>("org.freedesktop.login1", | ||
528 | 56 | "/org/freedesktop/login1", | ||
529 | 57 | "org.freedesktop.login1.Manager", | ||
530 | 58 | G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES); | ||
531 | 59 | |||
532 | 60 | lm_proxy_->Connect("PrepareForSleep", [this] (GVariant* variant) { | ||
533 | 61 | if (glib::Variant(variant).GetBool()) | ||
534 | 62 | parent_->about_to_suspend.emit(); | ||
535 | 63 | }); | ||
536 | 64 | |||
537 | 65 | lm_proxy_->connected.connect(sigc::mem_fun(&parent->connected, &decltype(parent->connected)::emit)); | ||
538 | 66 | } | ||
539 | 67 | |||
540 | 68 | SuspendInhibitorManager::Impl::~Impl() | ||
541 | 69 | {} | ||
542 | 70 | |||
543 | 71 | void SuspendInhibitorManager::Impl::Inhibit(std::string const& msg) | ||
544 | 72 | { | ||
545 | 73 | if (IsInhibited()) | ||
546 | 74 | return; | ||
547 | 75 | |||
548 | 76 | GVariant* args = g_variant_new("(ssss)", "sleep", "Unity", msg.c_str(), "delay"); | ||
549 | 77 | |||
550 | 78 | lm_proxy_->CallWithUnixFdList("Inhibit", args, [this] (GVariant* variant, glib::Error const& e) { | ||
551 | 79 | if (e) | ||
552 | 80 | { | ||
553 | 81 | LOG_WARNING(logger) << "Failed to inhbit suspend"; | ||
554 | 82 | return; | ||
555 | 83 | } | ||
556 | 84 | |||
557 | 85 | inhibitor_handler_ = glib::Variant(variant).GetInt32(); | ||
558 | 86 | }); | ||
559 | 87 | } | ||
560 | 88 | |||
561 | 89 | void SuspendInhibitorManager::Impl::Uninhibit() | ||
562 | 90 | { | ||
563 | 91 | if (IsInhibited()) | ||
564 | 92 | { | ||
565 | 93 | close(inhibitor_handler_); | ||
566 | 94 | inhibitor_handler_ = -1; | ||
567 | 95 | } | ||
568 | 96 | } | ||
569 | 97 | |||
570 | 98 | bool SuspendInhibitorManager::Impl::IsInhibited() | ||
571 | 99 | { | ||
572 | 100 | return inhibitor_handler_ >= 0; | ||
573 | 101 | } | ||
574 | 102 | |||
575 | 103 | // | ||
576 | 104 | // End Private Implementation | ||
577 | 105 | // | ||
578 | 106 | |||
579 | 107 | SuspendInhibitorManager::SuspendInhibitorManager() | ||
580 | 108 | : pimpl_(new Impl(this)) | ||
581 | 109 | {} | ||
582 | 110 | |||
583 | 111 | SuspendInhibitorManager::~SuspendInhibitorManager() | ||
584 | 112 | {} | ||
585 | 113 | |||
586 | 114 | void SuspendInhibitorManager::Inhibit(std::string const& msg) | ||
587 | 115 | { | ||
588 | 116 | pimpl_->Inhibit(msg); | ||
589 | 117 | } | ||
590 | 118 | |||
591 | 119 | void SuspendInhibitorManager::Uninhibit() | ||
592 | 120 | { | ||
593 | 121 | pimpl_->Uninhibit(); | ||
594 | 122 | } | ||
595 | 123 | |||
596 | 124 | bool SuspendInhibitorManager::IsInhibited() | ||
597 | 125 | { | ||
598 | 126 | return pimpl_->IsInhibited(); | ||
599 | 127 | } | ||
600 | 128 | |||
601 | 129 | |||
602 | 130 | } | ||
603 | 131 | } | ||
604 | 0 | 132 | ||
605 | === added file 'lockscreen/SuspendInhibitorManager.h' | |||
606 | --- lockscreen/SuspendInhibitorManager.h 1970-01-01 00:00:00 +0000 | |||
607 | +++ lockscreen/SuspendInhibitorManager.h 2016-04-07 11:57:30 +0000 | |||
608 | @@ -0,0 +1,54 @@ | |||
609 | 1 | /* | ||
610 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
611 | 3 | * | ||
612 | 4 | * This program is free software: you can redistribute it and/or modify | ||
613 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
614 | 6 | * published by the Free Software Foundation. | ||
615 | 7 | * | ||
616 | 8 | * This program is distributed in the hope that it will be useful, | ||
617 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
618 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
619 | 11 | * GNU General Public License for more details. | ||
620 | 12 | * | ||
621 | 13 | * You should have received a copy of the GNU General Public License | ||
622 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
623 | 15 | * | ||
624 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
625 | 17 | */ | ||
626 | 18 | |||
627 | 19 | #ifndef UNITY_LOCKSCREEN_SUSPEND_INHIBITOR_MANAGER | ||
628 | 20 | #define UNITY_LOCKSCREEN_SUSPEND_INHIBITOR_MANAGER | ||
629 | 21 | |||
630 | 22 | #include <memory> | ||
631 | 23 | #include <string> | ||
632 | 24 | #include <sigc++/signal.h> | ||
633 | 25 | |||
634 | 26 | namespace unity | ||
635 | 27 | { | ||
636 | 28 | namespace lockscreen | ||
637 | 29 | { | ||
638 | 30 | |||
639 | 31 | class SuspendInhibitorManager | ||
640 | 32 | { | ||
641 | 33 | public: | ||
642 | 34 | typedef std::shared_ptr<SuspendInhibitorManager> Ptr; | ||
643 | 35 | |||
644 | 36 | SuspendInhibitorManager(); | ||
645 | 37 | ~SuspendInhibitorManager(); | ||
646 | 38 | |||
647 | 39 | void Inhibit(std::string const&); | ||
648 | 40 | void Uninhibit(); | ||
649 | 41 | bool IsInhibited(); | ||
650 | 42 | |||
651 | 43 | sigc::signal<void> connected; | ||
652 | 44 | sigc::signal<void> about_to_suspend; | ||
653 | 45 | |||
654 | 46 | private: | ||
655 | 47 | class Impl; | ||
656 | 48 | std::unique_ptr<Impl> pimpl_; | ||
657 | 49 | }; | ||
658 | 50 | |||
659 | 51 | } | ||
660 | 52 | } | ||
661 | 53 | |||
662 | 54 | #endif | ||
663 | 0 | 55 | ||
664 | === removed file 'lockscreen/SuspendNotifier.cpp' | |||
665 | --- lockscreen/SuspendNotifier.cpp 2014-12-16 19:27:36 +0000 | |||
666 | +++ lockscreen/SuspendNotifier.cpp 1970-01-01 00:00:00 +0000 | |||
667 | @@ -1,153 +0,0 @@ | |||
668 | 1 | /* | ||
669 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
670 | 3 | * | ||
671 | 4 | * This program is free software: you can redistribute it and/or modify | ||
672 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
673 | 6 | * published by the Free Software Foundation. | ||
674 | 7 | * | ||
675 | 8 | * This program is distributed in the hope that it will be useful, | ||
676 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
677 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
678 | 11 | * GNU General Public License for more details. | ||
679 | 12 | * | ||
680 | 13 | * You should have received a copy of the GNU General Public License | ||
681 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
682 | 15 | * | ||
683 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
684 | 17 | */ | ||
685 | 18 | |||
686 | 19 | #include "SuspendNotifier.h" | ||
687 | 20 | |||
688 | 21 | #include <NuxCore/Logger.h> | ||
689 | 22 | #include "UnityCore/GLibDBusProxy.h" | ||
690 | 23 | |||
691 | 24 | namespace unity | ||
692 | 25 | { | ||
693 | 26 | namespace lockscreen | ||
694 | 27 | { | ||
695 | 28 | |||
696 | 29 | DECLARE_LOGGER(logger, "unity.lockscreen.suspendnotifier"); | ||
697 | 30 | |||
698 | 31 | // | ||
699 | 32 | // Private Implementation | ||
700 | 33 | // | ||
701 | 34 | |||
702 | 35 | class SuspendNotifier::Impl | ||
703 | 36 | { | ||
704 | 37 | public: | ||
705 | 38 | Impl(); | ||
706 | 39 | ~Impl(); | ||
707 | 40 | |||
708 | 41 | bool RegisterInterest(SuspendCallback const& cb); | ||
709 | 42 | void UnregisterInterest(); | ||
710 | 43 | |||
711 | 44 | void Inhibit(); | ||
712 | 45 | void Uninhibit(); | ||
713 | 46 | bool IsInhibited() const; | ||
714 | 47 | |||
715 | 48 | private: | ||
716 | 49 | std::shared_ptr<glib::DBusProxy> logind_proxy_; | ||
717 | 50 | SuspendCallback cb_; | ||
718 | 51 | gint delay_inhibit_fd_; | ||
719 | 52 | }; | ||
720 | 53 | |||
721 | 54 | SuspendNotifier::Impl::Impl() | ||
722 | 55 | : logind_proxy_(std::make_shared<glib::DBusProxy>("org.freedesktop.login1", | ||
723 | 56 | "/org/freedesktop/login1", | ||
724 | 57 | "org.freedesktop.login1.Manager", | ||
725 | 58 | G_BUS_TYPE_SYSTEM)) | ||
726 | 59 | , delay_inhibit_fd_(-1) | ||
727 | 60 | {} | ||
728 | 61 | |||
729 | 62 | SuspendNotifier::Impl::~Impl() | ||
730 | 63 | { | ||
731 | 64 | UnregisterInterest(); | ||
732 | 65 | } | ||
733 | 66 | |||
734 | 67 | bool SuspendNotifier::Impl::RegisterInterest(SuspendCallback const& cb) | ||
735 | 68 | { | ||
736 | 69 | if (!cb or cb_) | ||
737 | 70 | return false; | ||
738 | 71 | |||
739 | 72 | cb_ = cb; | ||
740 | 73 | |||
741 | 74 | Inhibit(); | ||
742 | 75 | |||
743 | 76 | logind_proxy_->Connect("PrepareForSleep", [this](GVariant* variant) { | ||
744 | 77 | bool active = glib::Variant(variant).GetBool(); | ||
745 | 78 | |||
746 | 79 | if (active) // suspending | ||
747 | 80 | { | ||
748 | 81 | cb_(); | ||
749 | 82 | Uninhibit(); | ||
750 | 83 | } | ||
751 | 84 | else // resuming | ||
752 | 85 | { | ||
753 | 86 | Inhibit(); | ||
754 | 87 | } | ||
755 | 88 | }); | ||
756 | 89 | |||
757 | 90 | return true; | ||
758 | 91 | } | ||
759 | 92 | |||
760 | 93 | void SuspendNotifier::Impl::UnregisterInterest() | ||
761 | 94 | { | ||
762 | 95 | Uninhibit(); | ||
763 | 96 | |||
764 | 97 | logind_proxy_->DisconnectSignal("PrepareForSleep"); | ||
765 | 98 | cb_ = nullptr; | ||
766 | 99 | } | ||
767 | 100 | |||
768 | 101 | void SuspendNotifier::Impl::Inhibit() | ||
769 | 102 | { | ||
770 | 103 | if (IsInhibited()) | ||
771 | 104 | return; | ||
772 | 105 | |||
773 | 106 | GVariant* args = g_variant_new("(ssss)", "sleep", "Unity Lockscreen", "Unity wants to lock screen before suspending.", "delay"); | ||
774 | 107 | |||
775 | 108 | logind_proxy_->CallWithUnixFdList("Inhibit", args, [this] (GVariant* variant, glib::Error const& e) { | ||
776 | 109 | if (e) | ||
777 | 110 | { | ||
778 | 111 | LOG_ERROR(logger) << "Failed to inhbit suspend"; | ||
779 | 112 | } | ||
780 | 113 | delay_inhibit_fd_ = glib::Variant(variant).GetInt32(); | ||
781 | 114 | }); | ||
782 | 115 | } | ||
783 | 116 | |||
784 | 117 | void SuspendNotifier::Impl::Uninhibit() | ||
785 | 118 | { | ||
786 | 119 | if (!IsInhibited()) | ||
787 | 120 | return; | ||
788 | 121 | |||
789 | 122 | close(delay_inhibit_fd_); | ||
790 | 123 | delay_inhibit_fd_ = -1; | ||
791 | 124 | } | ||
792 | 125 | |||
793 | 126 | bool SuspendNotifier::Impl::IsInhibited() const | ||
794 | 127 | { | ||
795 | 128 | return delay_inhibit_fd_ != -1; | ||
796 | 129 | } | ||
797 | 130 | |||
798 | 131 | // | ||
799 | 132 | // End Private Implementation | ||
800 | 133 | // | ||
801 | 134 | |||
802 | 135 | SuspendNotifier::SuspendNotifier() | ||
803 | 136 | : pimpl_(new(Impl)) | ||
804 | 137 | {} | ||
805 | 138 | |||
806 | 139 | SuspendNotifier::~SuspendNotifier() | ||
807 | 140 | {} | ||
808 | 141 | |||
809 | 142 | bool SuspendNotifier::RegisterInterest(SuspendCallback const& cb) | ||
810 | 143 | { | ||
811 | 144 | return pimpl_->RegisterInterest(cb); | ||
812 | 145 | } | ||
813 | 146 | |||
814 | 147 | void SuspendNotifier::UnregisterInterest() | ||
815 | 148 | { | ||
816 | 149 | pimpl_->UnregisterInterest(); | ||
817 | 150 | } | ||
818 | 151 | |||
819 | 152 | } | ||
820 | 153 | } | ||
821 | 154 | 0 | ||
822 | === removed file 'lockscreen/SuspendNotifier.h' | |||
823 | --- lockscreen/SuspendNotifier.h 2014-12-16 19:27:36 +0000 | |||
824 | +++ lockscreen/SuspendNotifier.h 1970-01-01 00:00:00 +0000 | |||
825 | @@ -1,51 +0,0 @@ | |||
826 | 1 | /* | ||
827 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
828 | 3 | * | ||
829 | 4 | * This program is free software: you can redistribute it and/or modify | ||
830 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
831 | 6 | * published by the Free Software Foundation. | ||
832 | 7 | * | ||
833 | 8 | * This program is distributed in the hope that it will be useful, | ||
834 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
835 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
836 | 11 | * GNU General Public License for more details. | ||
837 | 12 | * | ||
838 | 13 | * You should have received a copy of the GNU General Public License | ||
839 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
840 | 15 | * | ||
841 | 16 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
842 | 17 | */ | ||
843 | 18 | |||
844 | 19 | #ifndef UNITY_LOCKSCREEN_SUSPEND_NOTIFIER | ||
845 | 20 | #define UNITY_LOCKSCREEN_SHUTDOWN_NOTIFIER | ||
846 | 21 | |||
847 | 22 | #include <memory> | ||
848 | 23 | #include <functional> | ||
849 | 24 | |||
850 | 25 | namespace unity | ||
851 | 26 | { | ||
852 | 27 | namespace lockscreen | ||
853 | 28 | { | ||
854 | 29 | |||
855 | 30 | typedef std::function<void()> SuspendCallback; | ||
856 | 31 | |||
857 | 32 | class SuspendNotifier | ||
858 | 33 | { | ||
859 | 34 | public: | ||
860 | 35 | typedef std::shared_ptr<SuspendNotifier> Ptr; | ||
861 | 36 | |||
862 | 37 | SuspendNotifier(); | ||
863 | 38 | ~SuspendNotifier(); | ||
864 | 39 | |||
865 | 40 | bool RegisterInterest(SuspendCallback const&); | ||
866 | 41 | void UnregisterInterest(); | ||
867 | 42 | |||
868 | 43 | private: | ||
869 | 44 | class Impl; | ||
870 | 45 | std::unique_ptr<Impl> pimpl_; | ||
871 | 46 | }; | ||
872 | 47 | |||
873 | 48 | } | ||
874 | 49 | } | ||
875 | 50 | |||
876 | 51 | #endif | ||
877 | 52 | \ No newline at end of file | 0 | \ No newline at end of file |
878 | 53 | 1 | ||
879 | === modified file 'lockscreen/UserPromptView.h' | |||
880 | --- lockscreen/UserPromptView.h 2014-12-08 22:02:13 +0000 | |||
881 | +++ lockscreen/UserPromptView.h 2016-04-07 11:57:30 +0000 | |||
882 | @@ -25,7 +25,7 @@ | |||
883 | 25 | 25 | ||
884 | 26 | #include <Nux/Nux.h> | 26 | #include <Nux/Nux.h> |
885 | 27 | #include <Nux/View.h> | 27 | #include <Nux/View.h> |
887 | 28 | #include <UnityCore/SessionManager.h> | 28 | #include "UnityCore/SessionManager.h" |
888 | 29 | 29 | ||
889 | 30 | #include "UserAuthenticatorPam.h" | 30 | #include "UserAuthenticatorPam.h" |
890 | 31 | #include "unity-shared/IMTextEntry.h" | 31 | #include "unity-shared/IMTextEntry.h" |
891 | 32 | 32 | ||
892 | === modified file 'lockscreen/pch/lockscreen_pch.hh' | |||
893 | --- lockscreen/pch/lockscreen_pch.hh 2014-03-07 18:35:10 +0000 | |||
894 | +++ lockscreen/pch/lockscreen_pch.hh 2016-04-07 11:57:30 +0000 | |||
895 | @@ -28,5 +28,5 @@ | |||
896 | 28 | #include <security/pam_appl.h> | 28 | #include <security/pam_appl.h> |
897 | 29 | 29 | ||
898 | 30 | #include <Nux/Nux.h> | 30 | #include <Nux/Nux.h> |
899 | 31 | #include <UnityCore/SessionManager.h> | ||
900 | 32 | #include <UnityCore/Indicators.h> | ||
901 | 33 | \ No newline at end of file | 31 | \ No newline at end of file |
902 | 32 | #include "UnityCore/SessionManager.h" | ||
903 | 33 | #include "UnityCore/Indicators.h" | ||
904 | 34 | \ No newline at end of file | 34 | \ No newline at end of file |
905 | 35 | 35 | ||
906 | === modified file 'shutdown/SessionController.h' | |||
907 | --- shutdown/SessionController.h 2014-02-17 04:05:06 +0000 | |||
908 | +++ shutdown/SessionController.h 2016-04-07 11:57:30 +0000 | |||
909 | @@ -26,7 +26,7 @@ | |||
910 | 26 | #include <Nux/BaseWindow.h> | 26 | #include <Nux/BaseWindow.h> |
911 | 27 | #include <Nux/HLayout.h> | 27 | #include <Nux/HLayout.h> |
912 | 28 | #include <NuxCore/Animation.h> | 28 | #include <NuxCore/Animation.h> |
914 | 29 | #include <UnityCore/SessionManager.h> | 29 | #include "UnityCore/SessionManager.h" |
915 | 30 | 30 | ||
916 | 31 | #include "SessionView.h" | 31 | #include "SessionView.h" |
917 | 32 | 32 | ||
918 | 33 | 33 | ||
919 | === modified file 'shutdown/SessionDBusManager.h' | |||
920 | --- shutdown/SessionDBusManager.h 2014-03-07 03:26:23 +0000 | |||
921 | +++ shutdown/SessionDBusManager.h 2016-04-07 11:57:30 +0000 | |||
922 | @@ -20,9 +20,9 @@ | |||
923 | 20 | #ifndef UNITYSHELL_SESSION_DBUS_MANAGER_H | 20 | #ifndef UNITYSHELL_SESSION_DBUS_MANAGER_H |
924 | 21 | #define UNITYSHELL_SESSION_DBUS_MANAGER_H | 21 | #define UNITYSHELL_SESSION_DBUS_MANAGER_H |
925 | 22 | 22 | ||
929 | 23 | #include <UnityCore/ConnectionManager.h> | 23 | #include "UnityCore/ConnectionManager.h" |
930 | 24 | #include <UnityCore/GLibDBusServer.h> | 24 | #include "UnityCore/GLibDBusServer.h" |
931 | 25 | #include <UnityCore/SessionManager.h> | 25 | #include "UnityCore/SessionManager.h" |
932 | 26 | 26 | ||
933 | 27 | namespace unity | 27 | namespace unity |
934 | 28 | { | 28 | { |
935 | 29 | 29 | ||
936 | === modified file 'shutdown/SessionView.h' | |||
937 | --- shutdown/SessionView.h 2014-07-23 18:56:11 +0000 | |||
938 | +++ shutdown/SessionView.h 2016-04-07 11:57:30 +0000 | |||
939 | @@ -26,7 +26,7 @@ | |||
940 | 26 | #include <Nux/HLayout.h> | 26 | #include <Nux/HLayout.h> |
941 | 27 | 27 | ||
942 | 28 | #include <UnityCore/GLibSource.h> | 28 | #include <UnityCore/GLibSource.h> |
944 | 29 | #include <UnityCore/SessionManager.h> | 29 | #include "UnityCore/SessionManager.h" |
945 | 30 | #include "unity-shared/EMConverter.h" | 30 | #include "unity-shared/EMConverter.h" |
946 | 31 | #include "unity-shared/UnityWindowView.h" | 31 | #include "unity-shared/UnityWindowView.h" |
947 | 32 | 32 | ||
948 | 33 | 33 | ||
949 | === modified file 'tests/test_mock_session_manager.h' | |||
950 | --- tests/test_mock_session_manager.h 2014-07-23 18:56:11 +0000 | |||
951 | +++ tests/test_mock_session_manager.h 2016-04-07 11:57:30 +0000 | |||
952 | @@ -18,7 +18,7 @@ | |||
953 | 18 | */ | 18 | */ |
954 | 19 | 19 | ||
955 | 20 | #include <gmock/gmock.h> | 20 | #include <gmock/gmock.h> |
957 | 21 | #include <UnityCore/SessionManager.h> | 21 | #include "UnityCore/SessionManager.h" |
958 | 22 | 22 | ||
959 | 23 | namespace unity | 23 | namespace unity |
960 | 24 | { | 24 | { |
961 | 25 | 25 | ||
962 | === modified file 'unity-shared/PluginAdapter.cpp' | |||
963 | --- unity-shared/PluginAdapter.cpp 2015-10-15 16:13:20 +0000 | |||
964 | +++ unity-shared/PluginAdapter.cpp 2016-04-07 11:57:30 +0000 | |||
965 | @@ -1459,26 +1459,6 @@ | |||
966 | 1459 | _last_focused_window = NULL; | 1459 | _last_focused_window = NULL; |
967 | 1460 | } | 1460 | } |
968 | 1461 | 1461 | ||
969 | 1462 | void PluginAdapter::UnmapAllNoNuxWindowsSync() | ||
970 | 1463 | { | ||
971 | 1464 | for (auto const& window : m_Screen->windows()) | ||
972 | 1465 | { | ||
973 | 1466 | if (!IsNuxWindow(window) && (window->isMapped() || window->isViewable())) | ||
974 | 1467 | { | ||
975 | 1468 | if (window->overrideRedirect()) | ||
976 | 1469 | { | ||
977 | 1470 | XUnmapWindow(m_Screen->dpy(), window->id()); | ||
978 | 1471 | } | ||
979 | 1472 | else | ||
980 | 1473 | { | ||
981 | 1474 | window->hide(); | ||
982 | 1475 | } | ||
983 | 1476 | } | ||
984 | 1477 | } | ||
985 | 1478 | |||
986 | 1479 | XSync(m_Screen->dpy(), False); | ||
987 | 1480 | } | ||
988 | 1481 | |||
989 | 1482 | bool PluginAdapter::IsNuxWindow(CompWindow* value) | 1462 | bool PluginAdapter::IsNuxWindow(CompWindow* value) |
990 | 1483 | { | 1463 | { |
991 | 1484 | std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); | 1464 | std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); |
992 | 1485 | 1465 | ||
993 | === modified file 'unity-shared/PluginAdapter.h' | |||
994 | --- unity-shared/PluginAdapter.h 2014-12-16 19:27:36 +0000 | |||
995 | +++ unity-shared/PluginAdapter.h 2016-04-07 11:57:30 +0000 | |||
996 | @@ -193,7 +193,6 @@ | |||
997 | 193 | 193 | ||
998 | 194 | Window GetTopWindowAbove(Window xid) const; | 194 | Window GetTopWindowAbove(Window xid) const; |
999 | 195 | 195 | ||
1000 | 196 | void UnmapAllNoNuxWindowsSync(); | ||
1001 | 197 | static bool IsNuxWindow(CompWindow* value); | 196 | static bool IsNuxWindow(CompWindow* value); |
1002 | 198 | 197 | ||
1003 | 199 | protected: | 198 | protected: |
1004 | 200 | 199 | ||
1005 | === modified file 'unity-shared/StandaloneWindowManager.h' | |||
1006 | --- unity-shared/StandaloneWindowManager.h 2015-05-15 14:12:01 +0000 | |||
1007 | +++ unity-shared/StandaloneWindowManager.h 2016-04-07 11:57:30 +0000 | |||
1008 | @@ -164,8 +164,6 @@ | |||
1009 | 164 | virtual std::string GetStringProperty(Window window_id, Atom) const; | 164 | virtual std::string GetStringProperty(Window window_id, Atom) const; |
1010 | 165 | virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const; | 165 | virtual std::vector<long> GetCardinalProperty(Window window_id, Atom) const; |
1011 | 166 | 166 | ||
1012 | 167 | virtual void UnmapAllNoNuxWindowsSync() {}; | ||
1013 | 168 | |||
1014 | 169 | // Mock functions | 167 | // Mock functions |
1015 | 170 | StandaloneWindow::Ptr GetWindowByXid(Window window_id) const; | 168 | StandaloneWindow::Ptr GetWindowByXid(Window window_id) const; |
1016 | 171 | void AddStandaloneWindow(StandaloneWindow::Ptr const& window); | 169 | void AddStandaloneWindow(StandaloneWindow::Ptr const& window); |
1017 | 172 | 170 | ||
1018 | === modified file 'unity-shared/WindowManager.h' | |||
1019 | --- unity-shared/WindowManager.h 2015-05-15 14:12:01 +0000 | |||
1020 | +++ unity-shared/WindowManager.h 2016-04-07 11:57:30 +0000 | |||
1021 | @@ -170,9 +170,6 @@ | |||
1022 | 170 | virtual std::string GetStringProperty(Window, Atom) const = 0; | 170 | virtual std::string GetStringProperty(Window, Atom) const = 0; |
1023 | 171 | virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0; | 171 | virtual std::vector<long> GetCardinalProperty(Window, Atom) const = 0; |
1024 | 172 | 172 | ||
1025 | 173 | virtual void UnmapAllNoNuxWindowsSync() = 0; | ||
1026 | 174 | |||
1027 | 175 | |||
1028 | 176 | // Nux Modifiers, Nux Keycode (= X11 KeySym) | 173 | // Nux Modifiers, Nux Keycode (= X11 KeySym) |
1029 | 177 | nux::Property<std::pair<unsigned, unsigned>> close_window_key; | 174 | nux::Property<std::pair<unsigned, unsigned>> close_window_key; |
1030 | 178 | nux::Property<std::pair<unsigned, unsigned>> activate_indicators_key; | 175 | nux::Property<std::pair<unsigned, unsigned>> activate_indicators_key; |