#include "WindowMessageDispatchHandlers.h" #include "Platform/Win32/EditorWindow.h" #include "WindowMessageHost.h" namespace XCEngine::UI::Editor::Host { namespace { bool EnsureTrackingMouseLeave(const WindowMessageDispatchContext& context) { if (context.window.IsTrackingMouseLeave()) { return true; } TRACKMOUSEEVENT trackMouseEvent = {}; trackMouseEvent.cbSize = sizeof(trackMouseEvent); trackMouseEvent.dwFlags = TME_LEAVE; trackMouseEvent.hwndTrack = context.hwnd; if (!TrackMouseEvent(&trackMouseEvent)) { return false; } context.window.SetTrackingMouseLeave(true); return true; } bool TryHandleChromeHoverConsumption( const WindowMessageDispatchContext& context, LPARAM lParam, LRESULT& outResult) { const bool resizeHoverChanged = context.window.UpdateBorderlessWindowResizeHover(lParam); if (context.window.UpdateBorderlessWindowChromeHover(lParam)) { context.window.InvalidateHostWindow(); } if (resizeHoverChanged) { context.window.InvalidateHostWindow(); } EnsureTrackingMouseLeave(context); if (context.window.HasHoveredBorderlessResizeEdge()) { outResult = 0; return true; } const BorderlessWindowChromeHitTarget chromeHitTarget = context.window.HitTestBorderlessWindowChrome(lParam); if (chromeHitTarget == BorderlessWindowChromeHitTarget::MinimizeButton || chromeHitTarget == BorderlessWindowChromeHitTarget::MaximizeRestoreButton || chromeHitTarget == BorderlessWindowChromeHitTarget::CloseButton) { outResult = 0; return true; } return false; } } // namespace bool TryDispatchWindowPointerMessage( const WindowMessageDispatchContext& context, UINT message, WPARAM wParam, LPARAM lParam, LRESULT& outResult) { switch (message) { case WM_MOUSEMOVE: if (context.windowHost.HandleGlobalTabDragPointerMove(context.hwnd)) { outResult = 0; return true; } if (context.window.HandleBorderlessWindowResizePointerMove( context.windowHost.GetEditorContext(), context.windowHost.IsGlobalTabDragActive())) { outResult = 0; return true; } if (context.window.HandleBorderlessWindowChromeDragRestorePointerMove( context.windowHost.GetEditorContext(), context.windowHost.IsGlobalTabDragActive())) { outResult = 0; return true; } if (TryHandleChromeHoverConsumption(context, lParam, outResult)) { return true; } context.window.QueuePointerEvent( ::XCEngine::UI::UIInputEventType::PointerMove, ::XCEngine::UI::UIPointerButton::None, wParam, lParam); outResult = 0; return true; case WM_MOUSELEAVE: context.window.SetTrackingMouseLeave(false); context.window.ClearBorderlessWindowResizeState(); context.window.ClearBorderlessWindowChromeDragRestoreState(); context.window.ClearBorderlessWindowChromeState(); context.window.QueuePointerLeaveEvent(); outResult = 0; return true; case WM_LBUTTONDOWN: if (context.window.HandleBorderlessWindowResizeButtonDown(lParam)) { outResult = 0; return true; } if (context.window.HandleBorderlessWindowChromeButtonDown(lParam)) { outResult = 0; return true; } SetFocus(context.hwnd); context.window.QueuePointerEvent( ::XCEngine::UI::UIInputEventType::PointerButtonDown, ::XCEngine::UI::UIPointerButton::Left, wParam, lParam); outResult = 0; return true; case WM_LBUTTONUP: if (context.windowHost.HandleGlobalTabDragPointerButtonUp(context.hwnd)) { outResult = 0; return true; } if (context.window.HandleBorderlessWindowResizeButtonUp()) { outResult = 0; return true; } if (context.window.HandleBorderlessWindowChromeButtonUp( context.windowHost.GetEditorContext(), context.windowHost.IsGlobalTabDragActive(), lParam)) { outResult = 0; return true; } context.window.QueuePointerEvent( ::XCEngine::UI::UIInputEventType::PointerButtonUp, ::XCEngine::UI::UIPointerButton::Left, wParam, lParam); outResult = 0; return true; case WM_LBUTTONDBLCLK: if (context.window.HandleBorderlessWindowChromeDoubleClick( context.windowHost.GetEditorContext(), context.windowHost.IsGlobalTabDragActive(), lParam)) { outResult = 0; return true; } return false; case WM_MOUSEWHEEL: context.window.QueuePointerWheelEvent(GET_WHEEL_DELTA_WPARAM(wParam), wParam, lParam); outResult = 0; return true; default: return false; } } } // namespace XCEngine::UI::Editor::Host