Alexandre Julliard : user32: Use the generic handle functions for windows too.
Alexandre Julliard
julliard at winehq.org
Mon Oct 12 11:19:47 CDT 2009
Module: wine
Branch: master
Commit: 4bb95f4d0f10f3f27b36fab2fddb6fad74e9fd82
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4bb95f4d0f10f3f27b36fab2fddb6fad74e9fd82
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Oct 12 14:29:34 2009 +0200
user32: Use the generic handle functions for windows too.
---
dlls/user32/nonclient.c | 10 ++++----
dlls/user32/win.c | 53 +++++++++++++++-------------------------------
dlls/user32/win.h | 5 +--
dlls/user32/winpos.c | 2 +-
4 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c
index 03831a3..ccea517 100644
--- a/dlls/user32/nonclient.c
+++ b/dlls/user32/nonclient.c
@@ -533,17 +533,17 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
RECT rect, rcClient;
POINT ptClient;
- TRACE("hwnd=%p pt=%d,%d\n", wndPtr->hwndSelf, pt.x, pt.y );
+ TRACE("hwnd=%p pt=%d,%d\n", wndPtr->obj.handle, pt.x, pt.y );
- GetWindowRect(wndPtr->hwndSelf, &rect );
+ GetWindowRect(wndPtr->obj.handle, &rect );
if (!PtInRect( &rect, pt )) return HTNOWHERE;
if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
/* Check client area */
ptClient = pt;
- ScreenToClient( wndPtr->hwndSelf, &ptClient );
- GetClientRect( wndPtr->hwndSelf, &rcClient );
+ ScreenToClient( wndPtr->obj.handle, &ptClient );
+ GetClientRect( wndPtr->obj.handle, &rcClient );
if (PtInRect( &rcClient, ptClient )) return HTCLIENT;
/* Check borders */
@@ -606,7 +606,7 @@ static LRESULT NC_DoNCHitTest (WND *wndPtr, POINT pt )
/* Check system menu */
if ((wndPtr->dwStyle & WS_SYSMENU) && !(wndPtr->dwExStyle & WS_EX_TOOLWINDOW))
{
- if (NC_IconForWindow(wndPtr->hwndSelf))
+ if (NC_IconForWindow(wndPtr->obj.handle))
rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
}
if (pt.x < rect.left) return HTSYSMENU;
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 28ea841..be40018 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -250,12 +250,12 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name,
index = USER_HANDLE_TO_INDEX(handle);
assert( index < NB_USER_HANDLES );
user_handles[index] = win;
- win->hwndSelf = handle;
+ win->obj.handle = handle;
+ win->obj.type = USER_WINDOW;
win->parent = full_parent;
win->owner = full_owner;
win->class = class;
win->winproc = get_class_winproc( class );
- win->dwMagic = WND_MAGIC;
win->cbWndExtra = extra_bytes;
if (WINPROC_IsUnicode( win->winproc, unicode )) win->flags |= WIN_ISUNICODE;
return win;
@@ -267,31 +267,23 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name,
*
* Free a window handle.
*/
-static WND *free_window_handle( HWND hwnd )
+static void free_window_handle( HWND hwnd )
{
- WND *ptr;
+ struct user_object *ptr;
WORD index = USER_HANDLE_TO_INDEX(hwnd);
- if (index >= NB_USER_HANDLES) return NULL;
- USER_Lock();
- if ((ptr = user_handles[index]))
+ if ((ptr = get_user_handle_ptr( hwnd, USER_WINDOW )) && ptr != OBJ_OTHER_PROCESS)
{
SERVER_START_REQ( destroy_window )
{
req->handle = wine_server_user_handle( hwnd );
- if (!wine_server_call_err( req ))
- {
- user_handles[index] = NULL;
- ptr->dwMagic = 0;
- }
- else
- ptr = NULL;
+ if (!wine_server_call_err( req )) user_handles[index] = NULL;
+ else ptr = NULL;
}
SERVER_END_REQ;
+ release_user_handle_ptr( ptr );
+ HeapFree( GetProcessHeap(), 0, ptr );
}
- USER_Unlock();
- HeapFree( GetProcessHeap(), 0, ptr );
- return ptr;
}
@@ -494,22 +486,12 @@ BOOL is_desktop_window( HWND hwnd )
*/
WND *WIN_GetPtr( HWND hwnd )
{
- WND * ptr;
- WORD index = USER_HANDLE_TO_INDEX(hwnd);
-
- if (index >= NB_USER_HANDLES) return NULL;
+ WND *ptr;
- USER_Lock();
- if ((ptr = user_handles[index]))
+ if ((ptr = get_user_handle_ptr( hwnd, USER_WINDOW )) == WND_OTHER_PROCESS)
{
- if (ptr->dwMagic == WND_MAGIC &&
- (hwnd == ptr->hwndSelf || !HIWORD(hwnd) || HIWORD(hwnd) == 0xffff))
- return ptr;
- ptr = NULL;
+ if (is_desktop_window( hwnd )) ptr = WND_DESKTOP;
}
- else if (is_desktop_window( hwnd )) ptr = WND_DESKTOP;
- else ptr = WND_OTHER_PROCESS;
- USER_Unlock();
return ptr;
}
@@ -525,7 +507,7 @@ HWND WIN_IsCurrentProcess( HWND hwnd )
HWND ret;
if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0;
- ret = ptr->hwndSelf;
+ ret = ptr->obj.handle;
WIN_ReleasePtr( ptr );
return ret;
}
@@ -542,7 +524,7 @@ HWND WIN_IsCurrentThread( HWND hwnd )
HWND ret = 0;
if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0;
- if (ptr->tid == GetCurrentThreadId()) ret = ptr->hwndSelf;
+ if (ptr->tid == GetCurrentThreadId()) ret = ptr->obj.handle;
WIN_ReleasePtr( ptr );
return ret;
}
@@ -572,7 +554,7 @@ HWND WIN_Handle32( HWND16 hwnd16 )
if (ptr != WND_OTHER_PROCESS)
{
- hwnd = ptr->hwndSelf;
+ hwnd = ptr->obj.handle;
WIN_ReleasePtr( ptr );
}
else /* may belong to another process */
@@ -832,7 +814,6 @@ static void destroy_thread_window( HWND hwnd )
sys_menu = wndPtr->hSysMenu;
free_dce( wndPtr->dce, hwnd );
user_handles[index] = NULL;
- wndPtr->dwMagic = 0;
}
USER_Unlock();
@@ -1219,7 +1200,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, LPCWSTR className, UINT flags
if (!(wndPtr = create_window_handle( parent, owner, className, cs->hInstance, unicode )))
return 0;
- hwnd = wndPtr->hwndSelf;
+ hwnd = wndPtr->obj.handle;
/* Fill the window structure */
@@ -3305,7 +3286,7 @@ BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert )
wndPtr = WIN_GetPtr(hWnd);
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
- hWnd = wndPtr->hwndSelf; /* make it a full handle */
+ hWnd = wndPtr->obj.handle; /* make it a full handle */
if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED);
else wparam = (hWnd == GetForegroundWindow());
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index 5cd879a..743c67e 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -28,20 +28,19 @@
#include <winuser.h>
#include <wine/windef16.h>
-#define WND_MAGIC 0x444e4957 /* 'WIND' */
+#include "user_private.h"
struct tagCLASS;
struct tagDIALOGINFO;
typedef struct tagWND
{
- HWND hwndSelf; /* Handle of this window */
+ struct user_object obj; /* object header */
HWND parent; /* Window parent */
HWND owner; /* Window owner */
struct tagCLASS *class; /* Window class */
struct dce *dce; /* DCE pointer */
WNDPROC winproc; /* Window procedure */
- DWORD dwMagic; /* Magic number (must be WND_MAGIC) */
DWORD tid; /* Owner thread id */
HINSTANCE hInstance; /* Window hInstance (from CreateWindow) */
RECT rectClient; /* Client area rel. to parent client area */
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index 72532de..c62fdaa 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -1790,7 +1790,7 @@ static BOOL fixup_flags( WINDOWPOS *winpos )
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return FALSE;
}
- winpos->hwnd = wndPtr->hwndSelf; /* make it a full handle */
+ winpos->hwnd = wndPtr->obj.handle; /* make it a full handle */
/* Finally make sure that all coordinates are valid */
if (winpos->x < -32768) winpos->x = -32768;
More information about the wine-cvs
mailing list