Minimize doesnt work

I needed a custom lookandfeel for my titlebar, so I created a CustomTopLevelWindow, and by copying some bits of code of the ResizableWindow I had pretty much what I needed.

The issue is the code I copied from ResizableWindow::setMinimized doesnt work:

void setMinimized(bool minimized) {
	if (minimized != isMinimized()) {
		if (auto* peer = getPeer()) {
			updateLastPosIfShowing();
			peer->setMinimised(minimized);
			jassert(peer->isMinimised() == minimized); //here trigger false on mac, works on windows and linux
		}
		else
			jassertfalse;
	}
}

Any idea why ?

(Just to be clear : I only have this issue on mac. It works well for Windows and Linux)