| 120 | } |
| 121 | |
| 122 | static Config::Resolution getSaneWindowedResolution(uint32_t displayIndex, Config::Resolution preferredResolution) |
| 123 | { |
| 124 | const auto desktopResolution = getDesktopResolution(displayIndex); |
| 125 | constexpr int32_t kMinWidth = 640; |
| 126 | constexpr int32_t kMinHeight = 480; |
| 127 | constexpr int32_t kWindowMargin = 160; |
| 128 | |
| 129 | auto maxWidth = std::max(kMinWidth, desktopResolution.width - kWindowMargin); |
| 130 | auto maxHeight = std::max(kMinHeight, desktopResolution.height - kWindowMargin); |
| 131 | |
| 132 | if (!preferredResolution.isPositive() |
| 133 | || preferredResolution.width >= desktopResolution.width |
| 134 | || preferredResolution.height >= desktopResolution.height) |
| 135 | { |
| 136 | return { |
| 137 | std::clamp(desktopResolution.width * 4 / 5, kMinWidth, maxWidth), |
| 138 | std::clamp(desktopResolution.height * 4 / 5, kMinHeight, maxHeight) |
| 139 | }; |
| 140 | } |
| 141 | |
| 142 | return { |
| 143 | std::clamp(preferredResolution.width, kMinWidth, maxWidth), |
| 144 | std::clamp(preferredResolution.height, kMinHeight, maxHeight) |
| 145 | }; |
| 146 | } |
| 147 | |
| 148 | static Point getCenteredPositionOnDisplay(uint32_t displayIndex, int32_t width, int32_t height) |
| 149 | { |
no test coverage detected