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

Subscribers

People subscribed via source and target branches