Skip to content

Commit 4b69833

Browse files
authored
Windows: Fix window caption drawing on borderless windows
1 parent 039a60c commit 4b69833

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/video/windows/SDL_windowsevents.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@
6868
#define VK_OEM_NEC_EQUAL 0x92
6969
#endif
7070

71+
// Undocumented window messages
72+
#ifndef WM_NCUAHDRAWCAPTION
73+
#define WM_NCUAHDRAWCAPTION 0xAE
74+
#endif
75+
#ifndef WM_NCUAHDRAWFRAME
76+
#define WM_NCUAHDRAWFRAME 0xAF
77+
#endif
78+
7179
/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
7280
#ifndef WM_XBUTTONDOWN
7381
#define WM_XBUTTONDOWN 0x020B
@@ -805,6 +813,24 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
805813
actually being the foreground window, but this appears to get called in all cases where
806814
the global foreground window changes to and from this window. */
807815
WIN_UpdateFocus(data->window, !!wParam);
816+
817+
/* Handle borderless windows; this event is intended for drawing the titlebar, so we need
818+
to stop that from happening. */
819+
if (data->window->flags & SDL_WINDOW_BORDERLESS) {
820+
lParam = -1; // According to MSDN, DefWindowProc will draw a title bar if lParam != -1
821+
}
822+
} break;
823+
824+
case WM_NCUAHDRAWCAPTION:
825+
case WM_NCUAHDRAWFRAME:
826+
{
827+
/* These messages are undocumented. They are responsible for redrawing the window frame and
828+
caption. Notably, WM_NCUAHDRAWCAPTION is sent when calling SetWindowText on a window.
829+
For borderless windows, we don't want to draw a frame or caption, so we should stop
830+
that from happening. */
831+
if (data->window->flags & SDL_WINDOW_BORDERLESS) {
832+
returnCode = 0;
833+
}
808834
} break;
809835

810836
case WM_ACTIVATE:

0 commit comments

Comments
 (0)