Merge lp:~robert-ancell/unity-greeter/screensaver into lp:unity-greeter

Proposed by Robert Ancell
Status: Merged
Merged at revision: 1198
Proposed branch: lp:~robert-ancell/unity-greeter/screensaver
Merge into: lp:unity-greeter
Diff against target: 282 lines (+155/-18)
8 files modified
configure.ac (+1/-0)
data/com.canonical.unity-greeter.gschema.xml (+4/-0)
debian/control (+1/-0)
src/Makefile.am (+1/-0)
src/fixes.vapi (+16/-0)
src/settings-daemon.vala (+124/-17)
src/settings.vala (+7/-0)
src/unity-greeter.vala (+1/-1)
To merge this branch: bzr merge lp:~robert-ancell/unity-greeter/screensaver
Reviewer Review Type Date Requested Status
Michael Terry (community) Approve
Sebastien Bacher Approve
PS Jenkins bot (community) continuous-integration Approve
Unity Greeter Development Team Pending
Review via email: mp+214470@code.launchpad.net

Commit message

Allow unity-settings-daemon to blank the screen by implementing the gnome-screensaver and gnome-session d-bus interfaces.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I also think this merge might fix another suspected bug when gnome-screensaver sometimes runs in the greeter. We now make sure we have claimed the screensaver d-bus name before launching u-s-d.

1200. By Robert Ancell

Allow timeout to be disabled

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

The changes here look fine to me, runtime seems to work as advertized as well (I didn't try changing the value but the screen does turn off after the default timeout after installing the update)

review: Approve
Revision history for this message
Michael Terry (mterry) wrote :

Sure, seems fine. Do you have other changes planned, or should this be released by itself?

review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

> Sure, seems fine. Do you have other changes planned, or should this be
> released by itself?

No other changes planned, I will release this now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2014-04-01 21:21:43 +0000
3+++ configure.ac 2014-04-07 03:59:04 +0000
4@@ -23,6 +23,7 @@
5 indicator3-0.4
6 libido3-0.1 >= 13.10.0
7 liblightdm-gobject-1 >= 1.4.0
8+ gnome-desktop-3.0
9 freetype2
10 cairo-ft
11 libcanberra
12
13=== modified file 'data/com.canonical.unity-greeter.gschema.xml'
14--- data/com.canonical.unity-greeter.gschema.xml 2014-03-26 04:31:27 +0000
15+++ data/com.canonical.unity-greeter.gschema.xml 2014-04-07 03:59:04 +0000
16@@ -94,5 +94,9 @@
17 <default>[]</default>
18 <summary>List of usernames that are hidden until a special key combination is hit</summary>
19 </key>
20+ <key name="idle-timeout" type="i">
21+ <default>300</default>
22+ <summary>Number of seconds of inactivity before blanking the screen. Set to 0 to never timeout.</summary>
23+ </key>
24 </schema>
25 </schemalist>
26
27=== modified file 'debian/control'
28--- debian/control 2014-02-20 10:39:35 +0000
29+++ debian/control 2014-04-07 03:59:04 +0000
30@@ -12,6 +12,7 @@
31 ttf-ubuntu-font-family,
32 unity-settings-daemon-dev,
33 libcanberra-dev,
34+ libgnome-desktop-3-dev,
35 libgtk-3-dev,
36 libindicator3-dev,
37 libido3-0.1-dev (>= 13.10.0),
38
39=== modified file 'src/Makefile.am'
40--- src/Makefile.am 2014-02-18 17:57:29 +0000
41+++ src/Makefile.am 2014-04-07 03:59:04 +0000
42@@ -40,6 +40,7 @@
43 unity_greeter_CFLAGS = \
44 $(UNITY_GREETER_CFLAGS) \
45 -w \
46+ -DGNOME_DESKTOP_USE_UNSTABLE_API \
47 -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
48 -DLOCALEDIR=\""$(localedir)"\" \
49 -DVERSION=\"$(VERSION)\" \
50
51=== modified file 'src/fixes.vapi'
52--- src/fixes.vapi 2014-03-26 21:22:15 +0000
53+++ src/fixes.vapi 2014-04-07 03:59:04 +0000
54@@ -33,3 +33,19 @@
55 public void to_hsv (double r, double g, double b, out double h, out double s, out double v);
56 }
57 }
58+
59+namespace Gnome
60+{
61+ [CCode (cheader_filename = "libgnome-desktop/gnome-idle-monitor.h")]
62+ public class IdleMonitor : GLib.Object
63+ {
64+ public IdleMonitor ();
65+ public IdleMonitor.for_device (Gdk.Device device);
66+ public uint add_idle_watch (uint64 interval_msec, IdleMonitorWatchFunc callback, GLib.DestroyNotify? notify = null);
67+ public uint add_user_active_watch (IdleMonitorWatchFunc callback, GLib.DestroyNotify? notify = null);
68+ public void remove_watch (uint id);
69+ public int64 get_idletime ();
70+ }
71+
72+ public delegate void IdleMonitorWatchFunc (IdleMonitor monitor, uint id);
73+}
74
75=== modified file 'src/settings-daemon.vala'
76--- src/settings-daemon.vala 2014-02-07 12:39:53 +0000
77+++ src/settings-daemon.vala 2014-04-07 03:59:04 +0000
78@@ -20,14 +20,11 @@
79 public class SettingsDaemon : Object
80 {
81 private int logind_inhibit_fd = -1;
82-
83- public async void start ()
84- {
85- configure ();
86- yield run ();
87- }
88-
89- private void configure ()
90+ private ScreenSaverInterface screen_saver;
91+ private SessionManagerInterface session_manager;
92+ private int n_names = 0;
93+
94+ public void start ()
95 {
96 string[] disabled = { "org.gnome.settings-daemon.plugins.background",
97 "org.gnome.settings-daemon.plugins.clipboard",
98@@ -58,14 +55,54 @@
99 foreach (var schema in enabled)
100 set_plugin_enabled (schema, true);
101
102- /* We want to block the screensaver from being activated by g-s-d or
103- any of the indicators. So we own the name, preventing dbus
104- activation by anyone else.
105- If the screensaver were allowed to start, it would disable X's
106- builtin blanking logic which we do use and instead, blanking would
107- require gnome-session and it's Presence DBus interface to be run. */
108- GLib.Bus.own_name (GLib.BusType.SESSION, "org.gnome.ScreenSaver",
109- GLib.BusNameOwnerFlags.NONE);
110+ /* Pretend to be GNOME session */
111+ session_manager = new SessionManagerInterface ();
112+ n_names++;
113+ GLib.Bus.own_name (BusType.SESSION, "org.gnome.SessionManager", BusNameOwnerFlags.NONE,
114+ (c) =>
115+ {
116+ try
117+ {
118+ c.register_object ("/org/gnome/SessionManager", session_manager);
119+ }
120+ catch (Error e)
121+ {
122+ warning ("Failed to register /org/gnome/SessionManager: %s", e.message);
123+ }
124+ },
125+ () =>
126+ {
127+ debug ("Acquired org.gnome.SessionManager");
128+ start_settings_daemon ();
129+ },
130+ () => debug ("Failed to acquire name org.gnome.SessionManager"));
131+
132+ /* The power plugin does the screen saver screen blanking and disables
133+ * the builtin X screen saver. It relies on gnome-screensaver to generate
134+ * the event to trigger this (which actually comes from gnome-session).
135+ * We implement the gnome-screensaver inteface and start the settings
136+ * daemon once it is registered on the bus so gnome-screensaver is not
137+ * started when it accesses this interface */
138+ screen_saver = new ScreenSaverInterface ();
139+ n_names++;
140+ GLib.Bus.own_name (BusType.SESSION, "org.gnome.ScreenSaver", BusNameOwnerFlags.NONE,
141+ (c) =>
142+ {
143+ try
144+ {
145+ c.register_object ("/org/gnome/ScreenSaver", screen_saver);
146+ }
147+ catch (Error e)
148+ {
149+ warning ("Failed to register /org/gnome/ScreenSaver: %s", e.message);
150+ }
151+ },
152+ () =>
153+ {
154+ debug ("Acquired org.gnome.ScreenSaver");
155+ start_settings_daemon ();
156+ },
157+ () => debug ("Failed to acquire name org.gnome.ScreenSaver"));
158
159 /* The media-keys plugin inhibits the power key, but we don't want
160 all the other keys doing things. So inhibit it ourselves */
161@@ -113,8 +150,14 @@
162 }
163 }
164
165- private async void run ()
166+ private void start_settings_daemon ()
167 {
168+ n_names--;
169+ if (n_names != 0)
170+ return;
171+
172+ debug ("All bus names acquired, starting unity-settings-daemon");
173+
174 try
175 {
176 Process.spawn_command_line_async (Config.USD_BINARY);
177@@ -125,3 +168,67 @@
178 }
179 }
180 }
181+
182+[DBus (name="org.gnome.ScreenSaver")]
183+public class ScreenSaverInterface : Object
184+{
185+ public signal void active_changed (bool value);
186+
187+ private Gnome.IdleMonitor idle_monitor;
188+ private bool _active = false;
189+ private uint idle_watch = 0;
190+
191+ public ScreenSaverInterface ()
192+ {
193+ idle_monitor = new Gnome.IdleMonitor ();
194+ _set_active (false);
195+ }
196+
197+ private void _set_active (bool value)
198+ {
199+ _active = value;
200+ if (idle_watch != 0)
201+ idle_monitor.remove_watch (idle_watch);
202+ idle_watch = 0;
203+ if (value)
204+ idle_monitor.add_user_active_watch (() => set_active (false));
205+ else
206+ {
207+ var timeout = UGSettings.get_integer (UGSettings.KEY_IDLE_TIMEOUT);
208+ if (timeout > 0)
209+ idle_watch = idle_monitor.add_idle_watch (timeout * 1000, () => set_active (true));
210+ }
211+ }
212+
213+ public void set_active (bool value)
214+ {
215+ if (_active == value)
216+ return;
217+
218+ if (value)
219+ debug ("Screensaver activated");
220+ else
221+ debug ("Screensaver disabled");
222+
223+ _set_active (value);
224+ active_changed (value);
225+ }
226+
227+ public bool get_active ()
228+ {
229+ return _active;
230+ }
231+
232+ public uint32 get_active_time () { return 0; }
233+ public void lock () {}
234+ public void show_message (string summary, string body, string icon) {}
235+ public void simulate_user_activity () {}
236+}
237+
238+[DBus (name="org.gnome.SessionManager")]
239+public class SessionManagerInterface : Object
240+{
241+ public bool session_is_active { get { return true; } }
242+ public string session_name { get { return "ubuntu"; } }
243+ public uint32 inhibited_actions { get { return 0; } }
244+}
245
246=== modified file 'src/settings.vala'
247--- src/settings.vala 2014-03-26 04:31:27 +0000
248+++ src/settings.vala 2014-04-07 03:59:04 +0000
249@@ -40,6 +40,7 @@
250 public static const string KEY_PLAY_READY_SOUND = "play-ready-sound";
251 public static const string KEY_INDICATORS = "indicators";
252 public static const string KEY_HIDDEN_USERS = "hidden-users";
253+ public static const string KEY_IDLE_TIMEOUT = "idle-timeout";
254
255 public static bool get_boolean (string key)
256 {
257@@ -60,6 +61,12 @@
258 return default;
259 }
260
261+ public static int get_integer (string key)
262+ {
263+ var gsettings = new Settings (SCHEMA);
264+ return gsettings.get_int (key);
265+ }
266+
267 public static double get_double (string key)
268 {
269 var gsettings = new Settings (SCHEMA);
270
271=== modified file 'src/unity-greeter.vala'
272--- src/unity-greeter.vala 2014-04-01 21:05:10 +0000
273+++ src/unity-greeter.vala 2014-04-07 03:59:04 +0000
274@@ -77,7 +77,7 @@
275 if (!test_mode)
276 {
277 settings_daemon = new SettingsDaemon ();
278- settings_daemon.start.begin ();
279+ settings_daemon.start ();
280 }
281
282 var state_dir = Path.build_filename (Environment.get_user_cache_dir (), "unity-greeter");

Subscribers

People subscribed via source and target branches