Merge lp:~3v1n0/unity/screensaver-monitors-vt-changes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
Merged at revision: 3974
Proposed branch: lp:~3v1n0/unity/screensaver-monitors-vt-changes
Merge into: lp:unity
Diff against target: 75 lines (+22/-4)
2 files modified
UnityCore/GLibDBusProxy.cpp (+16/-3)
UnityCore/GnomeSessionManager.cpp (+6/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/screensaver-monitors-vt-changes
Reviewer Review Type Date Requested Status
Christopher Townsend (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+259534@code.launchpad.net

Commit message

GnomeSessionManager: Request ScreenSaver (de)activation on VT changes

Connect to login1 session active property, and monitor its state.
When the session is active we can safely request the screensaver to stop.

Description of the change

Test case:

sudo true && gdbus call --session --dest org.gnome.ScreenSaver --object-path /com/canonical/Unity/Session --method com.canonical.Unity.Session.ActivateScreenSaver && sleep 1 && sudo chvt 1 && sleep 1 && sudo chvt 7

Launching the script above in current unity, would cause it to switch VT and come back, but the screen will be blank. This change ensures the screen is turned on again.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Yep, issue is fixed and code looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/GLibDBusProxy.cpp'
2--- UnityCore/GLibDBusProxy.cpp 2014-10-22 15:26:56 +0000
3+++ UnityCore/GLibDBusProxy.cpp 2015-05-19 18:41:50 +0000
4@@ -89,7 +89,7 @@
5
6 void OnProxyNameOwnerChanged(GDBusProxy*, GParamSpec*);
7 void OnProxySignal(GDBusProxy* proxy, const char*, const char*, GVariant*);
8- void OnPropertyChanged(GDBusProxy*, GVariant*, GStrv*);
9+ void OnPropertyChanged(GDBusProxy*, GVariant*, GStrv);
10
11 static void OnProxyConnectCallback(GObject* source, GAsyncResult* res, gpointer impl);
12 static void OnCallCallback(GObject* source, GAsyncResult* res, gpointer call_data);
13@@ -114,7 +114,7 @@
14 unsigned reconnection_attempts_;
15
16 glib::Signal<void, GDBusProxy*, const char*, const char*, GVariant*> g_signal_connection_;
17- glib::Signal<void, GDBusProxy*, GVariant*, GStrv*> g_property_signal_;
18+ glib::Signal<void, GDBusProxy*, GVariant*, GStrv> g_property_signal_;
19 glib::Signal<void, GDBusProxy*, GParamSpec*> name_owner_signal_;
20 glib::Source::UniquePtr reconnect_timeout_;
21 sigc::signal<void> proxy_acquired;
22@@ -277,7 +277,7 @@
23 }
24 }
25
26-void DBusProxy::Impl::OnPropertyChanged(GDBusProxy* proxy, GVariant* changed_props, GStrv* invalidated)
27+void DBusProxy::Impl::OnPropertyChanged(GDBusProxy* proxy, GVariant* changed_props, GStrv invalidated)
28 {
29 LOG_DEBUG(logger) << "Properties changed for proxy (" << object_path_ << ")";
30
31@@ -303,6 +303,19 @@
32
33 g_variant_iter_free (iter);
34 }
35+
36+ for (const gchar *property_name = *invalidated; property_name; property_name = *(++invalidated))
37+ {
38+ LOG_DEBUG(logger) << "Property: '" << property_name << "' invalidated";
39+
40+ auto handler_it = property_handlers_.find(property_name);
41+
42+ if (handler_it != property_handlers_.end())
43+ {
44+ for (ReplyCallback const& callback : handler_it->second)
45+ callback(nullptr);
46+ }
47+ }
48 }
49
50 void DBusProxy::Impl::WaitForProxy(GCancellable* cancellable,
51
52=== modified file 'UnityCore/GnomeSessionManager.cpp'
53--- UnityCore/GnomeSessionManager.cpp 2015-01-24 00:56:37 +0000
54+++ UnityCore/GnomeSessionManager.cpp 2015-05-19 18:41:50 +0000
55@@ -104,7 +104,8 @@
56 login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1",
57 "/org/freedesktop/login1/session/" + glib::gchar_to_string(session_id),
58 "org.freedesktop.login1.Session",
59- test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM);
60+ test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM,
61+ G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES);
62
63 login_proxy_->Connect("Lock", [this](GVariant*){
64 manager_->PromptLockScreen();
65@@ -113,6 +114,10 @@
66 login_proxy_->Connect("Unlock", [this](GVariant*){
67 manager_->unlock_requested.emit();
68 });
69+
70+ login_proxy_->ConnectProperty("Active", [this] (GVariant* active) {
71+ manager_->screensaver_requested.emit(!glib::Variant(active).GetBool());
72+ });
73 }
74
75 {