Jacek Caban : win32u: Move NtUserWindowFromDC implementation from user32.
Alexandre Julliard
julliard at winehq.org
Mon Mar 14 17:47:37 CDT 2022
Module: wine
Branch: master
Commit: e411d919580b7bc72c6a86b03d8a4dbbbc567f6d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e411d919580b7bc72c6a86b03d8a4dbbbc567f6d
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Mar 14 11:43:32 2022 +0100
win32u: Move NtUserWindowFromDC implementation from user32.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/painting.c | 27 ---------------------------
dlls/user32/user32.spec | 2 +-
dlls/user32/user_main.c | 1 -
dlls/win32u/Makefile.in | 1 +
dlls/win32u/dce.c | 42 ++++++++++++++++++++++++++++++++++++++++++
dlls/win32u/ntuser_private.h | 13 ++++++++++++-
dlls/win32u/palette.c | 9 +++------
dlls/win32u/syscall.c | 1 +
dlls/win32u/win32u.spec | 2 +-
dlls/wow64win/syscall.h | 3 ++-
dlls/wow64win/user.c | 7 +++++++
include/ntuser.h | 1 +
12 files changed, 71 insertions(+), 38 deletions(-)
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c
index 96a06fe98c7..2f8ab9b81f8 100644
--- a/dlls/user32/painting.c
+++ b/dlls/user32/painting.c
@@ -35,17 +35,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
-struct dce
-{
- struct list entry; /* entry in global DCE list */
- HDC hdc;
- HWND hwnd;
- HRGN clip_rgn;
- DWORD flags;
- LONG count; /* usage count; 0 or 1 for cache DCEs, always 1 for window DCEs,
- always >= 1 for class DCEs */
-};
-
static struct list dce_list = LIST_INIT(dce_list);
#define DCE_CACHE_SIZE 64
@@ -1164,22 +1153,6 @@ INT WINAPI ReleaseDC( HWND hwnd, HDC hdc )
}
-/**********************************************************************
- * WindowFromDC (USER32.@)
- */
-HWND WINAPI WindowFromDC( HDC hdc )
-{
- struct dce *dce;
- HWND hwnd = 0;
-
- USER_Lock();
- dce = (struct dce *)GetDCHook( hdc, NULL );
- if (dce) hwnd = dce->hwnd;
- USER_Unlock();
- return hwnd;
-}
-
-
/***********************************************************************
* LockWindowUpdate (USER32.@)
*
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec
index 4c4e795c34a..aac2e39fa6d 100644
--- a/dlls/user32/user32.spec
+++ b/dlls/user32/user32.spec
@@ -818,7 +818,7 @@
@ stdcall WinHelpA(long str long long)
@ stdcall WinHelpW(long wstr long long)
# @ stub WinOldAppHackoMatic
-@ stdcall WindowFromDC(long)
+@ stdcall WindowFromDC(long) NtUserWindowFromDC
@ stdcall WindowFromPoint(int64)
@ stdcall WindowFromPhysicalPoint(int64)
# @ stub YieldTask
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 2ef7b3f01d0..ba7462ee241 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -151,7 +151,6 @@ static const struct user_callbacks user_funcs =
SendNotifyMessageW,
SetWindowPos,
WaitForInputIdle,
- WindowFromDC,
free_dce,
notify_ime,
register_builtin_classes,
diff --git a/dlls/win32u/Makefile.in b/dlls/win32u/Makefile.in
index ceb8f83eb97..2dea3682064 100644
--- a/dlls/win32u/Makefile.in
+++ b/dlls/win32u/Makefile.in
@@ -17,6 +17,7 @@ C_SRCS = \
clipping.c \
cursoricon.c \
dc.c \
+ dce.c \
dib.c \
dibdrv/bitblt.c \
dibdrv/dc.c \
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c
new file mode 100644
index 00000000000..a811f7eae7f
--- /dev/null
+++ b/dlls/win32u/dce.c
@@ -0,0 +1,42 @@
+/*
+ * Window painting functions
+ *
+ * Copyright 1993, 1994, 1995, 2001, 2004, 2005, 2008 Alexandre Julliard
+ * Copyright 1996, 1997, 1999 Alex Korobka
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#if 0
+#pragma makedep unix
+#endif
+
+#include "ntgdi_private.h"
+#include "ntuser_private.h"
+
+/**********************************************************************
+ * NtUserWindowFromDC (win32u.@)
+ */
+HWND WINAPI NtUserWindowFromDC( HDC hdc )
+{
+ struct dce *dce;
+ HWND hwnd = 0;
+
+ user_lock();
+ dce = (struct dce *)GetDCHook( hdc, NULL );
+ if (dce) hwnd = dce->hwnd;
+ user_unlock();
+ return hwnd;
+}
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index 6c10a3e77e1..160e3ab5f14 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -38,7 +38,6 @@ struct user_callbacks
BOOL (WINAPI *pSendNotifyMessageW)( HWND, UINT, WPARAM, LPARAM );
BOOL (WINAPI *pSetWindowPos)( HWND, HWND, INT, INT, INT, INT, UINT );
DWORD (WINAPI *pWaitForInputIdle)( HANDLE, DWORD );
- HWND (WINAPI *pWindowFromDC)( HDC );
void (WINAPI *free_dce)( struct dce *dce, HWND hwnd );
void (CDECL *notify_ime)( HWND hwnd, UINT param );
void (CDECL *register_builtin_classes)(void);
@@ -196,6 +195,18 @@ typedef struct tagWINDOWPROC
#define MAX_ATOM_LEN 255
+/* FIXME: make it private to dce.c */
+struct dce
+{
+ struct list entry; /* entry in global DCE list */
+ HDC hdc;
+ HWND hwnd;
+ HRGN clip_rgn;
+ DWORD flags;
+ LONG count; /* usage count; 0 or 1 for cache DCEs, always 1 for window DCEs,
+ always >= 1 for class DCEs */
+};
+
/* Built-in class names (see _Undocumented_Windows_ p.418) */
#define POPUPMENU_CLASS_ATOM MAKEINTATOM(32768) /* PopupMenu */
#define DESKTOP_CLASS_ATOM MAKEINTATOM(32769) /* Desktop */
diff --git a/dlls/win32u/palette.c b/dlls/win32u/palette.c
index 367bfea21b4..18885c7fba8 100644
--- a/dlls/win32u/palette.c
+++ b/dlls/win32u/palette.c
@@ -516,7 +516,7 @@ HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE hpal, WORD bkg )
if (!bkg && hpal != get_stock_object( DEFAULT_PALETTE ))
{
- HWND hwnd = user_callbacks->pWindowFromDC( hdc );
+ HWND hwnd = NtUserWindowFromDC( hdc );
if (hwnd)
{
/* set primary palette if it's related to current active */
@@ -582,7 +582,7 @@ UINT realize_palette( HDC hdc )
if (realized && is_primary)
{
/* send palette change notification */
- HWND hwnd = user_callbacks->pWindowFromDC( hdc );
+ HWND hwnd = NtUserWindowFromDC( hdc );
if (hwnd) user_callbacks->pSendMessageTimeoutW( HWND_BROADCAST, WM_PALETTECHANGED,
HandleToUlong(hwnd), 0, SMTO_ABORTIFHUNG,
2000, NULL );
@@ -591,9 +591,6 @@ UINT realize_palette( HDC hdc )
}
-typedef HWND (WINAPI *WindowFromDC_funcptr)( HDC );
-typedef BOOL (WINAPI *RedrawWindow_funcptr)( HWND, const RECT *, HRGN, UINT );
-
/**********************************************************************
* NtGdiUpdateColors (win32u.@)
*
@@ -607,7 +604,7 @@ BOOL WINAPI NtGdiUpdateColors( HDC hDC )
if (!size) return FALSE;
if (!user_callbacks) return TRUE;
- hwnd = user_callbacks->pWindowFromDC( hDC );
+ hwnd = NtUserWindowFromDC( hDC );
/* Docs say that we have to remap current drawable pixel by pixel
* but it would take forever given the speed of XGet/PutPixel.
diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c
index 41f9cfead49..abe32b8d70c 100644
--- a/dlls/win32u/syscall.c
+++ b/dlls/win32u/syscall.c
@@ -158,6 +158,7 @@ static void * const syscalls[] =
NtUserSetWindowsHookEx,
NtUserUnhookWinEvent,
NtUserUnhookWindowsHookEx,
+ NtUserWindowFromDC,
};
static BYTE arguments[ARRAY_SIZE(syscalls)];
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 671d26f6805..7238e729e79 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -1309,7 +1309,7 @@
@ stub NtUserWaitForMsgAndEvent
@ stub NtUserWaitForRedirectionStartComplete
@ stub NtUserWaitMessage
-@ stub NtUserWindowFromDC
+@ stdcall -syscall NtUserWindowFromDC(long)
@ stub NtUserWindowFromPhysicalPoint
@ stdcall NtUserWindowFromPoint(long long)
@ stub NtUserYieldTask
diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h
index 82262cd83ab..b6cdf5edfb2 100644
--- a/dlls/wow64win/syscall.h
+++ b/dlls/wow64win/syscall.h
@@ -142,6 +142,7 @@
SYSCALL_ENTRY( NtUserSetWinEventHook ) \
SYSCALL_ENTRY( NtUserSetWindowsHookEx ) \
SYSCALL_ENTRY( NtUserUnhookWinEvent ) \
- SYSCALL_ENTRY( NtUserUnhookWindowsHookEx )
+ SYSCALL_ENTRY( NtUserUnhookWindowsHookEx ) \
+ SYSCALL_ENTRY( NtUserWindowFromDC )
#endif /* __WOW64WIN_SYSCALL_H */
diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c
index 4ee05838b47..b8c4a86a352 100644
--- a/dlls/wow64win/user.c
+++ b/dlls/wow64win/user.c
@@ -206,6 +206,13 @@ NTSTATUS WINAPI wow64_NtUserGetWindowRgnEx( UINT *args )
return NtUserGetWindowRgnEx( hwnd, hrgn, unk );
}
+NTSTATUS WINAPI wow64_NtUserWindowFromDC( UINT *args )
+{
+ HDC hdc = get_handle( &args );
+
+ return HandleToUlong( NtUserWindowFromDC( hdc ));
+}
+
NTSTATUS WINAPI wow64_NtUserBuildHwndList( UINT *args )
{
HDESK desktop = get_handle( &args );
diff --git a/include/ntuser.h b/include/ntuser.h
index 28a025059f6..fb8db926888 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -407,6 +407,7 @@ BOOL WINAPI NtUserUpdateLayeredWindow( HWND hwnd, HDC hdc_dst, const POINT *p
const BLENDFUNCTION *blend, DWORD flags, const RECT *dirty );
WORD WINAPI NtUserVkKeyScanEx( WCHAR chr, HKL layout );
DWORD WINAPI NtUserWaitForInputIdle( HANDLE process, DWORD timeout, BOOL wow );
+HWND WINAPI NtUserWindowFromDC( HDC hdc );
HWND WINAPI NtUserWindowFromPoint( LONG x, LONG y );
#endif /* _NTUSER_ */
More information about the wine-cvs
mailing list