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

Made WIN_GetPtr return WND_DESKTOP in that case.
This commit is contained in:
Alexandre Julliard 2005-03-24 15:18:50 +00:00
parent bf0f6a22d2
commit 039603c77d
17 changed files with 120 additions and 116 deletions

View File

@ -109,6 +109,7 @@ static BOOL set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
ret = !wine_server_call( req ); ret = !wine_server_call( req );
} }
SERVER_END_REQ; SERVER_END_REQ;
if (win == WND_DESKTOP) return ret;
if (ret) if (ret)
{ {
win->rectWindow = *rectWindow; win->rectWindow = *rectWindow;

View File

@ -319,7 +319,7 @@ static HMENU get_win_sys_menu( HWND hwnd )
{ {
HMENU ret = 0; HMENU ret = 0;
WND *win = WIN_GetPtr( hwnd ); WND *win = WIN_GetPtr( hwnd );
if (win && win != WND_OTHER_PROCESS) if (win && win != WND_OTHER_PROCESS && win != WND_DESKTOP)
{ {
ret = win->hSysMenu; ret = win->hSysMenu;
WIN_ReleasePtr( win ); WIN_ReleasePtr( win );
@ -3667,6 +3667,7 @@ HMENU WINAPI GetSystemMenu( HWND hWnd, BOOL bRevert )
WND *wndPtr = WIN_GetPtr( hWnd ); WND *wndPtr = WIN_GetPtr( hWnd );
HMENU retvalue = 0; HMENU retvalue = 0;
if (wndPtr == WND_DESKTOP) return 0;
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS)
{ {
if (IsWindow( hWnd )) FIXME( "not supported on other process window %p\n", hWnd ); 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 ); 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 ); if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu ); wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu );

View File

@ -2867,7 +2867,7 @@ LONG WINAPI DispatchMessageA( const MSG* msg )
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE ); if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{ {
if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY ); if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE ); else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
@ -2942,7 +2942,7 @@ LONG WINAPI DispatchMessageW( const MSG* msg )
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE ); if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{ {
if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY ); if (IsWindow( msg->hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE ); else SetLastError( ERROR_INVALID_WINDOW_HANDLE );

View File

@ -363,11 +363,10 @@ LONG WINAPI DispatchMessage16( const MSG16* msg )
if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE ); if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{ {
if (IsWindow( hwnd )) if (IsWindow( hwnd )) SetLastError( ERROR_MESSAGE_SYNC_ONLY );
ERR( "cannot dispatch msg to other process window %p\n", hwnd ); else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
winproc = (WNDPROC16)wndPtr->winproc; winproc = (WNDPROC16)wndPtr->winproc;

View File

@ -188,7 +188,7 @@ static HRGN send_ncpaint( HWND hwnd, HWND *child, UINT *flags )
INT type; INT type;
WND *win = WIN_GetPtr( hwnd ); WND *win = WIN_GetPtr( hwnd );
if (!win || win == WND_OTHER_PROCESS) if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP)
{ {
DeleteObject( whole_rgn ); DeleteObject( whole_rgn );
return 0; return 0;

View File

@ -152,7 +152,7 @@ static SCROLLBAR_INFO *SCROLL_GetInternalInfo( HWND hwnd, INT nBar, BOOL alloc )
SCROLLBAR_INFO *infoPtr = NULL; SCROLLBAR_INFO *infoPtr = NULL;
WND *wndPtr = WIN_GetPtr( hwnd ); 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) switch(nBar)
{ {
case SB_HORZ: infoPtr = (SCROLLBAR_INFO *)wndPtr->pHScroll; break; 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; BOOL vertical;
WND *wndPtr = WIN_GetPtr( hwnd ); 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) switch(nBar)
{ {
@ -1069,7 +1069,7 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
if (scrollbar != SB_CTL) if (scrollbar != SB_CTL)
{ {
WND *wndPtr = WIN_GetPtr( hwnd ); 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; xoffset = wndPtr->rectClient.left - wndPtr->rectWindow.left;
yoffset = wndPtr->rectClient.top - wndPtr->rectWindow.top; yoffset = wndPtr->rectClient.top - wndPtr->rectWindow.top;
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );

View File

@ -66,18 +66,12 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
Display *display; Display *display;
MSG msg; MSG msg;
HWND hwnd; HWND hwnd;
WND *win;
Atom atom = x11drv_atom(WM_DELETE_WINDOW); Atom atom = x11drv_atom(WM_DELETE_WINDOW);
NtCurrentTeb()->driver_data = driver_data; NtCurrentTeb()->driver_data = driver_data;
display = thread_display(); display = thread_display();
hwnd = GetDesktopWindow(); 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 ); SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_winproc );
wine_tsx11_lock(); wine_tsx11_lock();
XSaveContext( display, root_window, winContext, (char *)hwnd ); XSaveContext( display, root_window, winContext, (char *)hwnd );

View File

@ -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 ); if (IsWindow( hwnd )) ERR( "cannot set rectangles of other process window %p\n", hwnd );
return FALSE; return FALSE;
} }
old_style = win->dwStyle;
SERVER_START_REQ( set_window_pos ) SERVER_START_REQ( set_window_pos )
{ {
req->handle = hwnd; req->handle = hwnd;
@ -749,6 +748,8 @@ BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow
} }
SERVER_END_REQ; SERVER_END_REQ;
if (win == WND_DESKTOP) return ret;
if (ret) if (ret)
{ {
Display *display = thread_display(); 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->rectWindow = *rectWindow;
win->rectClient = *rectClient; win->rectClient = *rectClient;
old_style = win->dwStyle;
win->dwStyle = new_style; win->dwStyle = new_style;
data->window_rect = *rectWindow; data->window_rect = *rectWindow;
@ -1090,6 +1092,7 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT cmd )
RECT newPos = {0, 0, 0, 0}; RECT newPos = {0, 0, 0, 0};
UINT swp = 0; UINT swp = 0;
if (hwnd == GetDesktopWindow()) return FALSE;
TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible); TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible);

View File

@ -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_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 ); extern LRESULT HOOK_CallHooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL unicode );

View File

@ -65,7 +65,6 @@ typedef struct tagCLASS
} CLASS; } CLASS;
static struct list class_list = LIST_INIT( class_list ); static struct list class_list = LIST_INIT( class_list );
static CLASS *desktop_class;
#define CLASS_OTHER_PROCESS ((CLASS *)1) #define CLASS_OTHER_PROCESS ((CLASS *)1)
@ -78,8 +77,9 @@ static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
if (ptr) if (ptr)
{ {
if (ptr != WND_OTHER_PROCESS) return ptr->class; if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP) return ptr->class;
if (write_access && IsWindow( hwnd )) /* check other processes */
if (write_access && (ptr == WND_DESKTOP || IsWindow( hwnd ))) /* check other processes */
{ {
/* modifying classes in other processes is not allowed */ /* modifying classes in other processes is not allowed */
SetLastError( ERROR_ACCESS_DENIED ); 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 SCROLL_builtin_class;
extern const struct builtin_class_descr STATIC_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( &BUTTON_builtin_class );
register_builtin( &COMBO_builtin_class ); register_builtin( &COMBO_builtin_class );
register_builtin( &COMBOLBOX_builtin_class ); register_builtin( &COMBOLBOX_builtin_class );
@ -499,8 +499,6 @@ void CLASS_RegisterBuiltinClasses(void)
*/ */
void CLASS_AddWindow( CLASS *class, WND *win, WINDOWPROCTYPE type ) void CLASS_AddWindow( CLASS *class, WND *win, WINDOWPROCTYPE type )
{ {
if (!class) class = desktop_class;
if (type == WIN_PROC_32W) if (type == WIN_PROC_32W)
{ {
if (!(win->winproc = class->winprocW)) win->winproc = class->winprocA; if (!(win->winproc = class->winprocW)) win->winproc = class->winprocA;

View File

@ -349,7 +349,7 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
else hwnd = WIN_GetFullHandle( hwnd ); else hwnd = WIN_GetFullHandle( hwnd );
if (!(wndPtr = WIN_GetPtr( hwnd ))) return 0; if (!(wndPtr = WIN_GetPtr( hwnd ))) return 0;
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{ {
wndPtr = NULL; wndPtr = NULL;
USER_Lock(); USER_Lock();

View File

@ -359,7 +359,7 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create )
dlgInfo->flags = 0; dlgInfo->flags = 0;
dlgInfo->hDialogHeap = 0; dlgInfo->hDialogHeap = 0;
wndPtr = WIN_GetPtr( hwnd ); wndPtr = WIN_GetPtr( hwnd );
if (wndPtr && wndPtr != WND_OTHER_PROCESS) if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{ {
wndPtr->flags |= WIN_ISDIALOG; wndPtr->flags |= WIN_ISDIALOG;
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );

View File

@ -997,7 +997,7 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
if (!hParent) break; if (!hParent) break;
pParent = WIN_GetPtr(hParent); 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)) if (!(pParent->flags & WIN_ISDIALOG))
{ {
@ -1086,6 +1086,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
if (CallMsgFilterW( msg, MSGF_DIALOGBOX )) return TRUE; if (CallMsgFilterW( msg, MSGF_DIALOGBOX )) return TRUE;
hwndDlg = WIN_GetFullHandle( hwndDlg ); hwndDlg = WIN_GetFullHandle( hwndDlg );
if (hwndDlg == GetDesktopWindow()) return FALSE;
if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE; if ((hwndDlg != msg->hwnd) && !IsChild( hwndDlg, msg->hwnd )) return FALSE;
hwndDlg = DIALOG_FindMsgDestination(hwndDlg); hwndDlg = DIALOG_FindMsgDestination(hwndDlg);

View File

@ -191,7 +191,7 @@ static MDICLIENTINFO *get_client_info( HWND client )
{ {
if (win == WND_OTHER_PROCESS) 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; return NULL;
} }
if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client ); if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client );

View File

@ -182,7 +182,7 @@ static HICON NC_IconForWindow( HWND hwnd )
HICON hIcon = 0; HICON hIcon = 0;
WND *wndPtr = WIN_GetPtr( hwnd ); WND *wndPtr = WIN_GetPtr( hwnd );
if (wndPtr && wndPtr != WND_OTHER_PROCESS) if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{ {
hIcon = wndPtr->hIconSmall; hIcon = wndPtr->hIconSmall;
if (!hIcon) hIcon = wndPtr->hIcon; if (!hIcon) hIcon = wndPtr->hIcon;
@ -441,7 +441,7 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect )
{ {
WND *wndPtr = WIN_GetPtr( hwnd ); 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->top = rect->left = 0;
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left; rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
@ -642,7 +642,7 @@ LONG NC_HandleNCHitTest (HWND hwnd , POINT pt)
LONG retvalue; LONG retvalue;
WND *wndPtr = WIN_GetPtr( hwnd ); 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); retvalue = NC_DoNCHitTest (wndPtr, pt);
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
@ -933,18 +933,10 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, DWORD style,
/****************************************************************************** /******************************************************************************
*
* NC_DoNCPaint * NC_DoNCPaint
* *
* Paint the non-client area for windows. The clip region is * Paint the non-client area for windows.
* currently ignored. */
*
* Bugs
* grep -E -A10 -B5 \(95\)\|\(Bugs\)\|\(FIXME\) windows/nonclient.c \
* misc/tweak.c controls/menu.c # :-)
*
*****************************************************************************/
static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint ) static void NC_DoNCPaint( HWND hwnd, HRGN clip, BOOL suppress_menupaint )
{ {
HDC hdc; HDC hdc;
@ -1185,7 +1177,7 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
else else
{ {
WND *wndPtr = WIN_GetPtr( hwnd ); 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 ); NC_GetInsideRect( hwnd, rect );
OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top); OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);

View File

@ -51,7 +51,7 @@ WINE_DECLARE_DEBUG_CHANNEL(msg);
/**********************************************************************/ /**********************************************************************/
/* Desktop window */ /* Desktop window */
static WND *pWndDesktop = NULL; static HWND hwndDesktop;
static WORD wDragWidth = 4; static WORD wDragWidth = 4;
static WORD wDragHeight= 3; static WORD wDragHeight= 3;
@ -213,13 +213,14 @@ static HWND *list_window_parents( HWND hwnd )
{ {
if (!(win = WIN_GetPtr( current ))) goto empty; if (!(win = WIN_GetPtr( current ))) goto empty;
if (win == WND_OTHER_PROCESS) break; /* need to do it the hard way */ if (win == WND_OTHER_PROCESS) break; /* need to do it the hard way */
list[pos] = win->parent; if (win == WND_DESKTOP)
WIN_ReleasePtr( win );
if (!(current = list[pos]))
{ {
if (!pos) goto empty; if (!pos) goto empty;
list[pos] = 0;
return list; return list;
} }
list[pos] = current = win->parent;
WIN_ReleasePtr( win );
if (++pos == size - 1) if (++pos == size - 1)
{ {
/* need to grow the list */ /* need to grow the list */
@ -312,6 +313,11 @@ WND *WIN_GetPtr( HWND hwnd )
return ptr; return ptr;
ptr = NULL; ptr = NULL;
} }
else if (index == USER_HANDLE_TO_INDEX(hwndDesktop))
{
if (!HIWORD(hwnd) || hwnd == GetDesktopWindow()) ptr = WND_DESKTOP;
else ptr = NULL;
}
else ptr = WND_OTHER_PROCESS; else ptr = WND_OTHER_PROCESS;
USER_Unlock(); USER_Unlock();
return ptr; return ptr;
@ -328,7 +334,7 @@ HWND WIN_IsCurrentProcess( HWND hwnd )
WND *ptr; WND *ptr;
HWND ret; HWND ret;
if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS) return 0; if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0;
ret = ptr->hwndSelf; ret = ptr->hwndSelf;
WIN_ReleasePtr( ptr ); WIN_ReleasePtr( ptr );
return ret; return ret;
@ -345,11 +351,9 @@ HWND WIN_IsCurrentThread( HWND hwnd )
WND *ptr; WND *ptr;
HWND ret = 0; HWND ret = 0;
if ((ptr = WIN_GetPtr( hwnd )) && ptr != WND_OTHER_PROCESS) 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->hwndSelf; WIN_ReleasePtr( ptr );
WIN_ReleasePtr( ptr );
}
return ret; return ret;
} }
@ -370,6 +374,8 @@ HWND WIN_Handle32( HWND16 hwnd16 )
if (!(ptr = WIN_GetPtr( hwnd ))) return hwnd; if (!(ptr = WIN_GetPtr( hwnd ))) return hwnd;
if (ptr == WND_DESKTOP) return GetDesktopWindow();
if (ptr != WND_OTHER_PROCESS) if (ptr != WND_OTHER_PROCESS)
{ {
hwnd = ptr->hwndSelf; hwnd = ptr->hwndSelf;
@ -411,7 +417,7 @@ void WIN_LinkWindow( HWND hwnd, HWND parent, HWND hwndInsertAfter )
{ {
WND *wndPtr = WIN_GetPtr( hwnd ); WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) return; if (!wndPtr || wndPtr == WND_DESKTOP) return;
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS)
{ {
if (IsWindow(hwnd)) ERR(" cannot link other process window %p\n", hwnd ); if (IsWindow(hwnd)) ERR(" cannot link other process window %p\n", hwnd );
@ -444,7 +450,7 @@ HWND WIN_SetOwner( HWND hwnd, HWND owner )
WND *win = WIN_GetPtr( hwnd ); WND *win = WIN_GetPtr( hwnd );
HWND ret = 0; HWND ret = 0;
if (!win) return 0; if (!win || win == WND_DESKTOP) return 0;
if (win == WND_OTHER_PROCESS) if (win == WND_OTHER_PROCESS)
{ {
if (IsWindow(hwnd)) ERR( "cannot set owner %p on other process window %p\n", owner, hwnd ); if (IsWindow(hwnd)) ERR( "cannot set owner %p on other process window %p\n", owner, hwnd );
@ -477,7 +483,7 @@ ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits )
ULONG new_style, old_style = 0; ULONG new_style, old_style = 0;
WND *win = WIN_GetPtr( hwnd ); WND *win = WIN_GetPtr( hwnd );
if (!win) return 0; if (!win || win == WND_DESKTOP) return 0;
if (win == WND_OTHER_PROCESS) if (win == WND_OTHER_PROCESS)
{ {
if (IsWindow(hwnd)) if (IsWindow(hwnd))
@ -521,7 +527,16 @@ BOOL WIN_GetRectangles( HWND hwnd, RECT *rectWindow, RECT *rectClient )
BOOL ret = TRUE; BOOL ret = TRUE;
if (!win) return FALSE; if (!win) return FALSE;
if (win == WND_OTHER_PROCESS) if (win == WND_DESKTOP)
{
RECT rect;
rect.left = rect.top = 0;
rect.right = GetSystemMetrics(SM_CXSCREEN);
rect.bottom = GetSystemMetrics(SM_CYSCREEN);
if (rectWindow) *rectWindow = rect;
if (rectClient) *rectClient = rect;
}
else if (win == WND_OTHER_PROCESS)
{ {
SERVER_START_REQ( get_window_rectangles ) SERVER_START_REQ( get_window_rectangles )
{ {
@ -645,26 +660,27 @@ void WIN_DestroyThreadWindows( HWND hwnd )
*/ */
BOOL WIN_CreateDesktopWindow(void) BOOL WIN_CreateDesktopWindow(void)
{ {
HWND hwndDesktop;
CREATESTRUCTA cs; CREATESTRUCTA cs;
TRACE("Creating desktop window\n"); TRACE("Creating desktop window\n");
if (!WINPOS_CreateInternalPosAtom()) return FALSE; if (!WINPOS_CreateInternalPosAtom()) return FALSE;
pWndDesktop = create_window_handle( 0, 0, LOWORD(DESKTOP_CLASS_ATOM), 0, WIN_PROC_32W ); SERVER_START_REQ( create_window )
if (!pWndDesktop) return FALSE; {
hwndDesktop = pWndDesktop->hwndSelf; req->parent = 0;
req->owner = 0;
req->atom = LOWORD(DESKTOP_CLASS_ATOM);
req->instance = 0;
if (!wine_server_call_err( req )) hwndDesktop = reply->handle;
}
SERVER_END_REQ;
pWndDesktop->tid = 0; /* nobody owns the desktop */ if (!hwndDesktop)
pWndDesktop->parent = 0; {
pWndDesktop->owner = 0; ERR( "error %ld creating desktop window\n", GetLastError() );
pWndDesktop->text = NULL; return FALSE;
pWndDesktop->pVScroll = NULL; }
pWndDesktop->pHScroll = NULL;
pWndDesktop->helpContext = 0;
pWndDesktop->flags = 0;
pWndDesktop->hSysMenu = 0;
cs.lpCreateParams = NULL; cs.lpCreateParams = NULL;
cs.hInstance = 0; cs.hInstance = 0;
@ -674,30 +690,12 @@ BOOL WIN_CreateDesktopWindow(void)
cs.y = 0; cs.y = 0;
cs.cx = GetSystemMetrics( SM_CXSCREEN ); cs.cx = GetSystemMetrics( SM_CXSCREEN );
cs.cy = GetSystemMetrics( SM_CYSCREEN ); cs.cy = GetSystemMetrics( SM_CYSCREEN );
cs.style = pWndDesktop->dwStyle; cs.style = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
cs.dwExStyle = pWndDesktop->dwExStyle; cs.dwExStyle = 0;
cs.lpszName = NULL; cs.lpszName = NULL;
cs.lpszClass = DESKTOP_CLASS_ATOM; cs.lpszClass = DESKTOP_CLASS_ATOM;
SERVER_START_REQ( set_window_info ) return USER_Driver.pCreateWindow( hwndDesktop, &cs, TRUE );
{
req->handle = hwndDesktop;
req->flags = 0; /* don't set anything, just retrieve */
req->extra_offset = -1;
wine_server_call( req );
pWndDesktop->dwStyle = reply->old_style;
pWndDesktop->dwExStyle = reply->old_ex_style;
pWndDesktop->hInstance = (HINSTANCE)reply->old_instance;
pWndDesktop->userdata = (ULONG_PTR)reply->old_user_data;
pWndDesktop->wIDmenu = reply->old_id;
}
SERVER_END_REQ;
WIN_ReleasePtr( pWndDesktop );
if (!USER_Driver.pCreateWindow || !USER_Driver.pCreateWindow( hwndDesktop, &cs, FALSE ))
return FALSE;
return TRUE;
} }
@ -946,7 +944,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
UINT flags = 0; UINT flags = 0;
wndPtr = WIN_GetPtr(cs->hwndParent); wndPtr = WIN_GetPtr(cs->hwndParent);
if (wndPtr && wndPtr != WND_OTHER_PROCESS) if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
{ {
flags = wndPtr->flags; flags = wndPtr->flags;
WIN_ReleasePtr(wndPtr); WIN_ReleasePtr(wndPtr);
@ -1640,7 +1638,7 @@ HWND WINAPI FindWindowW( LPCWSTR className, LPCWSTR title )
*/ */
HWND WINAPI GetDesktopWindow(void) HWND WINAPI GetDesktopWindow(void)
{ {
if (pWndDesktop) return pWndDesktop->hwndSelf; if (hwndDesktop) return hwndDesktop;
ERR( "Wine init error: either you're trying to use an invalid native USER.EXE config, or some graphics/GUI libraries or DLLs didn't initialize properly. Aborting.\n" ); ERR( "Wine init error: either you're trying to use an invalid native USER.EXE config, or some graphics/GUI libraries or DLLs didn't initialize properly. Aborting.\n" );
ExitProcess(1); ExitProcess(1);
return 0; return 0;
@ -1714,6 +1712,7 @@ BOOL WINAPI IsWindowUnicode( HWND hwnd )
BOOL retvalue; BOOL retvalue;
if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE; if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return FALSE;
if (wndPtr == WND_DESKTOP) return TRUE;
retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W); retvalue = (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W);
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
return retvalue; return retvalue;
@ -1734,7 +1733,7 @@ WORD WINAPI GetWindowWord( HWND hwnd, INT offset )
SetLastError( ERROR_INVALID_WINDOW_HANDLE ); SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{ {
SERVER_START_REQ( set_window_info ) SERVER_START_REQ( set_window_info )
{ {
@ -1801,6 +1800,11 @@ WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval )
} }
wndPtr = WIN_GetPtr( hwnd ); wndPtr = WIN_GetPtr( hwnd );
if (wndPtr == WND_DESKTOP)
{
SetLastError( ERROR_ACCESS_DENIED );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS)
{ {
if (IsWindow(hwnd)) if (IsWindow(hwnd))
@ -1865,7 +1869,7 @@ static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
return 0; return 0;
} }
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP)
{ {
if (offset == GWLP_WNDPROC) if (offset == GWLP_WNDPROC)
{ {
@ -1976,7 +1980,19 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return FALSE; return FALSE;
} }
if (!WIN_IsCurrentProcess( hwnd ))
if (!(wndPtr = WIN_GetPtr( hwnd )))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (wndPtr == WND_DESKTOP)
{
/* can't change anything on the desktop window */
SetLastError( ERROR_ACCESS_DENIED );
return 0;
}
if (wndPtr == WND_OTHER_PROCESS)
{ {
if (offset == GWLP_WNDPROC) if (offset == GWLP_WNDPROC)
{ {
@ -1986,15 +2002,6 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
return SendMessageW( hwnd, WM_WINE_SETWINDOWLONG, offset, newval ); return SendMessageW( hwnd, WM_WINE_SETWINDOWLONG, offset, newval );
} }
wndPtr = WIN_GetPtr( hwnd );
if (wndPtr->hwndSelf == GetDesktopWindow())
{
/* can't change anything on the desktop window */
WIN_ReleasePtr( wndPtr );
SetLastError( ERROR_ACCESS_DENIED );
return 0;
}
/* first some special cases */ /* first some special cases */
switch( offset ) switch( offset )
{ {
@ -2289,7 +2296,8 @@ INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
if (nMaxCount <= 0) return 0; if (nMaxCount <= 0) return 0;
if (!(win = WIN_GetPtr( hwnd ))) return 0; if (!(win = WIN_GetPtr( hwnd ))) return 0;
if (win != WND_OTHER_PROCESS) if (win == WND_DESKTOP) lpString[0] = 0;
else if (win != WND_OTHER_PROCESS)
{ {
if (win->text) lstrcpynW( lpString, win->text, nMaxCount ); if (win->text) lstrcpynW( lpString, win->text, nMaxCount );
else lpString[0] = 0; else lpString[0] = 0;
@ -2385,6 +2393,7 @@ BOOL WINAPI IsWindow( HWND hwnd )
BOOL ret; BOOL ret;
if (!(ptr = WIN_GetPtr( hwnd ))) return FALSE; if (!(ptr = WIN_GetPtr( hwnd ))) return FALSE;
if (ptr == WND_DESKTOP) return TRUE;
if (ptr != WND_OTHER_PROCESS) if (ptr != WND_OTHER_PROCESS)
{ {
@ -2417,7 +2426,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process )
return 0; return 0;
} }
if (ptr != WND_OTHER_PROCESS) if (ptr != WND_OTHER_PROCESS && ptr != WND_DESKTOP)
{ {
/* got a valid window */ /* got a valid window */
tid = ptr->tid; tid = ptr->tid;
@ -2454,6 +2463,7 @@ HWND WINAPI GetParent( HWND hwnd )
SetLastError( ERROR_INVALID_WINDOW_HANDLE ); SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
if (wndPtr == WND_DESKTOP) return 0;
if (wndPtr == WND_OTHER_PROCESS) if (wndPtr == WND_OTHER_PROCESS)
{ {
LONG style = GetWindowLongW( hwnd, GWL_STYLE ); LONG style = GetWindowLongW( hwnd, GWL_STYLE );
@ -2497,6 +2507,7 @@ HWND WINAPI GetAncestor( HWND hwnd, UINT type )
SetLastError( ERROR_INVALID_WINDOW_HANDLE ); SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0; return 0;
} }
if (win == WND_DESKTOP) return 0;
if (win != WND_OTHER_PROCESS) if (win != WND_OTHER_PROCESS)
{ {
ret = win->parent; ret = win->parent;
@ -2584,7 +2595,7 @@ HWND WINAPI SetParent( HWND hwnd, HWND parent )
was_visible = ShowWindow( hwnd, SW_HIDE ); was_visible = ShowWindow( hwnd, SW_HIDE );
if (!IsWindow( parent )) return 0; if (!IsWindow( parent )) return 0;
if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS) return 0; if (!(wndPtr = WIN_GetPtr(hwnd)) || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return 0;
retvalue = wndPtr->parent; /* old parent */ retvalue = wndPtr->parent; /* old parent */
if (parent != retvalue) if (parent != retvalue)
@ -2703,6 +2714,7 @@ HWND WINAPI GetWindow( HWND hwnd, UINT rel )
SetLastError( ERROR_INVALID_HANDLE ); SetLastError( ERROR_INVALID_HANDLE );
return 0; return 0;
} }
if (wndPtr == WND_DESKTOP) return 0;
if (wndPtr != WND_OTHER_PROCESS) if (wndPtr != WND_OTHER_PROCESS)
{ {
retval = wndPtr->owner; retval = wndPtr->owner;
@ -2972,7 +2984,7 @@ BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert )
RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME ); RedrawWindow( hWnd, 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME );
wndPtr = WIN_GetPtr(hWnd); wndPtr = WIN_GetPtr(hWnd);
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return FALSE; if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED)) if (bInvert && !(wndPtr->flags & WIN_NCACTIVATED))
{ {
wndPtr->flags |= WIN_NCACTIVATED; wndPtr->flags |= WIN_NCACTIVATED;
@ -2989,7 +3001,7 @@ BOOL WINAPI FlashWindow( HWND hWnd, BOOL bInvert )
WPARAM wparam; WPARAM wparam;
wndPtr = WIN_GetPtr(hWnd); wndPtr = WIN_GetPtr(hWnd);
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return FALSE; if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return FALSE;
hWnd = wndPtr->hwndSelf; /* make it a full handle */ hWnd = wndPtr->hwndSelf; /* make it a full handle */
if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED); if (bInvert) wparam = !(wndPtr->flags & WIN_NCACTIVATED);
@ -3017,7 +3029,7 @@ DWORD WINAPI GetWindowContextHelpId( HWND hwnd )
{ {
DWORD retval; DWORD retval;
WND *wnd = WIN_GetPtr( hwnd ); WND *wnd = WIN_GetPtr( hwnd );
if (!wnd) return 0; if (!wnd || wnd == WND_DESKTOP) return 0;
if (wnd == WND_OTHER_PROCESS) if (wnd == WND_OTHER_PROCESS)
{ {
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd ); if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
@ -3035,7 +3047,7 @@ DWORD WINAPI GetWindowContextHelpId( HWND hwnd )
BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id ) BOOL WINAPI SetWindowContextHelpId( HWND hwnd, DWORD id )
{ {
WND *wnd = WIN_GetPtr( hwnd ); WND *wnd = WIN_GetPtr( hwnd );
if (!wnd) return FALSE; if (!wnd || wnd == WND_DESKTOP) return FALSE;
if (wnd == WND_OTHER_PROCESS) if (wnd == WND_OTHER_PROCESS)
{ {
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd ); if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );

View File

@ -477,7 +477,7 @@ static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset )
{ {
HWND hwnd = hwndFrom; HWND hwnd = hwndFrom;
while (hwnd && hwnd != GetDesktopWindow()) while (hwnd)
{ {
if (hwnd == hwndTo) return; if (hwnd == hwndTo) return;
if (!(wndPtr = WIN_GetPtr( hwnd ))) 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 ); ERR( "bad hwndFrom = %p\n", hwnd );
return; return;
} }
if (wndPtr == WND_DESKTOP) break;
if (wndPtr == WND_OTHER_PROCESS) goto other_process; if (wndPtr == WND_OTHER_PROCESS) goto other_process;
offset->x += wndPtr->rectClient.left; offset->x += wndPtr->rectClient.left;
offset->y += wndPtr->rectClient.top; offset->y += wndPtr->rectClient.top;
@ -498,13 +499,14 @@ static void WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, POINT *offset )
{ {
HWND hwnd = hwndTo; HWND hwnd = hwndTo;
while (hwnd && hwnd != GetDesktopWindow()) while (hwnd)
{ {
if (!(wndPtr = WIN_GetPtr( hwnd ))) if (!(wndPtr = WIN_GetPtr( hwnd )))
{ {
ERR( "bad hwndTo = %p\n", hwnd ); ERR( "bad hwndTo = %p\n", hwnd );
return; return;
} }
if (wndPtr == WND_DESKTOP) break;
if (wndPtr == WND_OTHER_PROCESS) goto other_process; if (wndPtr == WND_OTHER_PROCESS) goto other_process;
offset->x -= wndPtr->rectClient.left; offset->x -= wndPtr->rectClient.left;
offset->y -= wndPtr->rectClient.top; offset->y -= wndPtr->rectClient.top;
@ -893,7 +895,7 @@ BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl )
WND *pWnd = WIN_GetPtr( hwnd ); WND *pWnd = WIN_GetPtr( hwnd );
LPINTERNALPOS lpPos; LPINTERNALPOS lpPos;
if (!pWnd) return FALSE; if (!pWnd || pWnd == WND_DESKTOP) return FALSE;
if (pWnd == WND_OTHER_PROCESS) if (pWnd == WND_OTHER_PROCESS)
{ {
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd ); 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; DWORD style;
WND *pWnd = WIN_GetPtr( hwnd ); 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 ); lpPos = WINPOS_InitInternalPos( pWnd );
if( flags & PLACE_MIN ) if( flags & PLACE_MIN )