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 727874 - _NET_WM_WINDOW_OPACITY now uses the incorrect range for opacity values
_NET_WM_WINDOW_OPACITY now uses the incorrect range for opacity values
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
3.12.x
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2014-04-09 05:57 UTC by Nirbheek Chauhan
Modified: 2014-04-10 16:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
window-props: _NET_WM_WINDOW_OPACITY range is 0xffffffff to 0 (1.23 KB, patch)
2014-04-09 06:00 UTC, Nirbheek Chauhan
committed Details | Review
Use guint8 for opacity (1.89 KB, patch)
2014-04-10 07:02 UTC, Nirbheek Chauhan
committed Details | Review

Description Nirbheek Chauhan 2014-04-09 05:57:26 UTC
According to the specification, _NET_WM_WINDOW_OPACITY values range from opaque (0xffffffff) to transparent (0x0). This is also how Mutter used to parse these values before 3.12 (ref: 1db95bc32be97028aae5f0f9d616cfe3cbfafbf6)

In src/compositor/meta-window-actor.c:

 meta_window_actor_update_opacity() {
 ...
       opacity = (guint8)((gfloat)value * 255.0 / ((gfloat)0xffffffff));
 ...
   clutter_actor_set_opacity (self->priv->actor, opacity);
 }

Now, however, the value is directly used and assumed to lie between 0x0 and 0xff:

In src/compositor/meta-window-actor.c:

 meta_window_actor_update_opacity() {
 ...
   clutter_actor_set_opacity (self->priv->actor, window->opacity);
 }

In src/core/window-props.c:

reload_window_opacity() {
...
  meta_window_set_opacity (window, requested_value);
...
}

Due to the way clutter handles the out-of-range opacity value, this causes the opacity value to be truncated to the last two digits. For instance, 0x7fffffff (50%) becomes 0xff (100%).

The attached patch fixes this by changing it *only* when the Atom value is read, in reload_window_opacity(). 

AIUI, mutter now always takes opacity values between 0 and 255? If so, it probably also makes sense to change the prototype of meta_window_set_opacity () to be "guint8 opacity" so that there's compiler warnings if this happens again, but that's your call.
Comment 1 Nirbheek Chauhan 2014-04-09 06:00:19 UTC
Created attachment 273851 [details] [review]
window-props: _NET_WM_WINDOW_OPACITY range is 0xffffffff to 0
Comment 2 Nirbheek Chauhan 2014-04-09 06:01:02 UTC
I couldn't find a link to the specification itself, but here's an email from Keith Packard about it: http://lists.freedesktop.org/archives/xdg/2003-December/001413.html
Comment 3 drago01 2014-04-09 13:52:44 UTC
Review of attachment 273851 [details] [review]:

Looks good.
Comment 4 drago01 2014-04-09 14:39:36 UTC
Attachment 273851 [details] pushed as 0c0973b - window-props: _NET_WM_WINDOW_OPACITY range is 0xffffffff to 0
Comment 5 Jasper St. Pierre (not reading bugmail) 2014-04-09 17:04:40 UTC
(In reply to comment #0)
> AIUI, mutter now always takes opacity values between 0 and 255? If so, it
> probably also makes sense to change the prototype of meta_window_set_opacity ()
> to be "guint8 opacity" so that there's compiler warnings if this happens again,
> but that's your call.

Could you make a patch for that as well? That sounds like a good idea.
Comment 6 Nirbheek Chauhan 2014-04-10 07:02:41 UTC
Created attachment 273958 [details] [review]
Use guint8 for opacity

(In reply to comment #5)
> (In reply to comment #0)
> > AIUI, mutter now always takes opacity values between 0 and 255? If so, it
> > probably also makes sense to change the prototype of meta_window_set_opacity ()
> > to be "guint8 opacity" so that there's compiler warnings if this happens again,
> > but that's your call.
> 
> Could you make a patch for that as well? That sounds like a good idea.

Patch attached.
Comment 7 drago01 2014-04-10 07:06:38 UTC
Review of attachment 273958 [details] [review]:

LG.