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 648613 - gtk_window_set_opacity() seems not to work with mutter
gtk_window_set_opacity() seems not to work with mutter
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
3.0.x
Other Linux
: Normal minor
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2011-04-25 14:11 UTC by pierre.sudron
Modified: 2011-04-27 14:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
C code you can try (667 bytes, text/x-csrc)
2011-04-25 14:11 UTC, pierre.sudron
  Details
wm: Consider window opacity in map effect (1.70 KB, patch)
2011-04-26 15:12 UTC, Florian Müllner
rejected Details | Review
Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity (2.45 KB, patch)
2011-04-26 16:11 UTC, Owen Taylor
reviewed Details | Review
Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity (2.41 KB, patch)
2011-04-26 16:27 UTC, Owen Taylor
reviewed Details | Review
Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity (2.52 KB, patch)
2011-04-26 19:11 UTC, Owen Taylor
committed Details | Review

Description pierre.sudron 2011-04-25 14:11:55 UTC
Created attachment 186596 [details]
C code you can try

I run a GNOME 3 desktop with gnome-shell and mutter enabled.
Although gtk_widget_is_composited() returns true, gtk_window_set_opacity() just wont work.

I attached the very simple piece of code I tried. Note that compiling with either gtk+-3.0 or gtk+-2.0 gave me the same result.
Comment 1 Matthias Clasen 2011-04-26 12:17:57 UTC
gtk_wndow_set_opacity only works if the compositing manager supports _NET_WM_WINDOW_OPACITY.
Comment 2 Florian Müllner 2011-04-26 14:39:09 UTC
(In reply to comment #1)
> gtk_wndow_set_opacity only works if the compositing manager supports
> _NET_WM_WINDOW_OPACITY.

Mutter does support _NET_WM_WINDOW_OPACITY - to verify, either run the test program under mutter standalone or start the program and restart gnome-shell (alt-f2 r). This is a known issue caused by bad interaction between mutter and gnome-shell:
 1. mutter doesn't store the hint opacity separately, but uses it
    to set the opacity of the window ClutterActor directly
 2. gnome-shell uses a fade from 0 to full opacity as map effect

For a fix, the easiest approach would probably be to store _NET_WM_WINDOW_OPACITY in a property and either consider it in the window's paint method or use it in the map effect in gnome-shell.
Comment 3 Florian Müllner 2011-04-26 15:12:54 UTC
Created attachment 186661 [details] [review]
wm: Consider window opacity in map effect

Mutter uses the _NET_WM_WINDOW_OPACITY hint to set the MetaWindowActor's
opacity. This setting is lost when applying the map effect, which fades
from 0 to full opacity.
As a quick fix, keep track of the original opacity and use that as
target value in the map effect, rather than assuming full opacity.

(Not the most elegant solution, but it should make window opacity work again ...)
Comment 4 Dan Winship 2011-04-26 15:22:57 UTC
How do we expect _NET_WM_WINDOW_OPACITY to interact with window shadows? If mutter is setting the opacity on the MetaWindowActor, that means it applies to both the window and its shadow. OTOH, if mutter just applied the opacity to the MetaWindowActor's priv->actor, and we handled the shadow separately (a la bug 635268), then gnome-shell wouldn't need any changes.
Comment 5 Florian Müllner 2011-04-26 15:48:41 UTC
(In reply to comment #4)
> How do we expect _NET_WM_WINDOW_OPACITY to interact with window shadows?

http://git.gnome.org/browse/mutter/tree/src/compositor/meta-window-actor.c#n832 suggests that the intention is to not draw any shadow at all (it doesn't work for me though).


> If mutter is setting the opacity on the MetaWindowActor, that means it applies 
> to both the window and its shadow.

It does (e.g. the shadow is drawn with the actor's paint opacity * the shadow opacity).


> OTOH, if mutter just applied the opacity to the MetaWindowActor's priv->actor,
> and we handled the shadow separately (a la bug 635268), then gnome-shell 
> wouldn't need any changes.

Not really. Bug 635268 certainly applies in that the shadow looks weird with translucent windows, but the primary issue here is that the window is not translucent in the first place, because gnome-shell uses the same property for the map effect which mutter uses for _NET_WM_WINDOW_OPACITY (e.g. mutter sets the actor's opacity and gnome-shell's map effect overrides it).

An alternative which wouldn't involve changes to gnome-shell would be to not use _NET_WM_WINDOW_OPACITY to clutter_actor_set_opacity(), but rather apply it on the fly in meta_window_actor_paint().
Comment 6 Owen Taylor 2011-04-26 16:06:10 UTC
Review of attachment 186661 [details] [review]:

I was actually working on this very issue yesterday and came up with more or less this exact patch. But note that it fails if the opacity is changed after the window is mapped but before the animation completes - since actor._targetOpacity isn't updated. I think the better thing to do is to leave MetaWindowActor.opacity *additional* to the argb opacity property in Mutter so that GNOME Shell can just change it and not stomp on the opacity. I'll attach a patch to that effect.
Comment 7 Owen Taylor 2011-04-26 16:11:52 UTC
Created attachment 186663 [details] [review]
Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity

Using MetaWindowActor.opacity for _NET_WM_WINDOW_OPACITY makes it
difficult to implement effects like fading a window in on map.
Instead, set the opacity on the MetaShadedTexture child and use
it when drawing the shadow.

Since the check MetaWindowGroup does on meta_actor_get_paint_opacity()
no longer covers this, we need to handle the opacity in
meta_window_actor_get_obscured_region explicitly.
Comment 8 Owen Taylor 2011-04-26 16:22:13 UTC
(In reply to comment #4)
> How do we expect _NET_WM_WINDOW_OPACITY to interact with window shadows? If
> mutter is setting the opacity on the MetaWindowActor, that means it applies to
> both the window and its shadow. OTOH, if mutter just applied the opacity to the
> MetaWindowActor's priv->actor, and we handled the shadow separately (a la bug
> 635268), then gnome-shell wouldn't need any changes.

My original thought on Dan's comment on bug 635268 was that the approach of clipping the shadow under the window wouldn't work well on this case - that it is dependent on their being a hard frame around the window, but when I tried it out it worked pretty well.

 - It only really makes any sense to set _NET_WM_WINDOW_OPACITY for a decorated window to something that's almost 1.0, otherwise the tilebar will be unreadable.

 - If we fade out the shadow the same amount as the window's contents (which we're doing currently and we continue doing with my attached patch above), you don't get the effect of a dark opaque shadow around a less opaque hole and things look pretty consistent.
Comment 9 Owen Taylor 2011-04-26 16:27:32 UTC
Created attachment 186666 [details] [review]
Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity

Version rebased not to depend on bug 635268
Comment 10 Florian Müllner 2011-04-26 16:47:18 UTC
Review of attachment 186663 [details] [review]:

Looks good.

::: src/compositor/meta-window-actor.c
@@ +434,3 @@
                         G_CALLBACK (window_appears_focused_notify), self);
+
+      clutter_actor_set_opacity (CLUTTER_ACTOR (priv->actor), priv->opacity);

I think both this call and the check for self->priv->actor in update_opacity() would be unnecessary if moving the call to meta_window_actor_update_opacity() below this block.
Comment 11 Florian Müllner 2011-04-26 16:48:19 UTC
Review of attachment 186666 [details] [review]:

Still looking good ;-)
Comment 12 Owen Taylor 2011-04-26 19:11:47 UTC
Created attachment 186683 [details] [review]
Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity

I avoided reordering things with the feeling it might be good to be
just robust against NULL priv->actor in any case, but yeah, that would
be a simpler way to do it. Here it is that way.
Comment 13 Florian Müllner 2011-04-26 20:25:53 UTC
Review of attachment 186683 [details] [review]:

Looks good to me
Comment 14 Owen Taylor 2011-04-27 14:13:39 UTC
Attachment 186683 [details] pushed as c30c29b - Make _NET_WM_WINDOW_OPACITY orthogonal to window actor opacity