| 698 | } |
| 699 | |
| 700 | void KNativeScreenSDL::recreateMainWindow() { |
| 701 | if (KSystem::videoOption != VIDEO_NO_WINDOW) { |
| 702 | destroyMainWindow(); |
| 703 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQuality.c_str()); |
| 704 | |
| 705 | int cx = input->width * input->scaleX / 100; |
| 706 | int cy = input->height * input->scaleY / 100; |
| 707 | int flags = SDL_WINDOW_HIDDEN | additionalSDLWindowFlags; |
| 708 | |
| 709 | visible = false; |
| 710 | |
| 711 | SDL_DisplayMode dm; |
| 712 | |
| 713 | if (SDL_GetDesktopDisplayMode(0, &dm) != 0) { |
| 714 | SDL_Log("SDL_GetDesktopDisplayMode failed: %s", SDL_GetError()); |
| 715 | fullScreen = FULLSCREEN_NOTSET; |
| 716 | } else { |
| 717 | if (fullScreen == FULLSCREEN_STRETCH) { |
| 718 | cx = dm.w; |
| 719 | cy = dm.h; |
| 720 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
| 721 | input->scaleX = dm.w * 100 / input->width; |
| 722 | input->scaleY = dm.h * 100 / input->height; |
| 723 | } else if (fullScreen == FULLSCREEN_ASPECT) { |
| 724 | cx = dm.w; |
| 725 | cy = dm.h; |
| 726 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
| 727 | input->scaleX = dm.w * 100 / input->width; |
| 728 | input->scaleY = dm.h * 100 / input->height; |
| 729 | input->scaleXOffset = 0; |
| 730 | input->scaleYOffset = 0; |
| 731 | if (input->scaleY > input->scaleX) { |
| 732 | input->scaleY = input->scaleX; |
| 733 | input->scaleYOffset = (dm.h - input->height * input->scaleY / 100) / 2; |
| 734 | } else if (input->scaleX > input->scaleY) { |
| 735 | input->scaleX = input->scaleY; |
| 736 | input->scaleXOffset = (dm.w - input->width * input->scaleX / 100) / 2; |
| 737 | } |
| 738 | } else if (input->width == (U32)dm.w && input->height == (U32)dm.h) { |
| 739 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
| 740 | } |
| 741 | if (cx > dm.w || cy > dm.h) { |
| 742 | cx = dm.w; |
| 743 | cy = dm.h; |
| 744 | input->scaleX = dm.w * 100 / input->width; |
| 745 | input->scaleY = dm.h * 100 / input->height; |
| 746 | flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | window = SDL_CreateWindow("BoxedWine", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, cx, cy, flags); |
| 751 | if (!window) { |
| 752 | klog_fmt("SDL_CreateWindow failed: %s", SDL_GetError()); |
| 753 | } |
| 754 | if (!(flags & SDL_WINDOW_VULKAN)) { |
| 755 | #if defined(BOXEDWINE_LINUX) || defined(__EMSCRIPTEN__) |
| 756 | // NVidia drivers need this |
| 757 | flags = SDL_RENDERER_SOFTWARE; |
no test coverage detected