| 348 | } |
| 349 | |
| 350 | SDL_HitTestResult OnWindowHitTest(SDL_Window* win, const SDL_Point* area, void* data) |
| 351 | { |
| 352 | SDLWindow* window = static_cast<SDLWindow*>(data); |
| 353 | const Float2 point(static_cast<float>(area->x), static_cast<float>(area->y)); |
| 354 | WindowHitCodes hit = window->OnWindowHit(point); |
| 355 | |
| 356 | #if PLATFORM_MAC |
| 357 | // HACK: Motion events are missing over special areas, try to track the mouse with hit test |
| 358 | Float2 mousePositionScreen; |
| 359 | if (hit != WindowHitCodes::Client && SDL_GetGlobalMouseState(&mousePositionScreen.X, &mousePositionScreen.Y) == 0) |
| 360 | { |
| 361 | const Float2 hitPositionScreen = window->ClientToScreen(point); |
| 362 | |
| 363 | // The hit tests does not always follow mouse, so only report tests close to mouse |
| 364 | if (Float2::Distance(hitPositionScreen, mousePositionScreen) <= 3) |
| 365 | Input::Mouse->OnMouseMove(hitPositionScreen, window); |
| 366 | } |
| 367 | #endif |
| 368 | |
| 369 | switch (hit) |
| 370 | { |
| 371 | case WindowHitCodes::Caption: |
| 372 | return SDL_HITTEST_DRAGGABLE; |
| 373 | case WindowHitCodes::TopLeft: |
| 374 | return SDL_HITTEST_RESIZE_TOPLEFT; |
| 375 | case WindowHitCodes::Top: |
| 376 | return SDL_HITTEST_RESIZE_TOP; |
| 377 | case WindowHitCodes::TopRight: |
| 378 | return SDL_HITTEST_RESIZE_TOPRIGHT; |
| 379 | case WindowHitCodes::Right: |
| 380 | return SDL_HITTEST_RESIZE_RIGHT; |
| 381 | case WindowHitCodes::BottomRight: |
| 382 | return SDL_HITTEST_RESIZE_BOTTOMRIGHT; |
| 383 | case WindowHitCodes::Bottom: |
| 384 | return SDL_HITTEST_RESIZE_BOTTOM; |
| 385 | case WindowHitCodes::BottomLeft: |
| 386 | return SDL_HITTEST_RESIZE_BOTTOMLEFT; |
| 387 | case WindowHitCodes::Left: |
| 388 | return SDL_HITTEST_RESIZE_LEFT; |
| 389 | default: |
| 390 | return SDL_HITTEST_NORMAL; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | SDLWindow* SDLWindow::GetWindowFromEvent(const SDL_Event& event) |
| 395 | { |
nothing calls this directly
no test coverage detected