Transparent windows

Vassilis Virvilis vasvir at
Tue Nov 2 17:36:32 CDT 2010

On 02/11/2010 02:12 πμ, Vincent Povirk wrote:
> It is probably a layered window, in which case the following functions
> in user32 are relevant: SetLayeredWindowAttributes,
> GetLayeredWindowAttributes, UpdateLayeredWindowIndirect, and
> UpdateLayeredWindow
> Most of user32 is implemented based on gdi32, wineserver, and
> winex11.drv. When you see USER_Driver in user32, that indicates a
> function in winex11.drv. So USER_Driver->pSetLayeredWindowAttributes
> is really X11DRV_SetLayeredWindowAttributes.
> Wine requires a compositing window manager to implement layered
> windows properly. It does not matter whether the window manager
> provides any 3D effects or uses opengl.

Thank you very much for the directions. They certainly put me on the right track.

WINEDEBUG=+win does the trick and shows relevant information.

My application still displays black instead of transparent.
I took the liberty and augment the trace message with the BLENDFUNCTION struct members
like this
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3531,7 +3531,7 @@ BOOL WINAPI UpdateLayeredWindowIndirect( HWND hwnd, const UPDATELAYEREDWINDOWINF

      if (info->pblend && !(info->dwFlags & ULW_OPAQUE)) alpha = info->pblend->SourceConstantAlpha;
-    TRACE( "setting window %p alpha %u\n", hwnd, alpha );
+    TRACE( "setting window %p alpha %u BlendOp %u, BlendFlags %x SourceConstantAlpha %u AlphaFormat %x \n", hwnd, alpha, info->pblend->BlendOp, info->pblend->BlendFlags, info->pblend->SourceConstantAlpha, info->pblend->AlphaFormat);
      USER_Driver->pSetLayeredWindowAttributes( hwnd, info->crKey, alpha,
                                                info->dwFlags & (LWA_ALPHA | LWA_COLORKEY) );
      return TRUE;

and I got output like this

trace:win:UpdateLayeredWindowIndirect setting window 0x10060 alpha 255 BlendOp 0, BlendFlags 0 SourceConstantAlpha 255 AlphaFormat 1

The BLENDFUNCTION structure is documented in MSDN
and is defined in include/wingdi.h

So from MSDN
	BlendOp = 0 == AC_SRC_OVER (the only option)
	BlendFlags = 0 (the only option)
	SourceConstantAlpha = 255 = 0xff
	AlphaFormat = 1 == AC_SRC_ALPHA (the only option)

then the documentation branches depending on
	if the SourceConstantAlpha is 0xff or not,
	if there is source alpha
	if there is destination alpha.

Just to be sure I hardcoded another value for SourceConstantAlpha and I did get some kind of transparency but not the right kind :-(

Is it possible that wine's implementation has a bug in the alpha blending handling in some subcase?

It is late now. I will hunt it down some more tomorrow.


More information about the wine-devel mailing list