Commit 039603c7 authored by Alexandre Julliard's avatar Alexandre Julliard

Don't maintain a client-side WND structure for the desktop window.

Made WIN_GetPtr return WND_DESKTOP in that case.
parent bf0f6a22
......@@ -109,6 +109,7 @@ static BOOL set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
ret = !wine_server_call( req );
}
SERVER_END_REQ;
if (win == WND_DESKTOP) return ret;
if (ret)
{
win->rectWindow = *rectWindow;
......
......@@ -319,7 +319,7 @@ static HMENU get_win_sys_menu( HWND hwnd )
{
HMENU ret = 0;
WND *win = WIN_GetPtr( hwnd );
if (win && win != WND_OTHER_PROCESS)
if (win && win != WND_OTHER_PROCESS && win != WND_DESKTOP)
{
ret = win->hSysMenu;
WIN_ReleasePtr( win );
......@@ -3667,6 +3667,7 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
WND *wndPtr = WIN_GetPtr( hWnd );
HMENU retvalue = 0;
if (wndPtr == WND_DESKTOP) return 0;
if (wndPtr == WND_OTHER_PROCESS)
{
if (IsWindow( hWnd )) FIXME( "not supported on other process window %p\n", hWnd );
......@@ -3724,7 +3725,7 @@ BOOL WINAPI SetSystemMenu( HWND hwnd, HMENU hMenu )
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (wndPtr && wndPtr != WND_OTHER_PROCESS)
if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{
if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu );
......
......@@ -2867,7 +2867,7 @@ LONG WINAPI DispatchMessageA( const MSG* msg )
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS)
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
......@@ -2942,7 +2942,7 @@ LONG WINAPI DispatchMessageW( const MSG* msg )
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS)
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
......
......@@ -363,11 +363,10 @@ LONG WINAPI DispatchMessage16( const MSG16* msg )
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS)
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
if (IsWindow( hwnd ))
ERR( "cannot dispatch msg to other process window %p\n", hwnd );
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
if (IsWindow( hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
winproc = (WNDPROC16)wndPtr->winproc;
......
......@@ -188,7 +188,7 @@ static HRGN send_ncpaint( HWND hwnd, HWND *child, UINT *flags )
INT type;
WND *win = WIN_GetPtr( hwnd );
if (!win || win == WND_OTHER_PROCESS)
if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP)
{
DeleteObject( whole_rgn );
return 0;
......
......@@ -152,7 +152,7 @@ static SCROLLBAR_INFO *SCROLL_GetInternalInfo( HWND hwnd, INT nBar, BOOL alloc )
SCROLLBAR_INFO *infoPtr = NULL;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return NULL;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return NULL;
switch(nBar)
{
case SB_HORZ: infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll; break;
......@@ -201,7 +201,7 @@ static BOOL SCROLL_GetScrollBarRect( HWND hwnd, INT nBar, RECT *lprect,
BOOL vertical;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return FALSE;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
switch(nBar)
{
......@@ -1069,7 +1069,7 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
if (scrollbar != SB_CTL)
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return;
xoffset = wndPtr->rectClient.left - wndPtr->rectWindow.left;
yoffset = wndPtr->rectClient.top - wndPtr->rectWindow.top;
WIN_ReleasePtr( wndPtr );
......
......@@ -66,18 +66,12 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
Display *display;
MSG msg;
HWND hwnd;
WND *win;
Atom atom = x11drv_atom(WM_DELETE_WINDOW);
NtCurrentTeb()->driver_data = driver_data;
display = thread_display();
hwnd = GetDesktopWindow();
/* patch the desktop window queue to point to our queue */
win = WIN_GetPtr( hwnd );
win->tid = GetCurrentThreadId();
WIN_ReleasePtr( win );
SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_winproc );
wine_tsx11_lock();
XSaveContext( display, root_window, winContext, (char *)hwnd );
......
......@@ -724,7 +724,6 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
if (IsWindow( hwnd )) ERR( "cannot set rectangles of other process window %p\n", hwnd );
return FALSE;
}
old_style = win->dwStyle;
SERVER_START_REQ( set_window_pos )
{
req->handle = hwnd;
......@@ -749,6 +748,8 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
}
SERVER_END_REQ;
if (win == WND_DESKTOP) return ret;
if (ret)
{
Display *display = thread_display();
......@@ -765,6 +766,7 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
win->rectWindow = *rectWindow;
win->rectClient = *rectClient;
old_style = win->dwStyle;
win->dwStyle = new_style;
data->window_rect = *rectWindow;
......@@ -1090,6 +1092,7 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
RECT newPos = {0, 0, 0, 0};
UINT swp = 0;
if (hwnd == GetDesktopWindow()) return FALSE;
TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible);
......
......@@ -106,6 +106,7 @@ inline static void WIN_ReleasePtr( WND *ptr )
}
#define WND_OTHER_PROCESS ((WND *)1) /* returned by WIN_GetPtr on unknown window handles */
#define WND_DESKTOP ((WND *)2) /* returned by WIN_GetPtr on the desktop window */
extern LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL unicode );
......
......@@ -65,7 +65,6 @@ typedef struct tagCLASS
} CLASS;
static struct list class_list = LIST_INIT( class_list );
static CLASS *desktop_class;
#define CLASS_OTHER_PROCESS ((CLASS *)1)
......@@ -78,8 +77,9 @@ static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
if (ptr)
{
if (ptr != WND_OTHER_PROCESS) return ptr->class;
if (write_access && IsWindow( hwnd )) /* check other processes */
if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP) return ptr->class;
if (write_access && (ptr == WND_DESKTOP || IsWindow( hwnd ))) /* check other processes */
{
/* modifying classes in other processes is not allowed */
SetLastError( ERROR_ACCESS_DENIED );
......@@ -476,7 +476,7 @@ void CLASS_RegisterBuiltinClasses(void)
extern const struct builtin_class_descr SCROLL_builtin_class;
extern const struct builtin_class_descr STATIC_builtin_class;
desktop_class = register_builtin( &DESKTOP_builtin_class );
register_builtin( &DESKTOP_builtin_class );
register_builtin( &BUTTON_builtin_class );
register_builtin( &COMBO_builtin_class );
register_builtin( &COMBOLBOX_builtin_class );
......@@ -499,8 +499,6 @@ void CLASS_RegisterBuiltinClasses(void)
*/
void CLASS_AddWindow( CLASS *class, WND *win, WINDOWPROCTYPE type )
{
if (!class) class = desktop_class;
if (type == WIN_PROC_32W)
{
if (!(win->winproc = class->winprocW)) win->winproc = class->winprocA;
......
......@@ -349,7 +349,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
else hwnd = WIN_GetFullHandle( hwnd );
if (!(wndPtr = WIN_GetPtr( hwnd ))) return 0;
if (wndPtr == WND_OTHER_PROCESS)
if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{
wndPtr = NULL;
USER_Lock();
......
......@@ -359,7 +359,7 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create )
dlgInfo->flags = 0;
dlgInfo->hDialogHeap = 0;
wndPtr = WIN_GetPtr( hwnd );
if (wndPtr && wndPtr != WND_OTHER_PROCESS)
if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{
wndPtr->flags |= WIN_ISDIALOG;
WIN_ReleasePtr( wndPtr );
......
......@@ -997,7 +997,7 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
if (!hParent) break;
pParent = WIN_GetPtr(hParent);
if (!pParent || pParent == WND_OTHER_PROCESS) break;
if (!pParent || pParent == WND_OTHER_PROCESS || pParent == WND_DESKTOP) break;
if (!(pParent->flags & WIN_ISDIALOG))
{
......@@ -1086,6 +1086,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
if (CallMsgFilterW( msg, MSGF_DIALOGBOX )) return TRUE;
hwndDlg = WIN_GetFullHandle( hwndDlg );
if (hwndDlg == GetDesktopWindow()) return FALSE;
if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE;
hwndDlg = DIALOG_FindMsgDestination(hwndDlg);
......
......@@ -191,7 +191,7 @@ static MDICLIENTINFO *get_client_info( HWND client )
{
if (win == WND_OTHER_PROCESS)
{
ERR( "client %p belongs to other process\n", client );
if (IsWindow(client)) ERR( "client %p belongs to other process\n", client );
return NULL;
}
if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client );
......
......@@ -182,7 +182,7 @@ static HICON NC_IconForWindow( HWND hwnd )
HICON hIcon = 0;
WND *wndPtr = WIN_GetPtr( hwnd );
if (wndPtr && wndPtr != WND_OTHER_PROCESS)
if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{
hIcon = wndPtr->hIconSmall;
if (!hIcon) hIcon = wndPtr->hIcon;
......@@ -441,7 +441,7 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect )
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return;
rect->top = rect->left = 0;
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
......@@ -642,7 +642,7 @@ LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
LONG retvalue;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return HTERROR;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return HTERROR;
retvalue = NC_DoNCHitTest (wndPtr, pt);
WIN_ReleasePtr( wndPtr );
......@@ -933,18 +933,10 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, DWORD style,
/******************************************************************************
*
* NC_DoNCPaint
*
* Paint the non-client area for windows. The clip region is
* currently ignored.
*
* Bugs
* grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
* misc/tweak.c controls/menu.c # :-)
*
*****************************************************************************/
* Paint the non-client area for windows.
*/
static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
{
HDC hdc;
......@@ -1185,7 +1177,7 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
else
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return;
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return;
NC_GetInsideRect( hwnd, rect );
OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
......
......@@ -477,7 +477,7 @@ static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset )
{
HWND hwnd = hwndFrom;
while (hwnd && hwnd != GetDesktopWindow())
while (hwnd)
{
if (hwnd == hwndTo) return;
if (!(wndPtr = WIN_GetPtr( hwnd )))
......@@ -485,6 +485,7 @@ static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset )
ERR( "bad hwndFrom = %p\n", hwnd );
return;
}
if (wndPtr == WND_DESKTOP) break;
if (wndPtr == WND_OTHER_PROCESS) goto other_process;
offset->x += wndPtr->rectClient.left;
offset->y += wndPtr->rectClient.top;
......@@ -498,13 +499,14 @@ static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset )
{
HWND hwnd = hwndTo;
while (hwnd && hwnd != GetDesktopWindow())
while (hwnd)
{
if (!(wndPtr = WIN_GetPtr( hwnd )))
{
ERR( "bad hwndTo = %p\n", hwnd );
return;
}
if (wndPtr == WND_DESKTOP) break;
if (wndPtr == WND_OTHER_PROCESS) goto other_process;
offset->x -= wndPtr->rectClient.left;
offset->y -= wndPtr->rectClient.top;
......@@ -893,7 +895,7 @@ BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
WND *pWnd = WIN_GetPtr( hwnd );
LPINTERNALPOS lpPos;
if (!pWnd) return FALSE;
if (!pWnd || pWnd == WND_DESKTOP) return FALSE;
if (pWnd == WND_OTHER_PROCESS)
{
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
......@@ -932,7 +934,7 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f
DWORD style;
WND *pWnd = WIN_GetPtr( hwnd );
if (!pWnd || pWnd == WND_OTHER_PROCESS) return FALSE;
if (!pWnd || pWnd == WND_OTHER_PROCESS || pWnd == WND_DESKTOP) return FALSE;
lpPos = WINPOS_InitInternalPos( pWnd );
if( flags & PLACE_MIN )
......
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