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 698754 - power: Use a DBus property for screen brightness
power: Use a DBus property for screen brightness
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2013-04-24 15:40 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2013-06-23 00:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
power: Use a DBus property for screen brightness (8.62 KB, patch)
2013-04-24 15:40 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
power: Use a DBus property for screen brightness (11.28 KB, patch)
2013-05-09 13:58 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
power: Use a DBus property for screen brightness (12.21 KB, patch)
2013-06-10 18:53 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
power: Split out get_property (2.95 KB, patch)
2013-06-12 20:43 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
power: Use a DBus property for screen brightness (11.26 KB, patch)
2013-06-12 20:43 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2013-04-24 15:40:05 UTC
See patch. This will be used in gnome-shell to implement the
brightness slider.
Comment 1 Jasper St. Pierre (not reading bugmail) 2013-04-24 15:40:07 UTC
Created attachment 242336 [details] [review]
power: Use a DBus property for screen brightness

This is a much easier interface for clients to manage.
Comment 2 Bastien Nocera 2013-04-24 15:57:08 UTC
Get/SetPercentage means that we don't need to make sure the brightness is synced with its actual value. The explicit API also ensure that errors are returned when getting or settings fails. I'm not sure it's that big a problem, but those should be mentioned in the commit log.

You'd also need to create more patches, g-s-d's color plugin uses SetPercentage, so does the Power panel in g-c-c.
Comment 3 Jasper St. Pierre (not reading bugmail) 2013-05-01 19:26:25 UTC
(In reply to comment #2)
> Get/SetPercentage means that we don't need to make sure the brightness is
> synced with its actual value.

Doesn't this mean that the slider in g-c-c (or in the new g-s designs) will get out of sync with the real brightness in some cases, then?

> The explicit API also ensure that errors are
> returned when getting or settings fails. I'm not sure it's that big a problem,
> but those should be mentioned in the commit log.

OK, will do.

> You'd also need to create more patches, g-s-d's color plugin uses
> SetPercentage, so does the Power panel in g-c-c.

g-c-c patch is in bug #698757. Will work on the color plugin; didn't know it used the DBus API.
Comment 4 Jasper St. Pierre (not reading bugmail) 2013-05-09 13:58:33 UTC
Created attachment 243702 [details] [review]
power: Use a DBus property for screen brightness

A property is easier for clients to manage, as they'll automatically
get new PropertiesChanged signals when the value changes, and with
GDBus bindings, properties are cached field lookups that don't require
asynchronous access.

The downside is that we cannot report any errors when getting the
brightness. For most user interface designs, however, this is
insignificant.

Also adapt the color plugin to the new interface.
Comment 5 Bastien Nocera 2013-06-04 12:05:31 UTC
Review of attachment 243702 [details] [review]:

::: plugins/color/gsd-color-manager.c
@@ +656,3 @@
+                                "org.freedesktop.DBus.Properties",
+                                "Set",
+                                g_variant_new_parsed ("('" GSD_DBUS_INTERFACE_POWER_SCREEN "',"

That is quite ugly, any way to make this cleaner?

::: plugins/power/gsd-power-manager.c
@@ +2329,3 @@
                 return;
+
+        value = backlight_get_percentage (manager->priv->rr_screen, NULL);

You're re-reading the value you've probably just set. That shouldn't be necessary.

@@ +3899,3 @@
+        /* Check session pointer as a proxy for whether the manager is in the
+           start or stop state */
+        if (manager->priv->session == NULL) {

You already check that in handle_get_property().

@@ +3906,3 @@
+                guint32 value;
+                value = backlight_get_percentage (manager->priv->rr_screen, NULL);
+                retval = g_variant_new_uint32 (value);

How does it return the lack of backlight devices to the caller for example?
Magic number? Return an error?
Comment 6 Jasper St. Pierre (not reading bugmail) 2013-06-10 18:53:56 UTC
Created attachment 246433 [details] [review]
power: Use a DBus property for screen brightness

A property is easier for clients to manage, as they'll automatically
get new PropertiesChanged signals when the value changes, and with
GDBus bindings, properties are cached field lookups that don't require
asynchronous access.

The downside is that we cannot report any errors when getting the
brightness. For most user interface designs, however, this is
insignificant.

Also adapt the color plugin to the new interface.



Review notes taken into account. Property reports -1 on error.

Suggestions for better cleanups welcome.
Comment 7 Bastien Nocera 2013-06-11 16:16:10 UTC
Review of attachment 246433 [details] [review]:

(In reply to comment #6)
<snip>
> The downside is that we cannot report any errors when getting the
> brightness. 
<snip>
> Review notes taken into account. Property reports -1 on error.

The commit message needs updating.

Nearly there!

::: plugins/power/gsd-power-manager.c
@@ +107,2 @@
 "    <method name='StepUp'>"
 "      <arg type='u' name='new_percentage' direction='out'/>"

StepUp/StepDown will need to use "i" as well, so they can report the new negative value on error, and the media-keys plugin should be fixed for the new API.

@@ +3864,2 @@
 static GVariant *
+handle_get_property_main (GsdPowerManager *manager,

I'd have split the code move from handle_get_property() to this new function.
Comment 8 Jasper St. Pierre (not reading bugmail) 2013-06-12 20:43:37 UTC
Created attachment 246674 [details] [review]
power: Split out get_property

We want to add properties on the Screen iface, so remove this.
Comment 9 Jasper St. Pierre (not reading bugmail) 2013-06-12 20:43:41 UTC
Created attachment 246675 [details] [review]
power: Use a DBus property for screen brightness

A property is easier for clients to manage, as they'll automatically
get new PropertiesChanged signals when the value changes, and with
GDBus bindings, properties are cached field lookups that don't require
asynchronous access.

If there are any errors when fetching the new brightness, the value
-1 is returned, so the interface has been modified slightly to support
signed values.

Also adapt the color and media-keys plugins to the new interface.
Comment 10 Bastien Nocera 2013-06-13 13:01:02 UTC
Review of attachment 246674 [details] [review]:

Looks good.
Comment 11 Bastien Nocera 2013-06-13 13:04:41 UTC
Review of attachment 246675 [details] [review]:

Looks good.

::: plugins/color/gsd-color-manager.c
@@ +654,3 @@
                                 GSD_DBUS_NAME_POWER,
                                 GSD_DBUS_PATH_POWER,
+                                "org.freedesktop.DBus.Properties",

Can you file a new bug against the color plugin to check the new value of Brightness after the call has finished to check whether the call succeeded? There's good chances we want to have an error here.
Comment 12 Jasper St. Pierre (not reading bugmail) 2013-06-13 13:22:20 UTC
Review of attachment 246675 [details] [review]:

::: plugins/color/gsd-color-manager.c
@@ +654,3 @@
                                 GSD_DBUS_NAME_POWER,
                                 GSD_DBUS_PATH_POWER,
+                                "org.freedesktop.DBus.Properties",

I don't understand. The old callback just emit a warning. I figured that wasn't necessary.
Comment 13 Bastien Nocera 2013-06-13 13:23:50 UTC
(In reply to comment #12)
> Review of attachment 246675 [details] [review]:
> 
> ::: plugins/color/gsd-color-manager.c
> @@ +654,3 @@
>                                  GSD_DBUS_NAME_POWER,
>                                  GSD_DBUS_PATH_POWER,
> +                                "org.freedesktop.DBus.Properties",
> 
> I don't understand. The old callback just emit a warning. I figured that wasn't
> necessary.

Then we should at least emit the warning. That's helpful to developers (meaning, Richard) to debug this problems with the color plugin.
Comment 14 Jasper St. Pierre (not reading bugmail) 2013-06-23 00:17:47 UTC
Attachment 246674 [details] pushed as 9763448 - power: Split out get_property
Attachment 246675 [details] pushed as a4c3299 - power: Use a DBus property for screen brightness