He may have violated the law by refusing an order to roll down the window, or not. Here’s how I would have made the determination:
“Am I free to leave?”
If they say “Yes” then just leave. If they say “No”, then I am being detained.
“Officer why are you detaining me?” [you want to get them to articulate their reason now so they don’t have a chance to make up a reason retroactively. In some situations they don’t have to tell you, but any answer you can get (and especially record) will be useful to you if this goes to court]
“Is that a request or an order?”
If “request” then I would refuse. If they say “order”:
“What would you do if I refuse?”
If they say “I would arrest you”:
“What would you arrest me for?”
If they say “refusal to follow a lawful order” then I would probably comply and roll down the window unless I wanted an arrest on my record, but not before saying immediately before doing so
“I do not consent to any searches” and I would repeat that every time I comply with an order.