| 3021 | } |
| 3022 | |
| 3023 | void ImageViewer::updateCurrentMonitorSize() { |
| 3024 | if (GLFWmonitor* monitor = glfwGetWindowCurrentMonitor(m_glfw_window)) { |
| 3025 | Vector2i pos{0}, size{0}; |
| 3026 | glfwGetMonitorWorkarea(monitor, &pos.x(), &pos.y(), &size.x(), &size.y()); |
| 3027 | if (size == Vector2i{0, 0}) { |
| 3028 | return; |
| 3029 | } |
| 3030 | |
| 3031 | const auto padding = framePadding(m_glfw_window); |
| 3032 | pos += padding.topLeft; |
| 3033 | size -= padding.topLeft + padding.bottomRight; |
| 3034 | |
| 3035 | // On some systems (notably Hyprland and some other tiling window managers / compositors), windows are always flagged as |
| 3036 | // maximized, even if they are technically not, to get them to play nicely with decorations. In the following, we detect |
| 3037 | // such cases (only after a current monitor was detected to give enough time for the compositor to set up the window) and |
| 3038 | // treat them as non-maximized always. |
| 3039 | if (isMaximized() && !mMaximizedLaunch) { |
| 3040 | tlog::debug("Detected unreliable maximized state; disabling maximized detection."); |
| 3041 | mMaximizedUnreliable = true; |
| 3042 | } |
| 3043 | |
| 3044 | auto posf = Vector2f{pos}; |
| 3045 | auto sizef = Vector2f{size}; |
| 3046 | |
| 3047 | #if defined(_WIN32) || defined(__linux__) || defined(EMSCRIPTEN) |
| 3048 | posf = posf / pixel_ratio(); |
| 3049 | sizef = sizef / pixel_ratio(); |
| 3050 | #endif |
| 3051 | |
| 3052 | if (posf == mMinWindowPos && sizef == mMaxWindowSize) { |
| 3053 | return; |
| 3054 | } |
| 3055 | |
| 3056 | mMinWindowPos = posf; |
| 3057 | mMaxWindowSize = sizef; |
| 3058 | |
| 3059 | tlog::debug("Current monitor: pos={} size={}", mMinWindowPos, mMaxWindowSize); |
| 3060 | } |
| 3061 | } |
| 3062 | |
| 3063 | } // namespace tev |
nothing calls this directly
no test coverage detected