Fix maximize resize guard and add records
This commit is contained in:
+40
-6
@@ -661,7 +661,6 @@ int Window::runEventLoop()
|
||||
if (GetCursorPos(&pt))
|
||||
{
|
||||
ScreenToClient(this->hWnd, &pt);
|
||||
ExMessage mm;
|
||||
// 只分发给 window 层控件(因为 dialog 已经关闭或即将关闭)
|
||||
managedDispatchActive = true;
|
||||
dispatchSyntheticMouseMoveToControls((short)pt.x, (short)pt.y);
|
||||
@@ -692,17 +691,52 @@ int Window::runEventLoop()
|
||||
int actualWidth = clientRect.right - clientRect.left;
|
||||
int actualHeight = clientRect.bottom - clientRect.top;
|
||||
|
||||
const int virtualScreenWidth = (std::max)(1, GetSystemMetrics(SM_CXVIRTUALSCREEN));
|
||||
const int virtualScreenHeight = (std::max)(1, GetSystemMetrics(SM_CYVIRTUALSCREEN));
|
||||
const int maxReasonableWidth = (std::max)(10000, virtualScreenWidth * 2);
|
||||
const int maxReasonableHeight = (std::max)(10000, virtualScreenHeight * 2);
|
||||
|
||||
// 仅拦截“明显非法”的客户区尺寸,不再按“变化跨度”误杀正常最大化。
|
||||
if (actualWidth <= 0 || actualHeight <= 0
|
||||
|| actualWidth > maxReasonableWidth || actualHeight > maxReasonableHeight)
|
||||
{
|
||||
SX_LOGD("Resize")
|
||||
<< SX_T("尺寸调整被非法尺寸保护跳过:old=(", "Resize settle skipped by invalid-size guard: old=(")
|
||||
<< width << "x" << height
|
||||
<< SX_T(") pending=(", ") pending=(")
|
||||
<< pendingW << "x" << pendingH
|
||||
<< SX_T(") actual=(", ") actual=(")
|
||||
<< actualWidth << "x" << actualHeight
|
||||
<< SX_T(") virtual=(", ") virtual=(")
|
||||
<< virtualScreenWidth << "x" << virtualScreenHeight
|
||||
<< SX_T(") maxAllowed=(", ") maxAllowed=(")
|
||||
<< maxReasonableWidth << "x" << maxReasonableHeight
|
||||
<< SX_T(")", ")");
|
||||
needResizeDirty = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
const int finalW = (std::max)(minClientW, actualWidth);
|
||||
const int finalH = (std::max)(minClientH, actualHeight);
|
||||
|
||||
// 变化过大/异常场景保护
|
||||
if (finalW != width || finalH != height)
|
||||
{
|
||||
if (abs(finalW - width) > 1000 || abs(finalH - height) > 1000)
|
||||
const int diffW = abs(finalW - width);
|
||||
const int diffH = abs(finalH - height);
|
||||
if (diffW > 1000 || diffH > 1000)
|
||||
{
|
||||
// 认为是异常帧,跳过本次(不改变任何状态)
|
||||
needResizeDirty = false;
|
||||
continue;
|
||||
SX_LOGD("Resize")
|
||||
<< SX_T("检测到大跨度尺寸调整,继续执行收口:old=(", "Large-span resize detected; continue settle: old=(")
|
||||
<< width << "x" << height
|
||||
<< SX_T(") new=(", ") new=(")
|
||||
<< finalW << "x" << finalH
|
||||
<< SX_T(") diff=(", ") diff=(")
|
||||
<< diffW << "x" << diffH
|
||||
<< SX_T(") actual=(", ") actual=(")
|
||||
<< actualWidth << "x" << actualHeight
|
||||
<< SX_T(") virtual=(", ") virtual=(")
|
||||
<< virtualScreenWidth << "x" << virtualScreenHeight
|
||||
<< SX_T(")", ")");
|
||||
}
|
||||
|
||||
// 再次冻结窗口更新,保证批量绘制的原子性
|
||||
|
||||
Reference in New Issue
Block a user