win32u: Introduce a new CreateLayeredWindow driver entry.

This commit is contained in:
Rémi Bernon 2024-06-02 12:33:27 +02:00 committed by Alexandre Julliard
parent 8a39b62db6
commit 091883d4b6
12 changed files with 116 additions and 61 deletions

View file

@ -867,8 +867,15 @@ static LRESULT nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
return -1;
}
static BOOL nulldrv_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **surface )
{
*surface = NULL;
return TRUE;
}
static BOOL nulldrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect )
const RECT *window_rect, struct window_surface *surface )
{
return TRUE;
}
@ -1208,10 +1215,16 @@ static void loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
}
static BOOL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect )
static BOOL loaderdrv_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **surface )
{
return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
return load_driver()->pCreateLayeredWindow( hwnd, window_rect, color_key, surface );
}
static BOOL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect, struct window_surface *surface )
{
return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect, surface );
}
static UINT loaderdrv_VulkanInit( UINT version, void *vulkan_handle, const struct vulkan_driver_funcs **driver_funcs )
@ -1278,6 +1291,7 @@ static const struct user_driver_funcs lazy_load_driver =
nulldrv_SetWindowText,
nulldrv_ShowWindow,
nulldrv_SysCommand,
loaderdrv_CreateLayeredWindow,
loaderdrv_UpdateLayeredWindow,
nulldrv_WindowMessage,
nulldrv_WindowPosChanging,
@ -1364,6 +1378,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(SetWindowText);
SET_USER_FUNC(ShowWindow);
SET_USER_FUNC(SysCommand);
SET_USER_FUNC(CreateLayeredWindow);
SET_USER_FUNC(UpdateLayeredWindow);
SET_USER_FUNC(WindowMessage);
SET_USER_FUNC(WindowPosChanging);

View file

@ -2121,9 +2121,11 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *pts_
const BLENDFUNCTION *blend, DWORD flags, const RECT *dirty )
{
DWORD swp_flags = SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW;
struct window_surface *surface;
RECT window_rect, client_rect;
UPDATELAYEREDWINDOWINFO info;
SIZE offset;
BOOL ret;
if (flags & ~(ULW_COLORKEY | ULW_ALPHA | ULW_OPAQUE | ULW_EX_NORESIZE) ||
!(get_window_long( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED) ||
@ -2169,6 +2171,9 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *pts_
apply_window_pos( hwnd, 0, swp_flags, &window_rect, &client_rect, NULL );
if (!(flags & ULW_COLORKEY)) key = CLR_INVALID;
if (!(user_driver->pCreateLayeredWindow( hwnd, &window_rect, key, &surface )) || !surface) return FALSE;
info.cbSize = sizeof(info);
info.hdcDst = hdc_dst;
info.pptDst = pts_dst;
@ -2179,7 +2184,10 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *pts_
info.pblend = blend;
info.dwFlags = flags;
info.prcDirty = dirty;
return user_driver->pUpdateLayeredWindow( hwnd, &info, &window_rect );
ret = user_driver->pUpdateLayeredWindow( hwnd, &info, &window_rect, surface );
window_surface_release( surface );
return ret;
}
/***********************************************************************

View file

@ -98,8 +98,10 @@ extern void ANDROID_SetParent( HWND hwnd, HWND parent, HWND old_parent );
extern void ANDROID_SetCapture( HWND hwnd, UINT flags );
extern void ANDROID_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style );
extern UINT ANDROID_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp );
extern BOOL ANDROID_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **surface );
extern BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect );
const RECT *window_rect, struct window_surface *surface );
extern LRESULT ANDROID_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
extern BOOL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
const RECT *window_rect, const RECT *client_rect,

View file

@ -348,6 +348,7 @@ static const struct user_driver_funcs android_drv_funcs =
.pSetParent = ANDROID_SetParent,
.pSetWindowStyle = ANDROID_SetWindowStyle,
.pShowWindow = ANDROID_ShowWindow,
.pCreateLayeredWindow = ANDROID_CreateLayeredWindow,
.pUpdateLayeredWindow = ANDROID_UpdateLayeredWindow,
.pWindowMessage = ANDROID_WindowMessage,
.pWindowPosChanging = ANDROID_WindowPosChanging,

View file

@ -1383,18 +1383,14 @@ void ANDROID_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DW
/*****************************************************************************
* ANDROID_UpdateLayeredWindow
* ANDROID_CreateLayeredWindow
*/
BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect )
BOOL ANDROID_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **window_surface )
{
struct window_surface *surface;
struct android_win_data *data;
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
COLORREF color_key = (info->dwFlags & ULW_COLORKEY) ? info->crKey : CLR_INVALID;
RECT rect, src_rect;
HDC hdc;
BOOL ret = FALSE;
RECT rect;
if (!(data = get_win_data( hwnd ))) return FALSE;
@ -1416,17 +1412,29 @@ BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info
}
else set_surface_layered( surface, 255, color_key );
if (surface) window_surface_add_ref( surface );
if ((*window_surface = surface)) window_surface_add_ref( surface );
release_win_data( data );
if (!surface) return FALSE;
if (!info->hdcSrc)
{
window_surface_release( surface );
return TRUE;
}
return TRUE;
}
if (!(hdc = NtGdiCreateCompatibleDC( 0 ))) goto done;
/*****************************************************************************
* ANDROID_UpdateLayeredWindow
*/
BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect, struct window_surface *surface )
{
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
RECT rect, src_rect;
HDC hdc;
BOOL ret;
rect = *window_rect;
OffsetRect( &rect, -window_rect->left, -window_rect->top );
if (!info->hdcSrc) return TRUE;
if (!(hdc = NtGdiCreateCompatibleDC( 0 ))) return FALSE;
window_surface_lock( surface );
NtGdiSelectBitmap( hdc, surface->color_bitmap );
@ -1447,8 +1455,6 @@ BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info
window_surface_unlock( surface );
window_surface_flush( surface );
done:
window_surface_release( surface );
return ret;
}

View file

@ -301,6 +301,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pToUnicodeEx = macdrv_ToUnicodeEx,
.pUnregisterHotKey = macdrv_UnregisterHotKey,
.pUpdateClipboard = macdrv_UpdateClipboard,
.pCreateLayeredWindow = macdrv_CreateLayeredWindow,
.pUpdateLayeredWindow = macdrv_UpdateLayeredWindow,
.pVkKeyScanEx = macdrv_VkKeyScanEx,
.pImeProcessKey = macdrv_ImeProcessKey,

View file

@ -145,8 +145,10 @@ extern void macdrv_SetLayeredWindowAttributes(HWND hwnd, COLORREF key, BYTE alph
extern void macdrv_SetWindowText(HWND hwnd, LPCWSTR text);
extern UINT macdrv_ShowWindow(HWND hwnd, INT cmd, RECT *rect, UINT swp);
extern LRESULT macdrv_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam);
extern BOOL macdrv_CreateLayeredWindow(HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **surface);
extern BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect);
const RECT *window_rect, struct window_surface *surface);
extern LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
extern BOOL macdrv_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags,
const RECT *window_rect, const RECT *client_rect,

View file

@ -1863,17 +1863,14 @@ done:
/***********************************************************************
* UpdateLayeredWindow (MACDRV.@)
* CreateLayeredWindow (MACDRV.@)
*/
BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect)
BOOL macdrv_CreateLayeredWindow(HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **window_surface)
{
struct window_surface *surface;
struct macdrv_win_data *data;
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
RECT rect, src_rect;
HDC hdc;
BOOL ret = FALSE;
RECT rect;
if (!(data = get_win_data(hwnd))) return FALSE;
@ -1898,7 +1895,7 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
}
else set_surface_use_alpha(surface, TRUE);
if (surface) window_surface_add_ref(surface);
if ((*window_surface = surface)) window_surface_add_ref(surface);
/* Since layered attributes are now set, can now show the window */
if (data->cocoa_window && !data->on_screen && NtUserGetWindowLongW(hwnd, GWL_STYLE) & WS_VISIBLE)
@ -1906,14 +1903,27 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
release_win_data(data);
if (!surface) return FALSE;
if (!info->hdcSrc)
{
window_surface_release(surface);
return TRUE;
}
return TRUE;
}
if (!(hdc = NtGdiCreateCompatibleDC(0))) goto done;
/***********************************************************************
* UpdateLayeredWindow (MACDRV.@)
*/
BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect, struct window_surface *surface)
{
struct macdrv_win_data *data;
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
RECT rect, src_rect;
HDC hdc;
BOOL ret = FALSE;
rect = *window_rect;
OffsetRect(&rect, -window_rect->left, -window_rect->top);
if (!info->hdcSrc) return TRUE;
if (!(hdc = NtGdiCreateCompatibleDC(0))) return FALSE;
window_surface_lock(surface);
NtGdiSelectBitmap(hdc, surface->color_bitmap);
@ -1943,7 +1953,6 @@ BOOL macdrv_UpdateLayeredWindow(HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
}
done:
window_surface_release(surface);
return ret;
}

View file

@ -420,6 +420,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pSysCommand = X11DRV_SysCommand,
.pClipboardWindowProc = X11DRV_ClipboardWindowProc,
.pUpdateClipboard = X11DRV_UpdateClipboard,
.pCreateLayeredWindow = X11DRV_CreateLayeredWindow,
.pUpdateLayeredWindow = X11DRV_UpdateLayeredWindow,
.pWindowMessage = X11DRV_WindowMessage,
.pWindowPosChanging = X11DRV_WindowPosChanging,

View file

@ -2960,18 +2960,15 @@ void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWO
/*****************************************************************************
* UpdateLayeredWindow (X11DRV.@)
* CreateLayeredWindow (X11DRV.@)
*/
BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect )
BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **window_surface )
{
struct window_surface *surface;
struct x11drv_win_data *data;
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
COLORREF color_key = (info->dwFlags & ULW_COLORKEY) ? info->crKey : CLR_INVALID;
RECT rect, src_rect;
HDC hdc;
BOOL mapped, ret = FALSE;
BOOL mapped;
RECT rect;
if (!(data = get_win_data( hwnd ))) return FALSE;
@ -2991,7 +2988,7 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
}
else set_surface_color_key( surface, color_key );
if (surface) window_surface_add_ref( surface );
if ((*window_surface = surface)) window_surface_add_ref( surface );
mapped = data->mapped;
release_win_data( data );
@ -3004,14 +3001,26 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
map_window( hwnd, style );
}
if (!surface) return FALSE;
if (!info->hdcSrc)
{
window_surface_release( surface );
return TRUE;
}
return TRUE;
}
if (!(hdc = NtGdiCreateCompatibleDC( 0 ))) goto done;
/*****************************************************************************
* UpdateLayeredWindow (X11DRV.@)
*/
BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect, struct window_surface *surface )
{
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, 0 };
RECT rect, src_rect;
HDC hdc;
BOOL ret;
rect = *window_rect;
OffsetRect( &rect, -window_rect->left, -window_rect->top );
if (!info->hdcSrc) return TRUE;
if (!(hdc = NtGdiCreateCompatibleDC( 0 ))) return FALSE;
window_surface_lock( surface );
NtGdiSelectBitmap( hdc, surface->color_bitmap );
@ -3032,8 +3041,6 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
window_surface_unlock( surface );
window_surface_flush( surface );
done:
window_surface_release( surface );
return ret;
}

View file

@ -240,8 +240,10 @@ extern UINT X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp );
extern LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam );
extern LRESULT X11DRV_ClipboardWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
extern void X11DRV_UpdateClipboard(void);
extern BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key,
struct window_surface **surface );
extern BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect );
const RECT *window_rect, struct window_surface *surface );
extern LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp );
extern BOOL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
const RECT *window_rect, const RECT *client_rect, RECT *visible_rect,

View file

@ -336,7 +336,8 @@ struct user_driver_funcs
void (*pSetWindowText)(HWND,LPCWSTR);
UINT (*pShowWindow)(HWND,INT,RECT*,UINT);
LRESULT (*pSysCommand)(HWND,WPARAM,LPARAM);
BOOL (*pUpdateLayeredWindow)(HWND,const struct tagUPDATELAYEREDWINDOWINFO *,const RECT *);
BOOL (*pCreateLayeredWindow)(HWND,const RECT *,COLORREF,struct window_surface **);
BOOL (*pUpdateLayeredWindow)(HWND,const struct tagUPDATELAYEREDWINDOWINFO*,const RECT*,struct window_surface*);
LRESULT (*pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
BOOL (*pWindowPosChanging)(HWND,HWND,UINT,const RECT *,const RECT *,RECT *,
struct window_surface**);