Bug 43001 - notify::lid-is-closed not emitted
Summary: notify::lid-is-closed not emitted
Status: RESOLVED FIXED
Alias: None
Product: upower
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-16 11:49 UTC by Federico Mena-Quintero
Modified: 2013-10-14 09:15 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
foo.c (1.02 KB, text/x-csrc)
2011-11-16 11:50 UTC, Federico Mena-Quintero
Details

Description Federico Mena-Quintero 2011-11-16 11:49:41 UTC
The attached test program shows something interesting.

UpClient's "changed" signal gets emitted when I close or open the laptop's lid.

However, the "notify::lid-is-closed" signal doesn't get emitted at the same time.  But if I open/close the lid and call up_client_get_lid_is_closed(), then *that* signal gets emitted and the function returns the correct value.

This means that UpClient notices the change and emits "changed", but doesn't update the properties and emit the corresponding GObject::notify signals until up_client_get_lid_is_closed() is called.

It *seems* that up_client_changed_cb(), the callback from D-Bus, could simply call up_client_get_properties_sync(), but that could probably mean a bunch of roundtrips.  Still, if clients use the "changed" signal, they'll want to know the new state of some properties, so the properties need updating anyway...

I've changed my code to use "changed" instead of "notify::lid-is-closed" and I'm fine with that; it just was surprising to see the latter not emitted.
Comment 1 Federico Mena-Quintero 2011-11-16 11:50:45 UTC
Created attachment 53610 [details]
foo.c
Comment 2 Bastien Nocera 2013-10-12 15:16:32 UTC
UPower doesn't use the PropertiesChanged signal at all.

We could do something ugly like this:
https://git.gnome.org/browse/gnome-session/tree/gnome-session/gsm-manager.c#n2314

Or we could port the whole thing to GDBus...
Comment 3 Bastien Nocera 2013-10-12 19:56:18 UTC
This is done (the hack, not the port) in my branch.
Comment 4 Bastien Nocera 2013-10-14 09:15:33 UTC
Fixed in master with the GDBus port of libupower-glib.

commit 28438a7672eec8277341d14121bf267f8e0542b3
Author: Bastien Nocera <hadess@hadess.net>
Date:   Sat Oct 12 21:49:21 2013 +0200

    lib: Emit notify:: signals
    
    In the UpClient object.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=43001

commit 7531dbdac05f1698d565f564f2280aafbeb1ba57
Author: Bastien Nocera <hadess@hadess.net>
Date:   Sat Oct 12 21:41:33 2013 +0200

    daemon: Emit the PropertiesChanged signal
    
    Use raw D-Bus.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=43001


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.