BOOL FASTCALL co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd) { USER_REFERENCE_ENTRY RefPrev; PWND WndPrev; BOOL Ret = TRUE; if (hWndPrev && (WndPrev = ValidateHwndNoErr(hWndPrev))) { UserRefObjectCo(WndPrev, &RefPrev); if (co_IntSendMessageNoWait(hWndPrev, WM_NCACTIVATE, FALSE, 0)) //(LPARAM)hWnd)) { co_IntSendMessageNoWait(hWndPrev, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, WndPrev->style & WS_MINIMIZE), (LPARAM)hWnd); if (WndPrev) WndPrev->state &= ~WNDS_ACTIVEFRAME; } else { ERR("Application is keeping itself Active to prevent the change!\n"); Ret = FALSE; } UserDerefObjectCo(WndPrev); } return Ret; }
BOOL FASTCALL co_UserShowCaret(PWND Window OPTIONAL) { PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; PWND pWnd = NULL; if (Window) ASSERT_REFS_CO(Window); if(Window && Window->head.pti->pEThread != PsGetCurrentThread()) { EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } pti = PsGetCurrentThreadWin32Thread(); ThreadQueue = pti->MessageQueue; if(Window && ThreadQueue->CaretInfo->hWnd != Window->head.h) { EngSetLastError(ERROR_ACCESS_DENIED); return FALSE; } if (!ThreadQueue->CaretInfo->Visible) { ThreadQueue->CaretInfo->Visible = 1; pWnd = ValidateHwndNoErr(ThreadQueue->CaretInfo->hWnd); if (!ThreadQueue->CaretInfo->Showing && pWnd) { IntNotifyWinEvent(EVENT_OBJECT_SHOW, pWnd, OBJID_CARET, OBJID_CARET, 0); } IntSetTimer(pWnd, IDCARETTIMER, gpsi->dtCaretBlink, CaretSystemTimerProc, TMRF_SYSTEM); } return TRUE; }
BOOL FASTCALL co_IntMouseActivateWindow(PWND Wnd) { HWND Top; USER_REFERENCE_ENTRY Ref; ASSERT_REFS_CO(Wnd); if (Wnd->style & WS_DISABLED) { BOOL Ret; PWND TopWnd; PWND DesktopWindow = UserGetDesktopWindow(); if (DesktopWindow) { ERR("Window Diabled\n"); Top = IntFindChildWindowToOwner(DesktopWindow, Wnd); if ((TopWnd = ValidateHwndNoErr(Top))) { UserRefObjectCo(TopWnd, &Ref); Ret = co_IntMouseActivateWindow(TopWnd); UserDerefObjectCo(TopWnd); return Ret; } } return FALSE; } TRACE("Mouse Active\n"); co_IntSetForegroundAndFocusWindow(Wnd, TRUE); return TRUE; }
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 = UserGetDesktopWindow(); if (DesktopWindow) { Top = IntFindChildWindowToOwner(DesktopWindow, Wnd); if ((TopWnd = ValidateHwndNoErr(Top))) { UserRefObjectCo(TopWnd, &Ref); Ret = co_IntMouseActivateWindow(TopWnd); UserDerefObjectCo(TopWnd); return Ret; } } return FALSE; } TopWindow = UserGetAncestor(Wnd, GA_ROOT); //if (TopWindow) {ERR("MAW 2 pWnd %p hWnd %p\n",TopWindow,TopWindow->head.h);} if (!TopWindow) return FALSE; /* TMN: Check return value from this function? */ UserRefObjectCo(TopWindow, &Ref); co_IntSetForegroundAndFocusWindow(TopWindow, TRUE); UserDerefObjectCo(TopWindow); return TRUE; }
BOOL FASTCALL co_IntDestroyCaret(PTHREADINFO Win32Thread) { PUSER_MESSAGE_QUEUE ThreadQueue; PWND pWnd; ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue; if(!ThreadQueue || !ThreadQueue->CaretInfo) return FALSE; pWnd = ValidateHwndNoErr(ThreadQueue->CaretInfo->hWnd); co_IntHideCaret(ThreadQueue->CaretInfo); ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0; ThreadQueue->CaretInfo->hWnd = (HWND)0; ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0; ThreadQueue->CaretInfo->Showing = 0; ThreadQueue->CaretInfo->Visible = 0; if (pWnd) { IntNotifyWinEvent(EVENT_OBJECT_DESTROY, pWnd, OBJID_CARET, CHILDID_SELF, 0); } return TRUE; }
BOOL FASTCALL co_IntSendActivateMessages(PWND WindowPrev, PWND Window, BOOL MouseActivate, BOOL Async) { USER_REFERENCE_ENTRY Ref, RefPrev; HANDLE OldTID, NewTID; PTHREADINFO pti, ptiOld, ptiNew; BOOL InAAPM = FALSE; if (Window) { pti = PsGetCurrentThreadWin32Thread(); UserRefObjectCo(Window, &Ref); if (WindowPrev) UserRefObjectCo(WindowPrev, &RefPrev); /* Send palette messages */ if (gpsi->PUSIFlags & PUSIF_PALETTEDISPLAY && //co_IntPostOrSendMessage(UserHMGetHandle(Window), WM_QUERYNEWPALETTE, 0, 0)) co_IntSendMessage(UserHMGetHandle(Window), WM_QUERYNEWPALETTE, 0, 0)) { UserSendNotifyMessage( HWND_BROADCAST, WM_PALETTEISCHANGING, (WPARAM)UserHMGetHandle(Window), 0); } //// Fixes bug 7089. if (!(Window->style & WS_CHILD)) { PWND pwndTemp = co_GetDesktopWindow(Window)->spwndChild; while (pwndTemp && !(pwndTemp->style & WS_VISIBLE)) pwndTemp = pwndTemp->spwndNext; if (Window != pwndTemp || (WindowPrev && !IntIsWindowVisible(WindowPrev))) { if (!Async || pti->MessageQueue == gpqForeground) { UINT flags = SWP_NOSIZE | SWP_NOMOVE; if (Window == pwndTemp) flags |= SWP_NOACTIVATE; //ERR("co_IntSendActivateMessages SetWindowPos! Async %d pti Q == FGQ %d\n",Async,pti->MessageQueue == gpqForeground); co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0, flags); } } } //// //// CORE-1161 and CORE-6651 if (Window->spwndPrev) { HWND *phwndTopLevel, *phwndCurrent; PWND pwndCurrent, pwndDesktop; pwndDesktop = UserGetDesktopWindow(); if (Window->spwndParent == pwndDesktop ) { phwndTopLevel = IntWinListChildren(pwndDesktop); phwndCurrent = phwndTopLevel; while(*phwndCurrent) { pwndCurrent = UserGetWindowObject(*phwndCurrent); if (pwndCurrent && pwndCurrent->spwndOwner == Window ) { co_WinPosSetWindowPos(pwndCurrent, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE); } phwndCurrent++; } ExFreePool(phwndTopLevel); } } //// OldTID = WindowPrev ? IntGetWndThreadId(WindowPrev) : NULL; NewTID = IntGetWndThreadId(Window); ptiOld = WindowPrev ? WindowPrev->head.pti : NULL; ptiNew = Window->head.pti; //ERR("SendActivateMessage Old -> %x, New -> %x\n", OldTID, NewTID); if (!(pti->TIF_flags & TIF_INACTIVATEAPPMSG) && (!WindowPrev || OldTID != NewTID) ) { PWND cWindow; HWND *List, *phWnd; List = IntWinListChildren(UserGetDesktopWindow()); if ( List ) { if ( OldTID ) { ptiOld->TIF_flags |= TIF_INACTIVATEAPPMSG; // Note: Do not set pci flags, this does crash! for (phWnd = List; *phWnd; ++phWnd) { cWindow = ValidateHwndNoErr(*phWnd); if (cWindow && cWindow->head.pti == ptiOld) { // FALSE if the window is being deactivated, // ThreadId that owns the window being activated. co_IntSendMessageNoWait(*phWnd, WM_ACTIVATEAPP, FALSE, (LPARAM)NewTID); } } ptiOld->TIF_flags &= ~TIF_INACTIVATEAPPMSG; } if ( NewTID ) { //// Prevents a resource crash due to reentrance! InAAPM = TRUE; pti->TIF_flags |= TIF_INACTIVATEAPPMSG; //// for (phWnd = List; *phWnd; ++phWnd) { cWindow = ValidateHwndNoErr(*phWnd); if (cWindow && cWindow->head.pti == ptiNew) { // TRUE if the window is being activated, // ThreadId that owns the window being deactivated. co_IntSendMessageNoWait(*phWnd, WM_ACTIVATEAPP, TRUE, (LPARAM)OldTID); } } } ExFreePoolWithTag(List, USERTAG_WINDOWLIST); } } if (WindowPrev) UserDerefObjectCo(WindowPrev); // Now allow the previous window to die. if (Window->state & WNDS_ACTIVEFRAME) { // If already active frame do not allow NCPaint. //ERR("SendActivateMessage Is Active Frame!\n"); Window->state |= WNDS_NONCPAINT; } if (Window->style & WS_MINIMIZE) { TRACE("Widow was minimized\n"); } co_IntMakeWindowActive(Window); /* FIXME: IntIsWindow */ co_IntSendMessageNoWait( UserHMGetHandle(Window), WM_NCACTIVATE, (WPARAM)(Window == (gpqForeground ? gpqForeground->spwndActive : NULL)), 0); //(LPARAM)hWndPrev); co_IntSendMessageNoWait( UserHMGetHandle(Window), WM_ACTIVATE, MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, Window->style & WS_MINIMIZE), (LPARAM)(WindowPrev ? UserHMGetHandle(WindowPrev) : 0)); if (!Window->spwndOwner && !IntGetParent(Window)) { // FIXME lParam; The value is TRUE if the window is in full-screen mode, or FALSE otherwise. co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (WPARAM) UserHMGetHandle(Window), FALSE); } Window->state &= ~WNDS_NONCPAINT; UserDerefObjectCo(Window); } return InAAPM; }
/* * co_UserProcessHotKeys * * Sends WM_HOTKEY message if given keys are hotkey */ BOOL NTAPI co_UserProcessHotKeys(WORD wVk, BOOL bIsDown) { UINT fModifiers; PHOT_KEY pHotKey; PWND pWnd; BOOL DoNotPostMsg = FALSE; BOOL IsModifier = FALSE; if (wVk == VK_SHIFT || wVk == VK_CONTROL || wVk == VK_MENU || wVk == VK_LWIN || wVk == VK_RWIN) { /* Remember that this was a modifier */ IsModifier = TRUE; } fModifiers = IntGetModifiers(gafAsyncKeyState); if (bIsDown) { if (IsModifier) { /* Modifier key down -- no hotkey trigger, but remember this */ gfsModOnlyCandidate = fModifiers; return FALSE; } else { /* Regular key down -- check for hotkey, and reset mod candidates */ pHotKey = IsHotKey(fModifiers, wVk); gfsModOnlyCandidate = 0; } } else { if (IsModifier) { /* Modifier key up -- modifier-only keys are triggered here */ pHotKey = IsHotKey(gfsModOnlyCandidate, 0); gfsModOnlyCandidate = 0; } else { /* Regular key up -- no hotkey, but reset mod-only candidates */ gfsModOnlyCandidate = 0; return FALSE; } } if (pHotKey) { TRACE("Hot key pressed (pWnd %p, id %d)\n", pHotKey->pWnd, pHotKey->id); /* FIXME: See comment about "UserDebuggerHotKey" on top of this file. */ if (pHotKey->id == IDHK_SHIFTF12 || pHotKey->id == IDHK_F12) { if (bIsDown) { ERR("Hot key pressed for Debug Activation! ShiftF12 = %d or F12 = %d\n",pHotKey->id == IDHK_SHIFTF12 , pHotKey->id == IDHK_F12); //DoNotPostMsg = co_ActivateDebugger(); // FIXME } return DoNotPostMsg; } /* WIN and F12 keys are not hardcoded here. See comments on top of this file. */ if (pHotKey->id == IDHK_WINKEY) { ASSERT(!bIsDown); pWnd = ValidateHwndNoErr(InputWindowStation->ShellWindow); if (pWnd) { TRACE("System Hot key Id %d Key %u\n", pHotKey->id, wVk ); UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_TASKLIST, 0); co_IntShellHookNotify(HSHELL_TASKMAN, 0, 0); return FALSE; } } if (pHotKey->id == IDHK_SNAP_LEFT || pHotKey->id == IDHK_SNAP_RIGHT || pHotKey->id == IDHK_SNAP_UP || pHotKey->id == IDHK_SNAP_DOWN) { HWND topWnd = UserGetForegroundWindow(); if (topWnd) { UserPostMessage(topWnd, WM_KEYDOWN, wVk, 0); } return TRUE; } if (!pHotKey->pWnd) { TRACE("UPTM Hot key Id %d Key %u\n", pHotKey->id, wVk ); UserPostThreadMessage(pHotKey->pti, WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk)); //ptiLastInput = pHotKey->pti; return TRUE; /* Don't send any message */ } else { pWnd = pHotKey->pWnd; if (pWnd == PWND_BOTTOM) { if (gpqForeground == NULL) return FALSE; pWnd = gpqForeground->spwndFocus; } if (pWnd) { // pWnd->head.rpdesk->pDeskInfo->spwndShell needs testing. if (pWnd == ValidateHwndNoErr(InputWindowStation->ShellWindow) && pHotKey->id == SC_TASKLIST) { UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_TASKLIST, 0); co_IntShellHookNotify(HSHELL_TASKMAN, 0, 0); } else { TRACE("UPM Hot key Id %d Key %u\n", pHotKey->id, wVk ); UserPostMessage(UserHMGetHandle(pWnd), WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk)); } //ptiLastInput = pWnd->head.pti; return TRUE; /* Don't send any message */ } } } return FALSE; }
/* * co_UserProcessHotKeys * * Sends WM_HOTKEY message if given keys are hotkey */ BOOL NTAPI co_UserProcessHotKeys(WORD wVk, BOOL bIsDown) { UINT fModifiers; PHOT_KEY pHotKey; PWND pWnd; BOOL DoNotPostMsg = FALSE; if (wVk == VK_SHIFT || wVk == VK_CONTROL || wVk == VK_MENU || wVk == VK_LWIN || wVk == VK_RWIN) { /* Those keys are specified by modifiers */ wVk = 0; } fModifiers = IntGetModifiers(gafAsyncKeyState); /* Check if it is a hotkey */ pHotKey = IsHotKey(fModifiers, wVk); if (pHotKey) { TRACE("Hot key pressed (pWnd %p, id %d)\n", pHotKey->pWnd, pHotKey->id); /* FIXME: See comment about "UserDebuggerHotKey" on top of this file. */ if (pHotKey->id == IDHK_SHIFTF12 || pHotKey->id == IDHK_F12) { if (bIsDown) { ERR("Hot key pressed for Debug Activation! ShiftF12 = %d or F12 = %d\n",pHotKey->id == IDHK_SHIFTF12 , pHotKey->id == IDHK_F12); //DoNotPostMsg = co_ActivateDebugger(); // FIXME } return DoNotPostMsg; } /* Process hotkey if it is key up event */ if (!bIsDown) { /* WIN and F12 keys are not hardcoded here. See comments on top of this file. */ if (pHotKey->id == IDHK_WINKEY && bWinHotkeyActive) { pWnd = ValidateHwndNoErr(InputWindowStation->ShellWindow); if (pWnd) { TRACE("System Hot key Id %d Key %d\n",pHotKey->id, wVk ); UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_TASKLIST, 0); co_IntShellHookNotify(HSHELL_TASKMAN, 0, 0); bWinHotkeyActive = FALSE; return FALSE; } } } else { /* The user pressed the win key */ if (pHotKey->id == IDHK_WINKEY) { bWinHotkeyActive = TRUE; return FALSE; } } if (bIsDown) { if (!pHotKey->pWnd) { TRACE("UPTM Hot key Id %d Key %d\n",pHotKey->id, wVk ); UserPostThreadMessage(pHotKey->pti, WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk)); //ptiLastInput = pHotKey->pti; return TRUE; /* Don't send any message */ } else { if (pHotKey->pWnd == PWND_BOTTOM) { if (gpqForeground != NULL) { pWnd = gpqForeground->spwndFocus; } else return FALSE; } else { pWnd = pHotKey->pWnd; } if (pWnd) { // pWnd->head.rpdesk->pDeskInfo->spwndShell needs testing. if (pWnd == ValidateHwndNoErr(InputWindowStation->ShellWindow) && pHotKey->id == SC_TASKLIST) { ERR("Sending to shell window w/o IDHK_WINKEY..\n"); UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_TASKLIST, 0); } else { TRACE("UPM Hot key Id %d Key %d\n",pHotKey->id, wVk ); UserPostMessage(UserHMGetHandle(pWnd), WM_HOTKEY, pHotKey->id, MAKELONG(fModifiers, wVk)); } //ptiLastInput = pWnd->head.pti; return TRUE; /* Don't send any message */ } } } } return FALSE; }