Merge lp:~azzar1/unity/sh-72 into lp:unity/7.2

Proposed by Andrea Azzarone
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
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.

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

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: