From 3649570e0cfcf175cc256082170d369d366e263e Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Sun, 5 May 2024 20:28:11 +0200 Subject: [PATCH] fix borderless flicker --- src/SFML/Window/Win32/WindowImplWin32.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 059b39dba..89a978589 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -179,7 +179,8 @@ m_cursorGrabbed(m_fullscreen) DWORD win32Style = WS_VISIBLE; if (style == Style::None) { - win32Style |= WS_POPUP; + // You cannot spawn a window as a true borderless window. Remove the caption after creation. + win32Style |= WS_CAPTION; } else { @@ -235,6 +236,14 @@ m_cursorGrabbed(m_fullscreen) if (m_fullscreen) switchToFullscreen(mode); + if (style == Style::None) + { + // For a true borderless window, remove the titlebar now. + // from: https://github.com/Codeusa/Borderless-Gaming/blob/3cc4dc6bd580b263287be45981f1e36036daf4eb/BorderlessGaming.Logic/Windows/Manipulation.cs#L71-L94 + constexpr long long borderlessStyleRemove = WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; + SetWindowLongPtr(m_handle, GWL_STYLE, GetWindowLongPtr(m_handle, GWL_STYLE) & ~borderlessStyleRemove); + } + // Increment window count ++windowCount; }