If you know Win32 code it is possible to alter GLFW to get borderless with snapping to work, but you’ll need to implement your own move and size controls.
I’m not sure if this helps, but I find this GitHub - rossy/borderless-window: A minimal borderless window with the Windows API a really good example on how to do borderless window with all contents custom draw, and window obeying regular rules about shortcuts and interaction with desktop. There are a lot of tiny things you need to take care for window to behave reasonably well.
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include <Windows.h>
#include <dwmapi.h>
void disableTitlebar(GLFWwindow* window)
{
HWND hWnd = glfwGetWin32Window(window);
// Remove the title bar
LONG_PTR lStyle = GetWindowLongPtr(hWnd, GWL_STYLE);
lStyle &= ~WS_CAPTION;
SetWindowLongPtr(hWnd, GWL_STYLE, lStyle);
// Set the window shape and rounded corners
DWMNCRENDERINGPOLICY policy = DWMNCRP_ENABLED;
DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &policy, sizeof(policy));
// Extend the frame into the client area
MARGINS margins = { 0 };
DwmExtendFrameIntoClientArea(hWnd, &margins);
// Adjust the window size to remove the thin frame at the top
RECT windowRect;
GetWindowRect(hWnd, &windowRect);
SetWindowPos(hWnd, NULL, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_FRAMECHANGED | SWP_NOMOVE);
}
With this, the titlebar disappear and im able to keep resizing and rounded corners. Snapping the window also works on windows 11-10.
Unfortunately there is a small issue. In the place where there was the title bar, there is a very thin white frame which does not have any purpose. It’s just there and it’s really annoying.
I cant find a way to remove it
Hey, so finally I was able to find a soluion. Figuring out a solution completely drained my energy .
Anyway here is the final code that I used to remove the titlebar on windows. I also implemented the same thing for macos and linux but I wont post them since I dont know if they work.
WNDPROC original_proc;
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_NCCALCSIZE:
{
// Remove the window's standard sizing border
if (wParam == TRUE && lParam != NULL)
{
NCCALCSIZE_PARAMS* pParams = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
pParams->rgrc[0].top += 1;
pParams->rgrc[0].right -= 2;
pParams->rgrc[0].bottom -= 2;
pParams->rgrc[0].left += 2;
}
return 0;
}
case WM_NCPAINT:
{
// Prevent the non-client area from being painted
return 0;
}
case WM_NCHITTEST:
{
// Expand the hit test area for resizing
const int borderWidth = 8; // Adjust this value to control the hit test area size
POINTS mousePos = MAKEPOINTS(lParam);
POINT clientMousePos = { mousePos.x, mousePos.y };
ScreenToClient(hWnd, &clientMousePos);
RECT windowRect;
GetClientRect(hWnd, &windowRect);
if (clientMousePos.y >= windowRect.bottom - borderWidth)
{
if (clientMousePos.x <= borderWidth)
return HTBOTTOMLEFT;
else if (clientMousePos.x >= windowRect.right - borderWidth)
return HTBOTTOMRIGHT;
else
return HTBOTTOM;
}
else if (clientMousePos.y <= borderWidth)
{
if (clientMousePos.x <= borderWidth)
return HTTOPLEFT;
else if (clientMousePos.x >= windowRect.right - borderWidth)
return HTTOPRIGHT;
else
return HTTOP;
}
else if (clientMousePos.x <= borderWidth)
{
return HTLEFT;
}
else if (clientMousePos.x >= windowRect.right - borderWidth)
{
return HTRIGHT;
}
break;
}
}
return CallWindowProc(original_proc, hWnd, uMsg, wParam, lParam);
}
void disableTitlebar(GLFWwindow* window)
{
HWND hWnd = glfwGetWin32Window(window);
LONG_PTR lStyle = GetWindowLongPtr(hWnd, GWL_STYLE);
lStyle |= WS_THICKFRAME;
lStyle &= ~WS_CAPTION;
SetWindowLongPtr(hWnd, GWL_STYLE, lStyle);
RECT windowRect;
GetWindowRect(hWnd, &windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
original_proc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC);
(WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WindowProc));
SetWindowPos(hWnd, NULL, 0, 0, width, height, SWP_FRAMECHANGED | SWP_NOMOVE);
}
With this code, you can basically keep all the native functionnality of glfw and windows like snapping the window or resizing and I think you still have rounded corners in windows11(I have to verify that).