mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
-cursoricon: naming changes, cleanup
-fix: hide/show caret to accept NULL hWnds -some handle to pointer converions -double handle table size -fix: co_WinPosActivateOtherWindow was trying to access desktop parent svn path=/trunk/; revision=17756
This commit is contained in:
parent
6b27e47c88
commit
16addb9060
8 changed files with 620 additions and 621 deletions
|
@ -42,7 +42,7 @@ typedef enum _USER_OBJECT_TYPE
|
|||
otWindow,
|
||||
otMenu,
|
||||
otAccel,
|
||||
otCursor,
|
||||
otCursorIcon,
|
||||
otHook,
|
||||
otMonitor,
|
||||
otClass //fixme: remove
|
||||
|
|
|
@ -21,6 +21,8 @@ BOOL FASTCALL ObmDereferenceObject(PVOID obj);
|
|||
|
||||
#define IntReferenceWindowObject(o) ObmReferenceObject(o)
|
||||
|
||||
#define UserDerefObject(o) ObmReferenceObject(o)
|
||||
|
||||
VOID FASTCALL IntReleaseWindowObject(PWINDOW_OBJECT Window);
|
||||
PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd);
|
||||
PVOID FASTCALL
|
||||
|
@ -136,7 +138,7 @@ BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Wnd);
|
|||
|
||||
LONG FASTCALL UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi);
|
||||
|
||||
HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type);
|
||||
PWINDOW_OBJECT FASTCALL UserGetAncestor(PWINDOW_OBJECT Wnd, UINT Type);
|
||||
|
||||
/*************** MENU.C ***************/
|
||||
|
||||
|
|
|
@ -317,11 +317,13 @@ CLEANUP:
|
|||
}
|
||||
|
||||
|
||||
BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window)
|
||||
BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL)
|
||||
{
|
||||
PUSER_MESSAGE_QUEUE ThreadQueue;
|
||||
|
||||
if(Window->OwnerThread != PsGetCurrentThread())
|
||||
if (Window) ASSERT_REFS_CO(Window);
|
||||
|
||||
if(Window && Window->OwnerThread != PsGetCurrentThread())
|
||||
{
|
||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
|
@ -329,7 +331,7 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window)
|
|||
|
||||
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
||||
|
||||
if(ThreadQueue->CaretInfo->hWnd != Window->hSelf)
|
||||
if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf)
|
||||
{
|
||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
|
@ -337,7 +339,7 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window)
|
|||
|
||||
if(ThreadQueue->CaretInfo->Visible)
|
||||
{
|
||||
IntKillTimer(Window->hSelf, IDCARETTIMER, TRUE);
|
||||
IntKillTimer((Window ? Window->hSelf : 0), IDCARETTIMER, TRUE);
|
||||
|
||||
co_IntHideCaret(ThreadQueue->CaretInfo);
|
||||
ThreadQueue->CaretInfo->Visible = 0;
|
||||
|
@ -350,24 +352,23 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window)
|
|||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserHideCaret(
|
||||
HWND hWnd)
|
||||
NtUserHideCaret(HWND hWnd OPTIONAL)
|
||||
{
|
||||
PWINDOW_OBJECT Window;
|
||||
PWINDOW_OBJECT Window = NULL;
|
||||
DECLARE_RETURN(BOOL);
|
||||
BOOL ret;
|
||||
|
||||
DPRINT("Enter NtUserHideCaret\n");
|
||||
UserEnterExclusive();
|
||||
|
||||
if(!(Window = UserGetWindowObject(hWnd)))
|
||||
if(hWnd && !(Window = UserGetWindowObject(hWnd)))
|
||||
{
|
||||
RETURN(FALSE);
|
||||
}
|
||||
|
||||
UserRefObjectCo(Window);
|
||||
if (Window) UserRefObjectCo(Window);
|
||||
ret = co_UserHideCaret(Window);
|
||||
UserDerefObjectCo(Window);
|
||||
if (Window) UserDerefObjectCo(Window);
|
||||
|
||||
RETURN(ret);
|
||||
|
||||
|
@ -378,11 +379,13 @@ CLEANUP:
|
|||
}
|
||||
|
||||
|
||||
BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
|
||||
BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL)
|
||||
{
|
||||
PUSER_MESSAGE_QUEUE ThreadQueue;
|
||||
|
||||
if(Window->OwnerThread != PsGetCurrentThread())
|
||||
if (Window) ASSERT_REFS_CO(Window);
|
||||
|
||||
if(Window && Window->OwnerThread != PsGetCurrentThread())
|
||||
{
|
||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
|
@ -390,7 +393,7 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
|
|||
|
||||
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
||||
|
||||
if(ThreadQueue->CaretInfo->hWnd != Window->hSelf)
|
||||
if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf)
|
||||
{
|
||||
SetLastWin32Error(ERROR_ACCESS_DENIED);
|
||||
return FALSE;
|
||||
|
@ -403,7 +406,7 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
|
|||
{
|
||||
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
|
||||
}
|
||||
IntSetTimer(Window->hSelf, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
|
||||
IntSetTimer((Window ? Window->hSelf : 0), IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -412,24 +415,23 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
|
|||
|
||||
BOOL
|
||||
STDCALL
|
||||
NtUserShowCaret(
|
||||
HWND hWnd)
|
||||
NtUserShowCaret(HWND hWnd OPTIONAL)
|
||||
{
|
||||
PWINDOW_OBJECT Window;
|
||||
PWINDOW_OBJECT Window = NULL;
|
||||
DECLARE_RETURN(BOOL);
|
||||
BOOL ret;
|
||||
|
||||
DPRINT("Enter NtUserShowCaret\n");
|
||||
UserEnterExclusive();
|
||||
|
||||
if(!(Window = UserGetWindowObject(hWnd)))
|
||||
if(hWnd && !(Window = UserGetWindowObject(hWnd)))
|
||||
{
|
||||
RETURN(FALSE);
|
||||
}
|
||||
|
||||
UserRefObjectCo(Window);
|
||||
if (Window) UserRefObjectCo(Window);
|
||||
ret = co_UserShowCaret(Window);
|
||||
UserDerefObjectCo(Window);
|
||||
if (Window) UserDerefObjectCo(Window);
|
||||
|
||||
RETURN(ret);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -250,28 +250,38 @@ co_IntMouseActivateWindow(PWINDOW_OBJECT Window)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
Top = UserGetAncestor(Window->hSelf, GA_ROOT);
|
||||
if (Top != Window->hSelf)
|
||||
{
|
||||
TopWindow = IntGetWindowObject(Top);
|
||||
if (TopWindow == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TopWindow = Window;
|
||||
}
|
||||
|
||||
TopWindow = UserGetAncestor(Window, GA_ROOT);
|
||||
if (!TopWindow) return FALSE;
|
||||
// if (TopWindow != Window)
|
||||
// {
|
||||
|
||||
// Top = UserGetAncestor(Window, GA_ROOT);
|
||||
// if (Top != Window->hSelf)
|
||||
// {
|
||||
// TopWindow = IntGetWindowObject(Top);
|
||||
// if (TopWindow == NULL)
|
||||
// {
|
||||
// SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||
// return FALSE;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// TopWindow = Window;
|
||||
// }
|
||||
|
||||
/* TMN: Check return valud from this function? */
|
||||
UserRefObjectCo(TopWindow);
|
||||
|
||||
co_IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
|
||||
|
||||
UserDerefObjectCo(TopWindow);
|
||||
|
||||
if (Top != Window->hSelf)
|
||||
{
|
||||
IntReleaseWindowObject(TopWindow);
|
||||
}
|
||||
// if (TopWindow != Window)
|
||||
// {
|
||||
// IntReleaseWindowObject(TopWindow);
|
||||
// }
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -521,7 +531,8 @@ HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window OPTIONAL)
|
|||
if (Window)
|
||||
{
|
||||
PUSER_MESSAGE_QUEUE ThreadQueue;
|
||||
HWND hWndPrev, hWndTop;
|
||||
HWND hWndPrev;
|
||||
PWINDOW_OBJECT TopWnd;
|
||||
|
||||
ASSERT_REFS_CO(Window);
|
||||
|
||||
|
@ -538,14 +549,13 @@ HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window OPTIONAL)
|
|||
return( 0);
|
||||
}
|
||||
|
||||
hWndTop = UserGetAncestor(Window->hSelf, GA_ROOT);
|
||||
if (hWndTop != UserGetActiveWindow())
|
||||
TopWnd = UserGetAncestor(Window, GA_ROOT);
|
||||
if (TopWnd->hSelf != UserGetActiveWindow())
|
||||
{
|
||||
PWINDOW_OBJECT WndTops = UserGetWindowObject(hWndTop);
|
||||
|
||||
UserRefObjectCo(WndTops);
|
||||
co_IntSetActiveWindow(WndTops);
|
||||
UserDerefObjectCo(WndTops);
|
||||
// PWINDOW_OBJECT WndTops = UserGetWindowObject(hWndTop);
|
||||
UserRefObjectCo(TopWnd);
|
||||
co_IntSetActiveWindow(TopWnd);
|
||||
UserDerefObjectCo(TopWnd);
|
||||
}
|
||||
|
||||
hWndPrev = co_IntSetFocusWindow(Window);
|
||||
|
|
|
@ -305,7 +305,7 @@ BOOL FASTCALL ObmCreateHandleTable()
|
|||
PVOID mem;
|
||||
|
||||
//FIXME: dont alloc all at once! must be mapped into umode also...
|
||||
mem = ExAllocatePool(PagedPool, sizeof(USER_HANDLE_ENTRY) * 1024);
|
||||
mem = ExAllocatePool(PagedPool, sizeof(USER_HANDLE_ENTRY) * 1024*2);
|
||||
if (!mem)
|
||||
{
|
||||
DPRINT1("Failed creating handle table\n");
|
||||
|
@ -313,7 +313,7 @@ BOOL FASTCALL ObmCreateHandleTable()
|
|||
}
|
||||
|
||||
//FIXME: make auto growable
|
||||
UserInitHandleTable(&gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * 1024);
|
||||
UserInitHandleTable(&gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * 1024*2);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1452,7 +1452,12 @@ co_IntCreateWindowEx(DWORD dwExStyle,
|
|||
if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
|
||||
ParentWindowHandle = hWndParent;
|
||||
else
|
||||
OwnerWindowHandle = UserGetAncestor(hWndParent, GA_ROOT);
|
||||
{
|
||||
//temp hack
|
||||
PWINDOW_OBJECT Par = UserGetWindowObject(hWndParent);
|
||||
if (Par)
|
||||
OwnerWindowHandle = UserGetAncestor(Par, GA_ROOT)->hSelf;
|
||||
}
|
||||
}
|
||||
else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
|
||||
{
|
||||
|
@ -2622,27 +2627,20 @@ NtUserFlashWindowEx(DWORD Unknown0)
|
|||
/*
|
||||
* @implemented
|
||||
*/
|
||||
HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type)
|
||||
PWINDOW_OBJECT FASTCALL UserGetAncestor(PWINDOW_OBJECT Wnd, UINT Type)
|
||||
{
|
||||
PWINDOW_OBJECT Wnd, WndAncestor, Parent;
|
||||
HWND hWndAncestor;
|
||||
PWINDOW_OBJECT WndAncestor, Parent;
|
||||
|
||||
if (hWnd == IntGetDesktopWindow())
|
||||
if (Wnd->hSelf == IntGetDesktopWindow())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(Wnd = IntGetWindowObject(hWnd)))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case GA_PARENT:
|
||||
{
|
||||
WndAncestor = IntGetParentObject(Wnd);
|
||||
WndAncestor = Wnd->Parent;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2655,17 +2653,15 @@ HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type)
|
|||
for(;;)
|
||||
{
|
||||
tmp = Parent;
|
||||
if(!(Parent = IntGetParentObject(WndAncestor)))
|
||||
if(!(Parent = WndAncestor->Parent))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(IntIsDesktopWindow(Parent))
|
||||
{
|
||||
IntReleaseWindowObject(Parent);
|
||||
break;
|
||||
}
|
||||
if(tmp)
|
||||
IntReleaseWindowObject(tmp);
|
||||
|
||||
WndAncestor = Parent;
|
||||
}
|
||||
break;
|
||||
|
@ -2674,17 +2670,21 @@ HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type)
|
|||
case GA_ROOTOWNER:
|
||||
{
|
||||
WndAncestor = Wnd;
|
||||
IntReferenceWindowObject(WndAncestor);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
PWINDOW_OBJECT Old;
|
||||
Old = WndAncestor;
|
||||
Parent = IntGetParent(WndAncestor);
|
||||
IntReleaseWindowObject(Old);
|
||||
|
||||
if (!Parent)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//temp hack
|
||||
UserDerefObject(Parent);
|
||||
|
||||
WndAncestor = Parent;
|
||||
}
|
||||
break;
|
||||
|
@ -2692,18 +2692,11 @@ HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type)
|
|||
|
||||
default:
|
||||
{
|
||||
IntReleaseWindowObject(Wnd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
hWndAncestor = (WndAncestor ? WndAncestor->hSelf : NULL);
|
||||
IntReleaseWindowObject(Wnd);
|
||||
|
||||
if(WndAncestor && (WndAncestor != Wnd))
|
||||
IntReleaseWindowObject(WndAncestor);
|
||||
|
||||
return hWndAncestor;
|
||||
return WndAncestor;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2714,12 +2707,21 @@ HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type)
|
|||
HWND STDCALL
|
||||
NtUserGetAncestor(HWND hWnd, UINT Type)
|
||||
{
|
||||
PWINDOW_OBJECT Window, Ancestor;
|
||||
DECLARE_RETURN(HWND);
|
||||
|
||||
DPRINT("Enter NtUserGetAncestor\n");
|
||||
UserEnterExclusive();
|
||||
|
||||
if (!(Window = UserGetWindowObject(hWnd)))
|
||||
{
|
||||
RETURN(NULL);
|
||||
}
|
||||
|
||||
RETURN(UserGetAncestor(hWnd, Type));
|
||||
Ancestor = UserGetAncestor(Window, Type);
|
||||
/* faxme: can UserGetAncestor ever return NULL for a valid window? */
|
||||
|
||||
RETURN(Ancestor ? Ancestor->hSelf : NULL);
|
||||
|
||||
CLEANUP:
|
||||
DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_);
|
||||
|
|
|
@ -120,6 +120,24 @@ CLEANUP:
|
|||
END_CLEANUP;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* can_activate_window
|
||||
*
|
||||
* Check if we can activate the specified window.
|
||||
*/
|
||||
static BOOL FASTCALL can_activate_window( PWINDOW_OBJECT Wnd )
|
||||
{
|
||||
LONG style;
|
||||
|
||||
if (!Wnd) return FALSE;
|
||||
style = Wnd->Style;
|
||||
if (!(style & WS_VISIBLE)) return FALSE;
|
||||
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
|
||||
return !(style & WS_DISABLED);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* WinPosActivateOtherWindow
|
||||
*
|
||||
|
@ -128,7 +146,7 @@ CLEANUP:
|
|||
VOID FASTCALL
|
||||
co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window OPTIONAL)
|
||||
{
|
||||
PWINDOW_OBJECT Wnd, Old;
|
||||
PWINDOW_OBJECT Wnd;
|
||||
HWND Fg;
|
||||
|
||||
if (Window)
|
||||
|
@ -143,20 +161,8 @@ co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window OPTIONAL)
|
|||
/* If this is popup window, try to activate the owner first. */
|
||||
if ((Window->Style & WS_POPUP) && (Wnd = IntGetOwner(Window)))
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
Old = Wnd;
|
||||
Wnd = Wnd->Parent;
|
||||
if(IntIsDesktopWindow(Wnd))
|
||||
{
|
||||
Wnd = Old;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
|
||||
(Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
|
||||
goto done;
|
||||
Wnd = UserGetAncestor( Wnd, GA_ROOT );
|
||||
if (can_activate_window(Wnd)) goto done;
|
||||
}
|
||||
|
||||
/* Pick a next top-level window. */
|
||||
|
@ -840,9 +846,11 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
|
|||
&& HWND_NOTOPMOST != WinPos->hwndInsertAfter
|
||||
&& HWND_BOTTOM != WinPos->hwndInsertAfter)
|
||||
{
|
||||
PWINDOW_OBJECT Parent = Window->Parent;
|
||||
if (UserGetAncestor(WinPos->hwndInsertAfter, GA_PARENT) !=
|
||||
(Parent ? Parent->hSelf : NULL))
|
||||
PWINDOW_OBJECT InsAfterWnd, Parent = Window->Parent;
|
||||
|
||||
InsAfterWnd = UserGetWindowObject(WinPos->hwndInsertAfter);
|
||||
|
||||
if (InsAfterWnd && UserGetAncestor(InsAfterWnd, GA_PARENT) != Parent)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -932,7 +940,9 @@ co_WinPosSetWindowPos(
|
|||
|
||||
if ((WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) !=
|
||||
SWP_NOZORDER &&
|
||||
UserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow())
|
||||
// UserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow())
|
||||
//faxme: is WinPos.hwnd constant?? (WinPos.hwnd = Window->hSelf above)
|
||||
UserGetAncestor(Window, GA_PARENT)->hSelf == IntGetDesktopWindow())
|
||||
{
|
||||
WinPos.hwndInsertAfter = WinPosDoOwnedPopups(WinPos.hwnd, WinPos.hwndInsertAfter);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue