Skip to content

Commit 4997637

Browse files
committed
Draw bettterer
1 parent 5005906 commit 4997637

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

imgui-borderless-win32/main.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -245,26 +245,25 @@ LRESULT WINAPI WndProcHook(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
245245
switch (msg) {
246246
case WM_NCCALCSIZE: {
247247
if (wParam && g_ClientIsBorderless) {
248-
WINDOWPLACEMENT placement = {0};
249-
if (::GetWindowPlacement(hWnd, &placement))
250-
{
251-
if (placement.showCmd == SW_MAXIMIZE)
252-
{
253-
NCCALCSIZE_PARAMS* params = (NCCALCSIZE_PARAMS*)lParam;
248+
NCCALCSIZE_PARAMS* params = (NCCALCSIZE_PARAMS*)lParam;
249+
if(IsMaximized(hWnd)) {
254250

255-
HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
256-
if (!monitor) return 0;
251+
HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
252+
if (!monitor) return 0;
257253

258-
MONITORINFO monitor_info = {0};
259-
monitor_info.cbSize = sizeof(monitor_info);
260-
if (!GetMonitorInfo(monitor, &monitor_info)) return 0;
254+
MONITORINFO monitor_info = {0};
255+
monitor_info.cbSize = sizeof(monitor_info);
256+
if (!GetMonitorInfo(monitor, &monitor_info)) return 0;
261257

262-
// when maximized, make the client area fill just the monitor (without task bar) rect,
263-
// not the whole window rect which extends beyond the monitor.
264-
params->rgrc[0] = monitor_info.rcWork;
265-
}
258+
// when maximized, make the client area fill just the monitor (without task bar) rect,
259+
// not the whole window rect which extends beyond the monitor.
260+
params->rgrc[0] = monitor_info.rcWork;
261+
return 0;
262+
}
263+
else {
264+
params->rgrc[0].bottom += 1;
265+
return WVR_VALIDRECTS;
266266
}
267-
return 0;
268267
}
269268
break;
270269
}
@@ -328,8 +327,10 @@ LRESULT WINAPI WndProcHook(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
328327
break;
329328
}
330329
case WM_TIMER: {
331-
if (g_ClientRenderFunction) // Ensure this is the root hWnd
330+
if (g_ClientRenderFunction) {
332331
g_ClientRenderFunction(hWnd);
332+
DwmFlush();
333+
}
333334
return 1;
334335
}
335336
case WM_ERASEBKGND: // Prevent flicker when we're rendering during resize

0 commit comments

Comments
 (0)