void ff::ViewWindow::Activate() { assertRet(IsValid()); if (!_active) { _active = true; OnActivated(); Layout(); } }
void EyeXGaze::HandleActivatableEvent(TX_HANDLE hEvent, int interactorId) { TX_HANDLE hActivatable(TX_EMPTY_HANDLE); if (txGetEventBehavior(hEvent, &hActivatable, TX_BEHAVIORTYPE_ACTIVATABLE) == TX_RESULT_OK) { TX_ACTIVATABLEEVENTTYPE eventType; if(txGetActivatableEventType(hActivatable,&eventType)==TX_RESULT_OK) { if (eventType == TX_ACTIVATABLEEVENTTYPE_ACTIVATED) { OnActivated(hActivatable, interactorId); } else if (eventType == TX_ACTIVATABLEEVENTTYPE_ACTIVATIONFOCUSCHANGED) { OnActivationFocusChanged(hActivatable, interactorId); } } } txReleaseObject(&hActivatable); }
void SpecialMove::HandleSfxMessage( HOBJECT hSender, ILTMessage_Read *pMsg, uint8 nSfxId ) { switch( nSfxId ) { case SPECIALMOVEFX_ACTIVATED: { OnActivated(); } break; case SPECIALMOVEFX_RELEASED: { OnReleased(); } break; case SPECIALMOVEFX_LOOKEDAT: { OnLookedAt(); } break; } }
LRESULT WndProcFunc::WndProc(HWND wnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { auto app = Application::InstancePtr(); POINT pt; RECT rt; int key = 0; Vec2I size, pos; GetCursorPos(&pt); ScreenToClient(wnd, &pt); Vec2F cursorPos = Vec2F((float)pt.x, (float)-pt.y); if (app->mRender) cursorPos -= Vec2F(Math::Round(app->mRender->mResolution.x*0.5f), Math::Round(-app->mRender->mResolution.y*0.5f)); float wheelDelta; if (app->IsReady()) { switch (uMsg) { case WM_LBUTTONDOWN: SetCapture(app->mHWnd); app->mInput->OnCursorPressed(cursorPos); break; case WM_LBUTTONUP: app->mInput->OnCursorReleased(); ReleaseCapture(); break; case WM_RBUTTONDOWN: SetCapture(app->mHWnd); app->mInput->OnAltCursorPressed(cursorPos); break; case WM_RBUTTONUP: app->mInput->OnAltCursorReleased(); ReleaseCapture(); break; case WM_MBUTTONDOWN: SetCapture(app->mHWnd); app->mInput->OnAlt2CursorPressed(cursorPos); break; case WM_MBUTTONUP: app->mInput->OnAlt2CursorReleased(); ReleaseCapture(); break; case WM_KEYDOWN: key = (int)wParam; app->mInput->OnKeyPressed(key); break; case WM_KEYUP: app->mInput->OnKeyReleased((int)wParam); break; case WM_MOUSEMOVE: app->mInput->OnCursorMoved(cursorPos, 0); app->mInput->GetCursor()->delta -= app->mCursorCorrectionDelta; app->mCursorCorrectionDelta = Vec2F(); break; case WM_MOUSEWHEEL: wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam); app->mInput->OnMouseWheel(wheelDelta); break; case WM_ACTIVATEAPP: case WM_ENABLE: if (wParam == TRUE) { app->mActive = true; app->OnActivated(); app->onActivated.Invoke(); o2Events.OnApplicationActivated(); } else { app->mActive = false; app->OnDeactivated(); app->onDeactivated.Invoke(); o2Events.OnApplicationDeactivated(); } break; case WM_SIZE: GetWindowRect(app->mHWnd, &rt); size.x = rt.right - rt.left; size.y = rt.bottom - rt.top; if (size.x > 0 && size.y > 0 && size != app->mWindowedSize) { app->mWindowedSize = size; app->mRender->OnFrameResized(); app->onResizing.Invoke(); app->OnResizing(); o2Events.OnApplicationSized(); } app->ProcessFrame(); break; case WM_MOVE: GetWindowRect(app->mHWnd, &rt); pos.x = rt.left; pos.y = rt.top; if (pos.x < 10000 && pos.y < 10000 && pos != app->mWindowedPos) { app->mWindowedPos = pos; app->OnMoved(); app->onMoving.Invoke(); } break; case WM_DESTROY: PostQuitMessage(0); return 0; break; } } return DefWindowProc(wnd, uMsg, wParam, lParam); }
LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; static bool s_in_sizemove = false; static bool s_in_suspend = false; static bool s_minimized = false; auto game = reinterpret_cast<Game*>(GetWindowLongPtr(window, GWLP_USERDATA)); // process messages accordingly switch (message) { case WM_PAINT: hdc = BeginPaint(window, &ps); EndPaint(window, &ps); break; case WM_SIZE: if (wParam == SIZE_MINIMIZED) { if (!s_minimized) { s_minimized = true; if (!s_in_suspend && game) game->OnSuspending(); s_in_suspend = true; } } else if (s_minimized) { s_minimized = false; if (s_in_suspend && game) game->OnResuming(); s_in_suspend = false; } else if (!s_in_sizemove && game) { game->OnWindowSizeChanged(LOWORD(lParam), HIWORD(lParam)); } break; case WM_ENTERSIZEMOVE: s_in_sizemove = true; break; case WM_EXITSIZEMOVE: s_in_sizemove = false; if (game) { GetClientRect(window, &rc); game->OnWindowSizeChanged(rc.right - rc.left, rc.bottom - rc.top); } break; case WM_GETMINMAXINFO: { auto info = reinterpret_cast<MINMAXINFO*>(lParam); info->ptMinTrackSize.x = 1920; info->ptMinTrackSize.y = 1080; } break; case WM_ACTIVATEAPP: if (game) { if (wParam) { game->OnActivated(); game->MouseProcess(message, wParam, lParam); game->KeyboardProcess(message, wParam, lParam); } else { game->OnDeactivated(); } } break; case WM_POWERBROADCAST: switch (wParam) { case PBT_APMQUERYSUSPEND: if (!s_in_suspend && game) game->OnSuspending(); s_in_suspend = true; return true; case PBT_APMRESUMESUSPEND: if (!s_minimized) { if (s_in_suspend && game) game->OnResuming(); s_in_suspend = false; } return true; } break; case WM_DESTROY: PostQuitMessage(0); break; case WM_INPUT: case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MOUSEWHEEL: case WM_XBUTTONDOWN: case WM_XBUTTONUP: case WM_MOUSEHOVER: game->MouseProcess(message, wParam, lParam); break; case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: game->KeyboardProcess(message, wParam, lParam); break; case WM_CHAR: game->CharactersInput(wParam); break; } return DefWindowProc(window, message, wParam, lParam); }
[[nodiscard]] HRESULT CConsoleTSF::Initialize() { HRESULT hr; if (_spITfThreadMgr) { return S_FALSE; } // Activate per-thread Cicero in custom UI mode (TF_TMAE_UIELEMENTENABLEDONLY). hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); Init_CheckResult(); _fCoInitialized = TRUE; hr = _spITfThreadMgr.CoCreateInstance(CLSID_TF_ThreadMgr); Init_CheckResult(); hr = _spITfThreadMgr->Activate(&_tid); Init_CheckResult(); // Create Cicero document manager and input context. hr = _spITfThreadMgr->CreateDocumentMgr(&_spITfDocumentMgr); Init_CheckResult(); TfEditCookie ecTmp; hr = _spITfDocumentMgr->CreateContext(_tid, 0, static_cast<ITfContextOwnerCompositionSink*>(this), &_spITfInputContext, &ecTmp); Init_CheckResult(); // Set the context owner before attaching the context to the doc. CComQIPtr<ITfSource> spSrcIC(_spITfInputContext); hr = spSrcIC->AdviseSink(IID_ITfContextOwner, static_cast<ITfContextOwner*>(this), &_dwContextOwnerCookie); Init_CheckResult(); hr = _spITfDocumentMgr->Push(_spITfInputContext); Init_CheckResult(); // Collect the active keyboard layout info. CComPtr<ITfInputProcessorProfileMgr> spITfProfilesMgr; hr = spITfProfilesMgr.CoCreateInstance(CLSID_TF_InputProcessorProfiles); if (SUCCEEDED(hr)) { TF_INPUTPROCESSORPROFILE ipp; hr = spITfProfilesMgr->GetActiveProfile(GUID_TFCAT_TIP_KEYBOARD, &ipp); if (SUCCEEDED(hr)) { OnActivated(ipp.dwProfileType, ipp.langid, ipp.clsid, ipp.catid, ipp.guidProfile, ipp.hkl, ipp.dwFlags); } } Init_CheckResult(); // Setup some useful Cicero event sinks and callbacks. CComQIPtr<ITfSource> spSrcTIM(_spITfThreadMgr); CComQIPtr<ITfSourceSingle> spSrcICS(_spITfInputContext); hr = (spSrcTIM && spSrcIC && spSrcICS) ? S_OK : E_FAIL; Init_CheckResult(); hr = spSrcTIM->AdviseSink(IID_ITfInputProcessorProfileActivationSink, static_cast<ITfInputProcessorProfileActivationSink*>(this), &_dwActivationSinkCookie); Init_CheckResult(); hr = spSrcTIM->AdviseSink(IID_ITfUIElementSink, static_cast<ITfUIElementSink*>(this), &_dwUIElementSinkCookie); Init_CheckResult(); hr = spSrcIC->AdviseSink(IID_ITfTextEditSink, static_cast<ITfTextEditSink*>(this), &_dwTextEditSinkCookie); Init_CheckResult(); hr = spSrcICS->AdviseSingleSink(_tid, IID_ITfCleanupContextSink, static_cast<ITfCleanupContextSink*>(this)); Init_CheckResult(); return hr; }