Alexandre Julliard : winex11: Driver-side implementation of SetLayeredWindowAttributes.
Alexandre Julliard
julliard at winehq.org
Mon Sep 15 06:53:59 CDT 2008
Module: wine
Branch: master
Commit: be3c3a52141e100075c11896ac96e50736411ae3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=be3c3a52141e100075c11896ac96e50736411ae3
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Sep 12 15:54:02 2008 +0200
winex11: Driver-side implementation of SetLayeredWindowAttributes.
Based on a patch by Rob Shearman.
---
dlls/winex11.drv/window.c | 49 +++++++++++++++++++++++++++++++++++++
dlls/winex11.drv/winex11.drv.spec | 1 +
dlls/winex11.drv/x11drv.h | 1 +
dlls/winex11.drv/x11drv_main.c | 1 +
4 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 0ba15e2..bd370f6 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -382,6 +382,28 @@ static void sync_window_region( Display *display, struct x11drv_win_data *data,
/***********************************************************************
+ * sync_window_opacity
+ */
+static void sync_window_opacity( Display *display, Window win,
+ COLORREF key, BYTE alpha, DWORD flags )
+{
+ unsigned long opacity = 0xffffffff;
+
+ if (flags & LWA_ALPHA) opacity = (0xffffffff / 0xff) * alpha;
+
+ if (flags & LWA_COLORKEY) FIXME("LWA_COLORKEY not supported\n");
+
+ wine_tsx11_lock();
+ if (opacity == 0xffffffff)
+ XDeleteProperty( display, win, x11drv_atom(_NET_WM_WINDOW_OPACITY) );
+ else
+ XChangeProperty( display, win, x11drv_atom(_NET_WM_WINDOW_OPACITY),
+ XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&opacity, 1 );
+ wine_tsx11_unlock();
+}
+
+
+/***********************************************************************
* sync_window_text
*/
static void sync_window_text( Display *display, Window win, const WCHAR *text )
@@ -1340,6 +1362,9 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
int cx, cy, mask;
XSetWindowAttributes attr;
WCHAR text[1024];
+ COLORREF key;
+ BYTE alpha;
+ DWORD layered_flags;
if (!(cx = data->window_rect.right - data->window_rect.left)) cx = 1;
if (!(cy = data->window_rect.bottom - data->window_rect.top)) cy = 1;
@@ -1389,6 +1414,10 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
/* set the window region */
sync_window_region( display, data, (HRGN)1 );
+ /* set the window opacity */
+ if (!GetLayeredWindowAttributes( data->hwnd, &key, &alpha, &layered_flags )) layered_flags = 0;
+ sync_window_opacity( display, data->whole_window, key, alpha, layered_flags );
+
wine_tsx11_lock();
XFlush( display ); /* make sure the window exists before we start painting to it */
wine_tsx11_unlock();
@@ -1488,6 +1517,13 @@ void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
wine_tsx11_unlock();
}
}
+
+ if (offset == GWL_EXSTYLE && (changed & WS_EX_LAYERED))
+ {
+ /* changing WS_EX_LAYERED resets attributes */
+ if ((data = X11DRV_get_win_data( hwnd )) && data->whole_window)
+ sync_window_opacity( thread_display(), data->whole_window, 0, 0, 0 );
+ }
}
@@ -2158,6 +2194,19 @@ int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
}
+/***********************************************************************
+ * SetLayeredWindowAttributes (X11DRV.@)
+ *
+ * Set transparency attributes for a layered window.
+ */
+void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
+{
+ Window win = X11DRV_get_whole_window( hwnd );
+
+ if (win) sync_window_opacity( thread_display(), win, key, alpha, flags );
+}
+
+
/**********************************************************************
* X11DRV_WindowMessage (X11DRV.@)
*/
diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index 39dcc8e..7cafaac 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -106,6 +106,7 @@
@ cdecl SetClipboardData(long long long long) X11DRV_SetClipboardData
@ cdecl SetCapture(long long) X11DRV_SetCapture
@ cdecl SetFocus(long) X11DRV_SetFocus
+@ cdecl SetLayeredWindowAttributes(long long long long) X11DRV_SetLayeredWindowAttributes
@ cdecl SetParent(long long long) X11DRV_SetParent
@ cdecl SetWindowIcon(long long long) X11DRV_SetWindowIcon
@ cdecl SetWindowRgn(long long long) X11DRV_SetWindowRgn
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 7ed91b3..f35ae5a 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -609,6 +609,7 @@ enum x11drv_atoms
XATOM__NET_WM_STATE_MAXIMIZED_VERT,
XATOM__NET_WM_STATE_SKIP_PAGER,
XATOM__NET_WM_STATE_SKIP_TASKBAR,
+ XATOM__NET_WM_WINDOW_OPACITY,
XATOM__NET_WM_WINDOW_TYPE,
XATOM__NET_WM_WINDOW_TYPE_DIALOG,
XATOM__NET_WM_WINDOW_TYPE_NORMAL,
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index 2e19913..25a86f0 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -145,6 +145,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_SKIP_PAGER",
"_NET_WM_STATE_SKIP_TASKBAR",
+ "_NET_WM_WINDOW_OPACITY",
"_NET_WM_WINDOW_TYPE",
"_NET_WM_WINDOW_TYPE_DIALOG",
"_NET_WM_WINDOW_TYPE_NORMAL",
More information about the wine-cvs
mailing list