GNOME Bugzilla – Bug 727874
_NET_WM_WINDOW_OPACITY now uses the incorrect range for opacity values
Last modified: 2014-04-10 16:16:11 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.
Created attachment 273851 [details] [review] window-props: _NET_WM_WINDOW_OPACITY range is 0xffffffff to 0
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
Review of attachment 273851 [details] [review]: Looks good.
Attachment 273851 [details] pushed as 0c0973b - window-props: _NET_WM_WINDOW_OPACITY range is 0xffffffff to 0
(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.
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.
Review of attachment 273958 [details] [review]: LG.