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,13 +1255,8 @@ 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;
}
case WM_NCHITTEST:
@ -1287,38 +1264,41 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (_glfw.hints.window.titlebar)
break;
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
ScreenToClient(hWnd, &pt);
RECT rc;
GetClientRect(hWnd, &rc);
if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_THICKFRAME)
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
ScreenToClient(hWnd, &pt);
RECT rc;
GetClientRect(hWnd, &rc);
int titlebarHittest = 0;
_glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest);
int titlebarHittest = 0;
_glfwInputTitleBarHitTest(window, pt.x, pt.y, &titlebarHittest);
if (titlebarHittest)
{
return HTCAPTION;
}
else
{
enum { left = 1, top = 2, right = 4, bottom = 8 };
int hit = 0;
if (pt.x < border_thickness.left) hit |= left;
if (pt.x > rc.right - border_thickness.right) hit |= right;
if (pt.y < border_thickness.top) hit |= top;
if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom;
if (titlebarHittest)
{
return HTCAPTION;
}
else
{
enum { left = 1, top = 2, right = 4, bottom = 8 };
int hit = 0;
if (pt.x < border_thickness.left) hit |= left;
if (pt.x > rc.right - border_thickness.right) hit |= right;
if (pt.y < border_thickness.top) hit |= top;
if (pt.y > rc.bottom - border_thickness.bottom) hit |= bottom;
if (hit & top && hit & left) return HTTOPLEFT;
if (hit & top && hit & right) return HTTOPRIGHT;
if (hit & bottom && hit & left) return HTBOTTOMLEFT;
if (hit & bottom && hit & right) return HTBOTTOMRIGHT;
if (hit & left) return HTLEFT;
if (hit & top) return HTTOP;
if (hit & right) return HTRIGHT;
if (hit & bottom) return HTBOTTOM;
if (hit & top && hit & left) return HTTOPLEFT;
if (hit & top && hit & right) return HTTOPRIGHT;
if (hit & bottom && hit & left) return HTBOTTOMLEFT;
if (hit & bottom && hit & right) return HTBOTTOMRIGHT;
if (hit & left) return HTLEFT;
if (hit & top) return HTTOP;
if (hit & right) return HTRIGHT;
if (hit & bottom) return HTBOTTOM;
return HTCLIENT;
}
return HTCLIENT;
}
}
}
}