Merge lp:~nobuto/notify-osd/fix_dnd_is_screensaver_inhibited into lp:notify-osd

Proposed by Nobuto Murata
Status: Merged
Approved by: Iain Lane
Approved revision: 489
Merged at revision: 494
Proposed branch: lp:~nobuto/notify-osd/fix_dnd_is_screensaver_inhibited
Merge into: lp:notify-osd
Diff against target: 178 lines (+62/-44)
4 files modified
debian/changelog (+7/-0)
src/dnd.c (+52/-41)
src/dnd.h (+1/-1)
tests/test-dnd.c (+2/-2)
To merge this branch: bzr merge lp:~nobuto/notify-osd/fix_dnd_is_screensaver_inhibited
Reviewer Review Type Date Requested Status
Iain Lane Approve
Review via email: mp+255538@code.launchpad.net

Description of the change

This merge proposal fixes LP: #1440825.

However the dnd_is_screensaver_inhibited is broken at least for a few years now, users of caffeine[1] or indicator-session-idle-inhibit[2] might feel the "fix" is a regression, i.e. notification suddenly stops working by notify-osd update.

[1] https://launchpad.net/caffeine
[2] https://github.com/oyvindstegard/indicator-session-idle-inhibit

I'm not sure which is the right way. A cleaner way to inhibit notifications(e.g. example org.freedesktop.Notifications.X-Inhibit dbus method) might be needed though.

To post a comment you must log in.
Revision history for this message
Lars Karlitski (larsu) wrote :

I'm not sure. Inhibiting the session from going idle doesn't necessarily mean "don't show notifications" to me...

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> I'm not sure. Inhibiting the session from going idle doesn't necessarily mean
> "don't show notifications" to me...

Yeah, I agree. But still this is what was supposed to happen before (so not sure we should resume it).
However, it is even true that 99% of apps that inhibit the screensaver are media-players which might use this strategy.
Do we have a list of apps using this API?

Having an inhibit "notifications" (API is extendible) would be nicer, though.
Also, I'm not sure whether unity does support this currently (in case we've to fix it).

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Also, I'm not sure whether unity does support this currently (in case we've to
> fix it).

Ok, it seems unity works fine when inhibited, but this is not checked when the screensaver is launched by logind or manually (but that's not idle).

Revision history for this message
Iain Lane (laney) wrote :

I tried it, it works good - the code seems fine. Let's get this in for wily.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-01-26 14:16:51 +0000
3+++ debian/changelog 2015-04-08 16:29:00 +0000
4@@ -1,3 +1,10 @@
5+notify-osd (0.9.35+15.04.20150126-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ * dnd_is_screensaver_inhibited no longer works due to obsoleted dbus
8+ method. replace it by an equivalent dbus call, LP: #1440825
9+
10+ -- Nobuto Murata <nobuto@ubuntu.com> Tue, 07 Apr 2015 17:47:18 +0900
11+
12 notify-osd (0.9.35+15.04.20150126-0ubuntu1) vivid; urgency=low
13
14 [ Alberts Muktupāvels ]
15
16=== modified file 'src/dnd.c'
17--- src/dnd.c 2012-01-24 08:14:04 +0000
18+++ src/dnd.c 2015-04-08 16:29:00 +0000
19@@ -45,6 +45,7 @@
20 #include "dbus.h"
21
22 static DBusGProxy *gsmgr = NULL;
23+static DBusGProxy *gscrsvr = NULL;
24
25 gboolean
26 dnd_is_xscreensaver_active ()
27@@ -98,55 +99,65 @@
28 }
29
30 static DBusGProxy*
31-get_screensaver_proxy (void)
32+get_gnomesession_proxy (void)
33 {
34 if (gsmgr == NULL)
35 {
36 DBusGConnection *connection = dbus_get_connection ();
37 gsmgr = dbus_g_proxy_new_for_name (connection,
38+ "org.gnome.SessionManager",
39+ "/org/gnome/SessionManager",
40+ "org.gnome.SessionManager");
41+ }
42+
43+ return gsmgr;
44+}
45+
46+gboolean
47+dnd_is_idle_inhibited ()
48+{
49+ GError *error = NULL;
50+ gboolean inhibited = FALSE;
51+ guint idle = 8; // 8: Inhibit the session being marked as idle
52+
53+ if (! get_gnomesession_proxy ())
54+ return FALSE;
55+
56+ dbus_g_proxy_call_with_timeout (
57+ gsmgr, "IsInhibited", 2000, &error,
58+ G_TYPE_UINT, idle,
59+ G_TYPE_INVALID,
60+ G_TYPE_BOOLEAN, &inhibited,
61+ G_TYPE_INVALID);
62+
63+ if (error)
64+ {
65+ g_warning ("dnd_is_idle_inhibited(): "
66+ "got error \"%s\"\n",
67+ error->message);
68+ g_error_free (error);
69+ error = NULL;
70+ }
71+
72+ if (inhibited)
73+ g_debug ("Session idleness has been inhibited");
74+
75+ return inhibited;
76+}
77+
78+static DBusGProxy*
79+get_screensaver_proxy (void)
80+{
81+ if (gscrsvr == NULL)
82+ {
83+ DBusGConnection *connection = dbus_get_connection ();
84+ gscrsvr = dbus_g_proxy_new_for_name (connection,
85 "org.gnome.ScreenSaver",
86 "/org/gnome/ScreenSaver",
87 "org.gnome.ScreenSaver");
88 }
89
90- return gsmgr;
91-}
92-
93-gboolean
94-dnd_is_screensaver_inhibited ()
95-{
96- GError *error = NULL;
97- gboolean inhibited = FALSE;
98- char **list;
99-
100- if (! get_screensaver_proxy ())
101- return FALSE;
102-
103- if (dbus_g_proxy_call_with_timeout (
104- gsmgr, "GetInhibitors", 2000, &error,
105- G_TYPE_INVALID,
106- G_TYPE_STRV, &list,
107- G_TYPE_INVALID))
108- {
109- if (error)
110- {
111- g_warning ("dnd_is_screensaver_inhibited(): "
112- "got error \"%s\"\n",
113- error->message);
114- g_error_free (error);
115- error = NULL;
116- }
117-
118- /* if the list is not empty, the screensaver is inhibited */
119- if (*list)
120- {
121- inhibited = TRUE;
122- g_debug ("Screensaver has been inhibited");
123- }
124- g_strfreev (list);
125- }
126-
127- return inhibited;
128+ return gscrsvr;
129 }
130
131 gboolean
132@@ -159,7 +170,7 @@
133 return FALSE;
134
135 dbus_g_proxy_call_with_timeout (
136- gsmgr, "GetActive", 2000, &error,
137+ gscrsvr, "GetActive", 2000, &error,
138 G_TYPE_INVALID,
139 G_TYPE_BOOLEAN, &active,
140 G_TYPE_INVALID);
141@@ -222,7 +233,7 @@
142 return (dnd_is_online_presence_dnd()
143 || dnd_is_xscreensaver_active()
144 || dnd_is_screensaver_active()
145- || dnd_is_screensaver_inhibited()
146+ || dnd_is_idle_inhibited()
147 || dnd_has_one_fullscreen_window()
148 );
149 }
150
151=== modified file 'src/dnd.h'
152--- src/dnd.h 2009-06-02 16:28:26 +0000
153+++ src/dnd.h 2015-04-08 16:29:00 +0000
154@@ -39,7 +39,7 @@
155 dnd_is_xscreensaver_active (void);
156
157 gboolean
158-dnd_is_screensaver_inhibited (void);
159+dnd_is_idle_inhibited (void);
160
161 gboolean
162 dnd_is_screensaver_active (void);
163
164=== modified file 'tests/test-dnd.c'
165--- tests/test-dnd.c 2011-07-01 18:23:39 +0000
166+++ tests/test-dnd.c 2015-04-08 16:29:00 +0000
167@@ -41,10 +41,10 @@
168 void
169 test_dnd_screensaver (gpointer fixture, gconstpointer user_data)
170 {
171- gboolean test = dnd_is_screensaver_inhibited();
172+ gboolean test = dnd_is_idle_inhibited();
173
174 if (test)
175- g_debug ("screensaver is inhibited");
176+ g_debug ("idleness is inhibited");
177
178 test = dnd_is_screensaver_active();
179

Subscribers

People subscribed via source and target branches