Commit be3c3a52 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Driver-side implementation of SetLayeredWindowAttributes.

Based on a patch by Rob Shearman.
parent 9fb76ddd
...@@ -382,6 +382,28 @@ static void sync_window_region( Display *display, struct x11drv_win_data *data, ...@@ -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 * sync_window_text
*/ */
static void sync_window_text( Display *display, Window win, const WCHAR *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 ...@@ -1340,6 +1362,9 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
int cx, cy, mask; int cx, cy, mask;
XSetWindowAttributes attr; XSetWindowAttributes attr;
WCHAR text[1024]; WCHAR text[1024];
COLORREF key;
BYTE alpha;
DWORD layered_flags;
if (!(cx = data->window_rect.right - data->window_rect.left)) cx = 1; if (!(cx = data->window_rect.right - data->window_rect.left)) cx = 1;
if (!(cy = data->window_rect.bottom - data->window_rect.top)) cy = 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 ...@@ -1389,6 +1414,10 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
/* set the window region */ /* set the window region */
sync_window_region( display, data, (HRGN)1 ); 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(); wine_tsx11_lock();
XFlush( display ); /* make sure the window exists before we start painting to it */ XFlush( display ); /* make sure the window exists before we start painting to it */
wine_tsx11_unlock(); wine_tsx11_unlock();
...@@ -1488,6 +1517,13 @@ void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style ) ...@@ -1488,6 +1517,13 @@ void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
wine_tsx11_unlock(); 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 ) ...@@ -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.@) * X11DRV_WindowMessage (X11DRV.@)
*/ */
......
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
@ cdecl SetClipboardData(long long long long) X11DRV_SetClipboardData @ cdecl SetClipboardData(long long long long) X11DRV_SetClipboardData
@ cdecl SetCapture(long long) X11DRV_SetCapture @ cdecl SetCapture(long long) X11DRV_SetCapture
@ cdecl SetFocus(long) X11DRV_SetFocus @ cdecl SetFocus(long) X11DRV_SetFocus
@ cdecl SetLayeredWindowAttributes(long long long long) X11DRV_SetLayeredWindowAttributes
@ cdecl SetParent(long long long) X11DRV_SetParent @ cdecl SetParent(long long long) X11DRV_SetParent
@ cdecl SetWindowIcon(long long long) X11DRV_SetWindowIcon @ cdecl SetWindowIcon(long long long) X11DRV_SetWindowIcon
@ cdecl SetWindowRgn(long long long) X11DRV_SetWindowRgn @ cdecl SetWindowRgn(long long long) X11DRV_SetWindowRgn
......
...@@ -609,6 +609,7 @@ enum x11drv_atoms ...@@ -609,6 +609,7 @@ enum x11drv_atoms
XATOM__NET_WM_STATE_MAXIMIZED_VERT, XATOM__NET_WM_STATE_MAXIMIZED_VERT,
XATOM__NET_WM_STATE_SKIP_PAGER, XATOM__NET_WM_STATE_SKIP_PAGER,
XATOM__NET_WM_STATE_SKIP_TASKBAR, XATOM__NET_WM_STATE_SKIP_TASKBAR,
XATOM__NET_WM_WINDOW_OPACITY,
XATOM__NET_WM_WINDOW_TYPE, XATOM__NET_WM_WINDOW_TYPE,
XATOM__NET_WM_WINDOW_TYPE_DIALOG, XATOM__NET_WM_WINDOW_TYPE_DIALOG,
XATOM__NET_WM_WINDOW_TYPE_NORMAL, XATOM__NET_WM_WINDOW_TYPE_NORMAL,
......
...@@ -145,6 +145,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] = ...@@ -145,6 +145,7 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_SKIP_PAGER", "_NET_WM_STATE_SKIP_PAGER",
"_NET_WM_STATE_SKIP_TASKBAR", "_NET_WM_STATE_SKIP_TASKBAR",
"_NET_WM_WINDOW_OPACITY",
"_NET_WM_WINDOW_TYPE", "_NET_WM_WINDOW_TYPE",
"_NET_WM_WINDOW_TYPE_DIALOG", "_NET_WM_WINDOW_TYPE_DIALOG",
"_NET_WM_WINDOW_TYPE_NORMAL", "_NET_WM_WINDOW_TYPE_NORMAL",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment