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()) {
			jassert(peer->isMinimised() == minimized); //here trigger false on mac, works on windows and linux

Any idea why ?

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