Skip to content

Commit af9316f

Browse files
[wsi] Handle attached but not drawn menus in getWindowSize
1 parent 13f2afc commit af9316f

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎src/wsi/win32/wsi_window_win32.cpp‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,31 @@ namespace dxvk::wsi {
106106
HWND hWindow,
107107
uint32_t* pWidth,
108108
uint32_t* pHeight) {
109+
uint32_t reservedMenuHeight = 0u;
110+
109111
RECT rect = { };
110112
::GetClientRect(hWindow, &rect);
113+
114+
HMENU menu = ::GetMenu(hWindow);
115+
if (menu) {
116+
RECT noMenu = { };
117+
118+
const LONG style = ::GetWindowLongW(hWindow, GWL_STYLE);
119+
const LONG exStyle = ::GetWindowLongW(hWindow, GWL_EXSTYLE);
120+
121+
::AdjustWindowRectEx(&noMenu, style, FALSE, exStyle);
122+
// No adjustments being made without a menu, while we have a menu
123+
// attached to the window, means we're dealing with a menu that's
124+
// not currently drawn, but still reserves height in ::GetClientRect
125+
if (!noMenu.right && !noMenu.left && !noMenu.bottom && !noMenu.top)
126+
::AdjustWindowRectEx(&rect, style, TRUE, exStyle);
127+
}
111128

112129
if (pWidth)
113130
*pWidth = rect.right - rect.left;
114131

115132
if (pHeight)
116-
*pHeight = rect.bottom - rect.top;
133+
*pHeight = rect.bottom - rect.top + reservedMenuHeight;
117134
}
118135

119136

0 commit comments

Comments
 (0)