diff options
Diffstat (limited to 'alf/alf.cpp')
| -rw-r--r-- | alf/alf.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp index 77fe344..f914e55 100644 --- a/alf/alf.cpp +++ b/alf/alf.cpp @@ -75,11 +75,9 @@ ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv) } void -ALF_RecalculateLayout(HWND hwnd) +ALF_InvalidateLayout(HWND hwnd) { - SIZE dummy; - SendMessage(hwnd, ALF_WM_QUERYSIZE, 0, (LPARAM)&dummy); - SendMessage(hwnd, ALF_WM_APPLYLAYOUT, 0, 0); + SendMessage(hwnd, ALF_WM_INVALIDATELAYOUT, 0, 0); } static void @@ -230,11 +228,21 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) ALF_Layout_Apply(&priv->layout, hwnd); } + if (msg == WM_SHOWWINDOW) { + if (wparam) + ALF_Layout_Validate(&priv->layout, hwnd); + } + if (msg == WM_GETMINMAXINFO) { RECT tmp; ZeroMemory(&tmp, sizeof(tmp)); - tmp.right = priv->layout.totalMinWidth; - tmp.bottom = priv->layout.totalMinHeight; + + SIZE s; + ZeroMemory(&s, sizeof(s)); + ALF_Layout_GetMinSize(&priv->layout, hwnd, &s); + + tmp.right = s.cx; + tmp.bottom = s.cy; if (ALF_Compat_AdjustWindowRectExForDpi( &tmp, @@ -259,7 +267,6 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) SendMessage(hwnd, WM_UPDATEUISTATE, MAKEWPARAM(UIS_INITIALIZE, 0), 0); } ALF_UpdateFontsPriv(hwnd, priv); - ALF_Layout_CalcSizes(&priv->layout, hwnd); ALF_Layout_Apply(&priv->layout, hwnd); } @@ -282,15 +289,14 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) if (msg == WM_DPICHANGED) { ALF_UpdateFontsPriv(hwnd, priv); - ALF_Layout_CalcSizes(&priv->layout, hwnd); + ALF_Layout_Invalidate(&priv->layout, hwnd); RECT *r = (RECT*)lparam; SetWindowPos(hwnd, NULL, r->left, r->top, r->right-r->left, r->bottom-r->top, SWP_NOACTIVATE|SWP_NOZORDER); } if (msg == WM_THEMECHANGED || msg == WM_SETTINGCHANGE) { ALF_UpdateFontsPriv(hwnd, priv); - ALF_Layout_CalcSizes(&priv->layout, hwnd); - ALF_Layout_Apply(&priv->layout, hwnd); + ALF_Layout_Invalidate(&priv->layout, hwnd); } if (msg == DM_GETDEFID) { @@ -318,6 +324,15 @@ ALF_DefWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) LRESULT ret = 0; if (ALF_Layout_HandleMessage(&priv->layout, hwnd, msg, wparam, lparam, &ret)) { + // if the layout was changed, our current size might be too small + // windows will call WM_GETMINMAXINFO and fix it + if (msg == ALF_WM_VALIDATELAYOUT) { + RECT r; + if (GetWindowRect(hwnd, &r)) { + SetWindowPos(hwnd, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); + } + } + return ret; } |
