Fix imgui window resizing and dragging issue while undocking.

This commit is contained in:
Mohit Sethi 2022-11-25 21:32:36 +05:30
parent d516e66801
commit 359bcc31d0

View File

@ -490,7 +490,9 @@ static void releaseMonitor(_GLFWwindow* window)
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam)
{
static RECT border_thickness;
static RECT border_thickness = { 0, 0, 0, 0 };
if (!_glfw.hints.window.titlebar)
SetRect(&border_thickness, 8, 8, 8, 8);
_GLFWwindow* window = GetPropW(hWnd, L"GLFW");
if (!window)
@ -548,22 +550,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (_glfw.hints.window.titlebar)
break;
//find border thickness
SetRectEmpty(&border_thickness);
if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME)
{
AdjustWindowRectEx(&border_thickness, GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION, FALSE, NULL);
border_thickness.left *= -1;
border_thickness.top *= -1;
}
else// if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_BORDER)
{
SetRect(&border_thickness, 4, 4, 4, 4);
}
MARGINS margins = { 0 };
DwmExtendFrameIntoClientArea(hWnd, &margins);
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
break;
}
@ -573,14 +561,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (_glfw.hints.window.titlebar)
break;
// Extend the frame into the client area.
MARGINS margins = { 0 };
auto hr = DwmExtendFrameIntoClientArea(hWnd, &margins);
if (!SUCCEEDED(hr))
{
// Handle the error.
}
DwmExtendFrameIntoClientArea(hWnd, &margins);
break;
}
@ -1273,12 +1255,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// Extend the frame into the client area.
MARGINS margins = { 0 };
auto hr = DwmExtendFrameIntoClientArea(hWnd, &margins);
if (!SUCCEEDED(hr))
{
// Handle the error.
}
DwmExtendFrameIntoClientArea(hWnd, &margins);
break;
}
@ -1287,6 +1264,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (_glfw.hints.window.titlebar)
break;
if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME)
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
ScreenToClient(hWnd, &pt);
RECT rc;
@ -1321,6 +1300,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
}
}
}
}
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}