After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 682224 - libgnome-desktop: Add GnomeIdleMonitor
libgnome-desktop: Add GnomeIdleMonitor
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: libgnome-desktop
unspecified
Other All
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
: 672039 (view as bug list)
Depends on:
Blocks: 672825 687791
 
 
Reported: 2012-08-20 04:15 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2012-11-12 18:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libgnome-desktop: Add GnomeIdleMonitor (14.51 KB, patch)
2012-08-20 04:15 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
libgnome-desktop: Add GnomeIdleMonitor (14.51 KB, patch)
2012-08-20 07:43 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
libgnome-desktop: Add GnomeIdleMonitor (16.41 KB, patch)
2012-09-13 21:35 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
Port to GnomeIdleMonitor (25.63 KB, patch)
2012-09-13 21:35 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
power: Power to GnomeIdleMonitor (30.40 KB, patch)
2012-09-13 21:36 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
Port to GnomeDesktopIdleMonitor (23.67 KB, patch)
2012-09-13 21:37 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
Port to GnomeDesktopIdleMonitor (23.74 KB, patch)
2012-09-14 14:44 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
Port to GnomeDesktopIdleMonitor (23.74 KB, patch)
2012-09-14 14:44 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
idle-monitor: Fix a memory leak when finding the proper IDLETIME counter (1.13 KB, patch)
2012-10-30 17:13 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
idle-monitor: Remove the global constructor (1.81 KB, patch)
2012-10-30 17:14 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
idle-monitor: Allow counting device-specific idle-times (6.46 KB, patch)
2012-10-30 17:14 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
idle-monitor: Remove the global constructor (2.02 KB, patch)
2012-10-31 15:36 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
idle-monitor: Allow counting device-specific idle-times (6.50 KB, patch)
2012-10-31 15:36 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
idle-monitor: Allow counting device-specific idle-times (6.93 KB, patch)
2012-11-12 18:05 UTC, Bastien Nocera
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2012-08-20 04:15:28 UTC
This code has been floating around for a while. I stole it from
gnome-shell, cleaned it up so it was less icky and fit in with
gnome-desktop style guides and things.

gnome-screensaver and gnome-session have the same code, and I'm
quite sure there's other code that cares about small amounts of
user idle time (smaller than gnome-session presence provides)
and either has its own IDLETIME hacks or uses timeouts (uggh)
to try it.
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-08-20 04:15:31 UTC
Created attachment 221782 [details] [review]
libgnome-desktop: Add GnomeIdleMonitor

This copy/paste code has long been part of gnome-shell, gnome-session,
gnome-screensaver, and probably other places as well. It deserves a
standard place in gnome-desktop for code deduplication.
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-08-20 04:16:34 UTC
Oh, I forgot to add: I have patches for gnome-shell and gnome-session. They're not too difficult (s/gs/gnome/ or s/Shell./GnomeDesktop./), so I'm not sure they're worthy of attaching here.
Comment 3 Jasper St. Pierre (not reading bugmail) 2012-08-20 07:43:18 UTC
Created attachment 221789 [details] [review]
libgnome-desktop: Add GnomeIdleMonitor

This copy/paste code has long been part of gnome-shell, gnome-session,
gnome-screensaver, and probably other places as well. It deserves a
standard place in gnome-desktop for code deduplication.



Make sure to add a ref in the constructor.
Comment 4 Colin Walters 2012-08-20 12:45:53 UTC
Review of attachment 221782 [details] [review]:

We could also move to the model where just gnome-settings-daemon is monitoring, and everything else watches over DBus.  But this is fine with me.

I'm assuming you didn't modify the code other than renaming; if so, looks correct to me.
Comment 5 Colin Walters 2012-08-20 12:46:22 UTC
Review of attachment 221789 [details] [review]:

ACN based on previous review.
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-08-20 17:58:05 UTC
I did modify the code a lot.
Comment 7 Jasper St. Pierre (not reading bugmail) 2012-08-20 18:33:25 UTC
I'm also not super happy with the (existing) API. Maybe look at a chance to improve it?
Comment 8 Colin Walters 2012-08-20 21:13:34 UTC
(In reply to comment #6)
> I did modify the code a lot.

Eeee....you know this code has been a continual source of evil, hard to reproduce bugs right?  (Both in it and the X server).

Hmm...do you plan to replace plugins/power/gpm-idletime.c too in gnome-settings-daemon?

Let's see if we can get hughsie in on this bug.
Comment 9 Jasper St. Pierre (not reading bugmail) 2012-08-20 21:18:38 UTC
(In reply to comment #8)
> (In reply to comment #6)
> > I did modify the code a lot.
> 
> Eeee....you know this code has been a continual source of evil, hard to
> reproduce bugs right?  (Both in it and the X server).

Yes, I do. That's why I modified (read: simplified) the code a lot. :)

> Hmm...do you plan to replace plugins/power/gpm-idletime.c too in
> gnome-settings-daemon?

I swore I grepped through gnome-settings-daemon and didn't find anything. But yes, looks like I can easily replace it.

> Let's see if we can get hughsie in on this bug.
Comment 10 Jasper St. Pierre (not reading bugmail) 2012-09-13 21:09:18 UTC
OK, I ported plugins/power, and at the same time decided to clean the API of GnomeIdleMonitor up. New patches incoming, along with gnome-session, gnome-shell and gnome-settings-daemon patches.
Comment 11 Jasper St. Pierre (not reading bugmail) 2012-09-13 21:35:49 UTC
Created attachment 224279 [details] [review]
libgnome-desktop: Add GnomeIdleMonitor

This copy/paste code has long been part of gnome-shell, gnome-session,
gnome-screensaver, and probably other places as well. It deserves a
standard place in gnome-desktop for code deduplication.
Comment 12 Jasper St. Pierre (not reading bugmail) 2012-09-13 21:35:58 UTC
Created attachment 224280 [details] [review]
Port to GnomeIdleMonitor
Comment 13 Jasper St. Pierre (not reading bugmail) 2012-09-13 21:36:58 UTC
Created attachment 224281 [details] [review]
power: Power to GnomeIdleMonitor
Comment 14 Jasper St. Pierre (not reading bugmail) 2012-09-13 21:37:11 UTC
Created attachment 224282 [details] [review]
Port to GnomeDesktopIdleMonitor
Comment 15 Richard Hughes 2012-09-14 12:50:51 UTC
Review of attachment 224281 [details] [review]:

Looks fine with me; that XIDLETIME code is super-hard to get right so it probably deserves to be abstracted out. Thanks.
Comment 16 Jasper St. Pierre (not reading bugmail) 2012-09-14 14:44:41 UTC
Created attachment 224333 [details] [review]
Port to GnomeDesktopIdleMonitor
Comment 17 Jasper St. Pierre (not reading bugmail) 2012-09-14 14:44:56 UTC
Created attachment 224334 [details] [review]
Port to GnomeDesktopIdleMonitor

Update shell patch, and rebase to master.
Comment 18 Jasper St. Pierre (not reading bugmail) 2012-10-10 22:17:25 UTC
I'd like to get this in for 3.8 (or 3.6.1 if we have time)
Comment 19 Colin Walters 2012-10-22 15:22:05 UTC
Review of attachment 224279 [details] [review]:

Code looks reasonable, having been reviewed by Richard as well is good.
Comment 20 Colin Walters 2012-10-22 15:29:42 UTC
Review of attachment 224334 [details] [review]:

One minor question, otherwise looks right.

::: js/ui/messageTray.js
@@ +2128,3 @@
+        let userIdle = this.idleMonitor.get_idletime() > IDLE_TIME;
+        if (userIdle) {
+            this._userActiveWhileNotificationShown = false;

This is not a new bug, but can't we end up leaking watches here if showNotification() gets called multiple times?
Comment 21 Jasper St. Pierre (not reading bugmail) 2012-10-22 16:06:23 UTC
Comment on attachment 224279 [details] [review]
libgnome-desktop: Add GnomeIdleMonitor

Attachment 224279 [details] pushed as df95944 - libgnome-desktop: Add GnomeIdleMonitor
Comment 22 Jasper St. Pierre (not reading bugmail) 2012-10-22 16:07:25 UTC
Comment on attachment 224334 [details] [review]
Port to GnomeDesktopIdleMonitor

Attachment 224280 [details] pushed as d106191 - Port to GnomeIdleMonitor


Indeed we will! Fixed and pushed.
Comment 23 Jasper St. Pierre (not reading bugmail) 2012-10-25 20:40:15 UTC
Can I get feedback on the g-s-d and g-s patches here?
Comment 24 Bastien Nocera 2012-10-26 08:16:15 UTC
(In reply to comment #23)
> Can I get feedback on the g-s-d and g-s patches here?

Seeing as you've already committed the code here, why don't you create new bugs for the ports?
Comment 25 Bastien Nocera 2012-10-26 08:22:28 UTC
*** Bug 672039 has been marked as a duplicate of this bug. ***
Comment 26 Bastien Nocera 2012-10-26 08:24:58 UTC
FWIW, gnome_idle_monitor_add_watch() is broken if init_xsync() fails.

It's also missing per-device idle support as requested in bug 672039.

Would also be great in the future that you ask g-s-d maintainers if you want to move code from g-s-d somewhere else, just to make sure all the requirements are fulfilled.
Comment 27 Bastien Nocera 2012-10-26 08:28:41 UTC
Review of attachment 224281 [details] [review]:

::: configure.ac
@@ +48,3 @@
 GCONF_REQUIRED_VERSION=2.6.1
 GIO_REQUIRED_VERSION=2.26.0
+GNOME_DESKTOP_REQUIRED_VERSION=3.5.91

Version will need changing.

::: plugins/power/gsd-power-manager.c
@@ +3853,3 @@
         }
 
+        g_object_unref (manager->priv->idle_monitor);

Use g_clear_object() instead.
Comment 28 Jasper St. Pierre (not reading bugmail) 2012-10-26 12:50:12 UTC
(In reply to comment #26)
> FWIW, gnome_idle_monitor_add_watch() is broken if init_xsync() fails.

That's just a fatal error I'm not sure what we should do.

> It's also missing per-device idle support as requested in bug 672039.

Sorry, I didn't see that bug, and I didn't see anything using per-device idle timers yet, so I assumed they weren't wanted yet. They're not hard to add.

> Would also be great in the future that you ask g-s-d maintainers if you want to
> move code from g-s-d somewhere else, just to make sure all the requirements are
> fulfilled.

That's why I tried to get Richard's input.
Comment 29 Bastien Nocera 2012-10-26 14:38:48 UTC
(In reply to comment #28)
> (In reply to comment #26)
> > FWIW, gnome_idle_monitor_add_watch() is broken if init_xsync() fails.
> 
> That's just a fatal error I'm not sure what we should do.

Either a GInitable, or a binding-friendly _get_error() would be my guess.

> > It's also missing per-device idle support as requested in bug 672039.
> 
> Sorry, I didn't see that bug, and I didn't see anything using per-device idle
> timers yet, so I assumed they weren't wanted yet. They're not hard to add.

Excellent, would be very useful.

> > Would also be great in the future that you ask g-s-d maintainers if you want to
> > move code from g-s-d somewhere else, just to make sure all the requirements are
> > fulfilled.
> 
> That's why I tried to get Richard's input.

He probably was a wee bit busy at the time ;)
No big deal.
Comment 30 Jasper St. Pierre (not reading bugmail) 2012-10-30 17:13:56 UTC
Created attachment 227658 [details] [review]
idle-monitor: Fix a memory leak when finding the proper IDLETIME counter
Comment 31 Jasper St. Pierre (not reading bugmail) 2012-10-30 17:14:01 UTC
Created attachment 227659 [details] [review]
idle-monitor: Remove the global constructor

To support device-specific counters, we're going to need the ability
to create multiple instances of the idle-monitor.
Comment 32 Jasper St. Pierre (not reading bugmail) 2012-10-30 17:14:41 UTC
Created attachment 227660 [details] [review]
idle-monitor: Allow counting device-specific idle-times

For more complicated cases, it's possible that users may want to
track per-device idle times. Allow them to specify a "device" property
so that they can do this properly.



Note that this is untested -- I haven't actually sat down and tested that
this works properly, but it doesn't break the old IDLETIME case, and it
compiles.
Comment 33 Jasper St. Pierre (not reading bugmail) 2012-10-31 15:36:09 UTC
Created attachment 227734 [details] [review]
idle-monitor: Remove the global constructor

To support device-specific counters, we're going to need the ability
to create multiple instances of the idle-monitor.



Fix a potential crash where the filter would stay alive after the IdleMonitor was disposed.
Comment 34 Jasper St. Pierre (not reading bugmail) 2012-10-31 15:36:20 UTC
Created attachment 227735 [details] [review]
idle-monitor: Allow counting device-specific idle-times

For more complicated cases, it's possible that users may want to
track per-device idle times. Allow them to specify a "device" property
so that they can do this properly.



No changes, reattaching for order.
Comment 35 Bastien Nocera 2012-10-31 16:17:46 UTC
Comment on attachment 224280 [details] [review]
Port to GnomeIdleMonitor

Removing gnome-session patch from gnome-desktop bug.
Comment 36 Bastien Nocera 2012-10-31 16:18:28 UTC
Review of attachment 227658 [details] [review]:

++
Comment 37 Bastien Nocera 2012-10-31 16:19:48 UTC
Review of attachment 227734 [details] [review]:

++
Comment 38 Bastien Nocera 2012-10-31 16:23:45 UTC
Review of attachment 227735 [details] [review]:

What happens when the server doesn't support the device-specific idletime counter?
What happens when the GdkDevice is invalidated? (eg. somebody unplugged the keyboard this was tracking)

::: libgnome-desktop/gnome-idle-monitor.c
@@ +191,3 @@
+{
+	if (device) {
+		gint device_id = gdk_x11_device_get_id (device);

Split this in 2 lines.

@@ +206,3 @@
 	XSyncSystemCounter *counters;
 	XSyncCounter        counter = None;
+	char               *counter_name = counter_name_for_device (monitor->priv->device);

Please, no assignment in declarations.
Comment 39 Jasper St. Pierre (not reading bugmail) 2012-10-31 16:59:51 UTC
Attachment 227658 [details] pushed as d56495c - idle-monitor: Fix a memory leak when finding the proper IDLETIME counter
Attachment 227734 [details] pushed as ec61247 - idle-monitor: Remove the global constructor
Comment 40 Jasper St. Pierre (not reading bugmail) 2012-11-12 17:33:18 UTC
Comment on attachment 224281 [details] [review]
power: Power to GnomeIdleMonitor

Attachment 224281 [details] pushed as 09b764b - power: Power to GnomeIdleMonitor
Comment 41 Bastien Nocera 2012-11-12 18:05:43 UTC
Created attachment 228800 [details] [review]
idle-monitor: Allow counting device-specific idle-times

For more complicated cases, it's possible that users may want to
track per-device idle times. Allow them to specify a "device" property
so that they can do this properly.
Comment 42 Bastien Nocera 2012-11-12 18:20:11 UTC
Attachment 228800 [details] pushed as 35ee57f - idle-monitor: Allow counting device-specific idle-times