Windows 11 animations not working when GLFW_DECORATED is false

Hey!

I’m using glfwWindowHint(GLFW_DECORATED, GL_FALSE); to hide the topbar in my window, but it disables animations in windows 11 like minimizing. Minimizing the window just instantly dissapears the window. When i test with other app’s that have totally custom layout (i.e UE5), then they are minimizing with a smooth animation.

As far as I can tell, windows doesn’t apply minimize/maximize animation to borderless windows, but from searching I found that there is a workaround which might work: when the your minimize button is clicked or event received you can set the window style back to having a border then minimize then restore it back to borderless when it is fully maximized.

However this doesn’t work if done via the iconify callback since that fires after the event, but it is possible to restore, set decorated and minimize as follows:

void IconifyCallback( GLFWwindow* window, int iconified )
{
    static bool inside = false;

    if( inside ) { return; }
    inside = true;
    if( iconified )
    {
        glfwRestoreWindow( window );
        glfwSetWindowAttrib( window, GLFW_DECORATED, GLFW_TRUE );
        glfwIconifyWindow( window );
    }
    else
    {
        glfwSetWindowAttrib( window, GLFW_DECORATED, GLFW_FALSE );
    }
    inside = false;
}


    // somewhere after in your window creation code:
    glfwSetWindowIconifyCallback( window, IconifyCallback );

Obviously if you’re minimizing via your own button you can do better and simply decorate then minimize. This will still show a border when animating though.

Finally you could animate the window yourself. This might not be a good idea for people who have turned animations off, but perhaps there is a way to read that setting and change your behaviour.

EDIT: you might also want to take a look at:

1 Like

Thanks. That helped to get the minimize animation back, but now if i have maximized window, I minimize it and then restore the window, it creates a little titlebar-sized cap at the top. I’m gonna look into some hacky fix for that.
The thread you mentioned was helpful. The solution in there didn’t work but I realized I need to create my own alternative to GLFW with Windows API to get stuff working and wait till the GLFW gets the full borderless window features.
Too bad GLFW doesn’t support making fully functional custom borderless windows yet. Every modern desktop app is doing it (steam, UE5…, blizzard and many other game launchers). But lets hope with the new GLFW version some of the stuff gets added.

EDIT:
I found a perfect GLFW fork repo for my problem. It’s Cherno’s version that uses glfwWindowHint(GLFW_TITLEBAR, GL_FALSE); instead of glfwWindowHint(GLFW_DECORATED, GL_FALSE);. With that you can disable the titlebar and the resizing, animations and snapping are working as needed.

Steam and Unreal do not actually use an undecorated window, they create a decorated window and then custom draw on it.

It looks like the modification by Jaroslave on Cherno’s repository does things similar, creating a normal window but then expanding the client area.

It looks like this hasn’t been implemented for X11, Wayland and Cocoa (MacOSX) yet though, so I don’t think it would be integrated into GLFW.

1 Like

Thanks for clarifying that up!