MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / SetWindowMode

Method SetWindowMode

engine/PoseidonGL33/EngineGL33_Lifecycle.cpp:653–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653bool EngineGL33::SetWindowMode(WindowMode mode)
654{
655 if (!_sdlWindow)
656 return false;
657 const WindowMode previousMode = _windowMode;
658 LOG_DEBUG(Graphics, "GL33: SetWindowMode requesting {}",
659 mode == WindowMode::Fullscreen ? "fullscreen"
660 : mode == WindowMode::Borderless ? "borderless"
661 : "windowed");
662 if (_sdlWindow && _windowed && mode != WindowMode::Windowed)
663 SDL_GetWindowSize(_sdlWindow, &_windowedRestoreW, &_windowedRestoreH);
664 _windowMode = mode;
665 _pendingExclusiveEnter = (mode == WindowMode::Fullscreen && _windowed);
666
667 // Build a synthetic DisplayConfig so we can route through the
668 // shared resolver — keeps the "borderless covers monitor" rule in
669 // exactly one place (WindowPlacement.cpp) and makes runtime mode
670 // toggles match the initial-create behaviour bit-for-bit.
671 DisplayPlacementInput synth;
672 synth.displayMode = (mode == WindowMode::Fullscreen) ? "exclusive"
673 : (mode == WindowMode::Borderless) ? "borderless"
674 : "windowed";
675 synth.width = _w;
676 synth.height = _h;
677 if (_sdlWindow && mode == WindowMode::Windowed)
678 {
679 if (previousMode != WindowMode::Windowed)
680 {
681 synth.width = _windowedRestoreW > 0 ? _windowedRestoreW : synth.width;
682 synth.height = _windowedRestoreH > 0 ? _windowedRestoreH : synth.height;
683 }
684 else if (_windowed)
685 {
686 WindowMetrics metrics;
687 SDL_GetWindowSize(_sdlWindow, &metrics.logicalWidth, &metrics.logicalHeight);
688 metrics.drawableWidth = _w;
689 metrics.drawableHeight = _h;
690 std::tie(synth.width, synth.height) = GetWindowedModeSize(metrics);
691 }
692 else
693 {
694 synth.width = _windowedRestoreW > 0 ? _windowedRestoreW : synth.width;
695 synth.height = _windowedRestoreH > 0 ? _windowedRestoreH : synth.height;
696 }
697 }
698 synth.refresh = _refreshRate;
699
700 int desktopW = 0, desktopH = 0, desktopRefresh = 0;
701 const SDL_DisplayID disp = SDL_GetDisplayForWindow(_sdlWindow);
702 if (const SDL_DisplayMode* dm = SDL_GetDesktopDisplayMode(disp ? disp : SDL_GetPrimaryDisplay()))
703 {
704 desktopW = dm->w;
705 desktopH = dm->h;
706 desktopRefresh = (int)(dm->refresh_rate + 0.5f);
707 }
708 const WindowPlacement p = ResolveWindowPlacement(synth, desktopW, desktopH, desktopRefresh);
709
710 // Windowed: leave fullscreen first so size/border/pos edits land on

Callers 2

HandleEventsMethod · 0.45

Calls 4

GetWindowedModeSizeFunction · 0.85
ResolveWindowPlacementFunction · 0.85
LogExclusiveModeStatusFunction · 0.85

Tested by

no test coverage detected