| 439 | } |
| 440 | |
| 441 | void Sdl3Ui::ToggleZoom() { |
| 442 | #ifdef SUPPORT_ZOOM |
| 443 | BeginDisplayModeChange(); |
| 444 | // Work around a SDL bug which doesn't demaximize the window when the size |
| 445 | // is changed |
| 446 | int flags = SDL_GetWindowFlags(sdl_window); |
| 447 | if ((flags & SDL_WINDOW_MAXIMIZED) == SDL_WINDOW_MAXIMIZED) { |
| 448 | SDL_RestoreWindow(sdl_window); |
| 449 | } |
| 450 | |
| 451 | // get current window size, calculate next bigger zoom factor |
| 452 | int w, h; |
| 453 | SDL_GetWindowSize(sdl_window, &w, &h); |
| 454 | last_display_mode.zoom = std::min(w / main_surface->width(), h / main_surface->height()); |
| 455 | current_display_mode.zoom = last_display_mode.zoom + 1; |
| 456 | |
| 457 | // get maximum usable window size |
| 458 | int display_index = SDL_GetDisplayForWindow(sdl_window); |
| 459 | SDL_Rect max_mode; |
| 460 | // this takes account of the menu bar and dock on macOS and task bar on windows |
| 461 | SDL_GetDisplayUsableBounds(display_index, &max_mode); |
| 462 | |
| 463 | // reset zoom, if it does not fit |
| 464 | if ((max_mode.h < main_surface->height() * current_display_mode.zoom) || |
| 465 | (max_mode.w < main_surface->width() * current_display_mode.zoom)) { |
| 466 | current_display_mode.zoom = 1; |
| 467 | } |
| 468 | EndDisplayModeChange(); |
| 469 | #endif |
| 470 | } |
| 471 | |
| 472 | bool Sdl3Ui::ProcessEvents() { |
| 473 | #if defined(__WIIU__) |