BOOL FASTCALL co_IntMouseActivateWindow(PWND Wnd) { HWND Top; PWND TopWindow; USER_REFERENCE_ENTRY Ref; ASSERT_REFS_CO(Wnd); if(Wnd->style & WS_DISABLED) { BOOL Ret; PWND TopWnd; PWND DesktopWindow = UserGetWindowObject(IntGetDesktopWindow()); if(DesktopWindow) { Top = IntFindChildWindowToOwner(DesktopWindow, Wnd); if((TopWnd = UserGetWindowObject(Top))) { UserRefObjectCo(TopWnd, &Ref); Ret = co_IntMouseActivateWindow(TopWnd); UserDerefObjectCo(TopWnd); return Ret; } } return FALSE; } TopWindow = UserGetAncestor(Wnd, GA_ROOT); if (!TopWindow) return FALSE; /* TMN: Check return valud from this function? */ UserRefObjectCo(TopWindow, &Ref); co_IntSetForegroundAndFocusWindow(TopWindow, Wnd, TRUE); UserDerefObjectCo(TopWindow); return TRUE; }
BOOL FASTCALL UserRegisterUserApiHook( PUNICODE_STRING pstrDllName, PUNICODE_STRING pstrFuncName) { PTHREADINFO pti, ptiCurrent; HWND *List; PWND DesktopWindow, pwndCurrent; ULONG i; PPROCESSINFO ppiCsr; pti = PsGetCurrentThreadWin32Thread(); ppiCsr = PsGetProcessWin32Process(gpepCSRSS); /* Fail if the api hook is already registered */ if(gpsi->dwSRVIFlags & SRVINFO_APIHOOK) { return FALSE; } TRACE("UserRegisterUserApiHook. Server PID: %p\n", PsGetProcessId(pti->ppi->peProcess)); /* Register the api hook */ gpsi->dwSRVIFlags |= SRVINFO_APIHOOK; strUahModule = *pstrDllName; strUahInitFunc = *pstrFuncName; ppiUahServer = pti->ppi; /* Broadcast an internal message to every top level window */ DesktopWindow = UserGetWindowObject(IntGetDesktopWindow()); List = IntWinListChildren(DesktopWindow); if (List != NULL) { for (i = 0; List[i]; i++) { pwndCurrent = UserGetWindowObject(List[i]); if(pwndCurrent == NULL) { continue; } ptiCurrent = pwndCurrent->head.pti; /* FIXME: The first check is a reactos specific hack for system threads */ if(PsIsSystemProcess(ptiCurrent->ppi->peProcess) || ptiCurrent->ppi == ppiCsr) { continue; } co_MsqSendMessageAsync( ptiCurrent, 0, WH_APIHOOK, FALSE, /* Load the module */ 0, NULL, 0, FALSE, MSQ_INJECTMODULE); } ExFreePoolWithTag(List, USERTAG_WINDOWLIST); } return TRUE; }
VOID FASTCALL DceUpdateVisRgn(DCE *Dce, PWND Window, ULONG Flags) { PREGION RgnVisible = NULL; ULONG DcxFlags; PWND DesktopWindow; if (Flags & DCX_PARENTCLIP) { PWND Parent; Parent = Window->spwndParent; if (!Parent) { RgnVisible = NULL; goto noparent; } if (Parent->style & WS_CLIPSIBLINGS) { DcxFlags = DCX_CLIPSIBLINGS | (Flags & ~(DCX_CLIPCHILDREN | DCX_WINDOW)); } else { DcxFlags = Flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW); } RgnVisible = DceGetVisRgn(Parent, DcxFlags, Window->head.h, Flags); } else if (Window == NULL) { DesktopWindow = UserGetWindowObject(IntGetDesktopWindow()); if (NULL != DesktopWindow) { RgnVisible = IntSysCreateRectpRgnIndirect(&DesktopWindow->rcWindow); } else { RgnVisible = NULL; } } else { RgnVisible = DceGetVisRgn(Window, Flags, 0, 0); } noparent: if (Flags & DCX_INTERSECTRGN) { PREGION RgnClip = NULL; if (Dce->hrgnClip != NULL) RgnClip = REGION_LockRgn(Dce->hrgnClip); if (RgnClip) { IntGdiCombineRgn(RgnVisible, RgnVisible, RgnClip, RGN_AND); REGION_UnlockRgn(RgnClip); } else { if (RgnVisible != NULL) { REGION_Delete(RgnVisible); } RgnVisible = IntSysCreateRectpRgn(0, 0, 0, 0); } } else if ((Flags & DCX_EXCLUDERGN) && Dce->hrgnClip != NULL) { PREGION RgnClip = REGION_LockRgn(Dce->hrgnClip); IntGdiCombineRgn(RgnVisible, RgnVisible, RgnClip, RGN_DIFF); REGION_UnlockRgn(RgnClip); } Dce->DCXFlags &= ~DCX_DCEDIRTY; GdiSelectVisRgn(Dce->hDC, RgnVisible); /* Tell GDI driver */ if (Window) IntEngWindowChanged(Window, WOC_RGN_CLIENT); if (RgnVisible != NULL) { REGION_Delete(RgnVisible); } }
VOID FASTCALL co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) { USER_REFERENCE_ENTRY Ref, RefPrev; PWND Window, WindowPrev = NULL; if ((Window = UserGetWindowObject(hWnd))) { UserRefObjectCo(Window, &Ref); WindowPrev = UserGetWindowObject(hWndPrev); if (WindowPrev) UserRefObjectCo(WindowPrev, &RefPrev); /* Send palette messages */ if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) { UserSendNotifyMessage( HWND_BROADCAST, WM_PALETTEISCHANGING, (WPARAM)hWnd, 0); } if (Window->spwndPrev != NULL) co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); if (!Window->spwndOwner && !IntGetParent(Window)) { co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd); } if (Window) { // Set last active for window and it's owner. Window->hWndLastActive = hWnd; if (Window->spwndOwner) Window->spwndOwner->hWndLastActive = hWnd; Window->state |= WNDS_ACTIVEFRAME; } if (WindowPrev) WindowPrev->state &= ~WNDS_ACTIVEFRAME; if (Window && WindowPrev) { PWND cWindow; HWND *List, *phWnd; HANDLE OldTID = IntGetWndThreadId(WindowPrev); HANDLE NewTID = IntGetWndThreadId(Window); TRACE("SendActiveMessage Old -> %x, New -> %x\n", OldTID, NewTID); if (Window->style & WS_MINIMIZE) { TRACE("Widow was minimized\n"); } if (OldTID != NewTID) { List = IntWinListChildren(UserGetWindowObject(IntGetDesktopWindow())); if (List) { for (phWnd = List; *phWnd; ++phWnd) { cWindow = UserGetWindowObject(*phWnd); if (cWindow && (IntGetWndThreadId(cWindow) == OldTID)) { // FALSE if the window is being deactivated, // ThreadId that owns the window being activated. co_IntSendMessageNoWait(*phWnd, WM_ACTIVATEAPP, FALSE, (LPARAM)NewTID); } } for (phWnd = List; *phWnd; ++phWnd) { cWindow = UserGetWindowObject(*phWnd); if (cWindow && (IntGetWndThreadId(cWindow) == NewTID)) { // TRUE if the window is being activated, // ThreadId that owns the window being deactivated. co_IntSendMessageNoWait(*phWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)OldTID); } } ExFreePool(List); } } UserDerefObjectCo(WindowPrev); // Now allow the previous window to die. } UserDerefObjectCo(Window); /* FIXME: IntIsWindow */ co_IntSendMessageNoWait(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0); /* FIXME: WA_CLICKACTIVE */ co_IntSendMessageNoWait(hWnd, WM_ACTIVATE, MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, Window->style & WS_MINIMIZE), (LPARAM)hWndPrev); } }