diff --git a/src/main.cpp b/src/main.cpp index 23065d2..68b8c3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -236,6 +236,8 @@ static float g_borderlessDpi = 1.0f; // DPI scale, updated from SDL each f // Custom WndProc that removes the native title bar by extending the // client area to cover the entire window (WM_NCCALCSIZE) and provides // resize borders + caption drag zone (WM_NCHITTEST). +static void winlog(const char* fmt, ...); // [WINLOG] tracer (defined below) + static LRESULT CALLBACK BorderlessWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -315,6 +317,12 @@ static LRESULT CALLBACK BorderlessWndProc(HWND hwnd, UINT msg, // Scale min window size by DPI so it matches the SDL-side minimum. mmi->ptMinTrackSize.x = (LONG)(1024 * g_borderlessDpi); mmi->ptMinTrackSize.y = (LONG)(720 * g_borderlessDpi); + static float s_lastBd = -1.0f; // [WINLOG] log only when g_borderlessDpi changes (this fires a lot) + if (g_borderlessDpi != s_lastBd) { + s_lastBd = g_borderlessDpi; + winlog("WM_GETMINMAXINFO g_borderlessDpi=%.3f -> minTrack=%ldx%ld", + g_borderlessDpi, (long)mmi->ptMinTrackSize.x, (long)mmi->ptMinTrackSize.y); + } return 0; } } @@ -556,6 +564,18 @@ static void winlogState(SDL_Window* w, const char* tag) SDL_DisplayID did = SDL_GetDisplayForWindow(w); winlog("%-20s size=%dx%d px=%dx%d min=%dx%d dispScale=%.3f storedScale=%.3f display=%u", tag, sw, sh, pw, ph, mw, mh, ds, st, (unsigned)did); +#ifdef _WIN32 + HWND hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(w), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr); + if (hwnd) { + RECT wr = {}, cr = {}; + GetWindowRect(hwnd, &wr); + GetClientRect(hwnd, &cr); + winlog("%-20s native win=%ldx%ld client=%ldx%ld pos=%ld,%ld", + tag, (long)(wr.right - wr.left), (long)(wr.bottom - wr.top), + (long)(cr.right - cr.left), (long)(cr.bottom - cr.top), (long)wr.left, (long)wr.top); + } +#endif } // Handle SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED: save the old-scale size, @@ -1364,6 +1384,7 @@ int main(int argc, char* argv[]) winlog("RETRY done: reached target %dx%d", dpiTargetW, dpiTargetH); dpiResizeRetries = 0; } + if (dpiResizeRetries == 1) winlogState(window, "RETRY-last(stuck?)"); --dpiResizeRetries; needsRedraw = true; }