The gun wasn't out; it was merely ready to draw if it becomes necessary. Which is okay and legal. Drawing it at that point would've been illegal. So, in this regard, no harm, no foul. Maybe not ideal, but, well, pushing your head in someone's car is asking for trouble. Of course, situational awareness would've helped but realistically, you can't avoid all interactions with people.
If someone walks up to your car and knocks on your window, you're going to roll it down a bit to hear what they want. Mostly it's panhandlers, but you get all sorts of people. Sometimes it's someone genuinely asking instructions, wanting to sell me things, wanting to tell me my light isn't working - all sorts. Once I was stopped by a guy who returned me some cash I dropped when rummaging for the car keys (there are well intentoned people,too). However, sometimes you get people who are obviously not right in the head, and in my view, when it's someone not wired properly, it's better to be nice and resolve it peacefully, especially if you have a gun on you.
Although I do not normally carry a gun (permits for carry in my country are rarely given and I don't feel some sort of need which would compel me to go through all the red tape involved), every sunday and some saturdays I drive to the range, naturally, with my guns in the bag beside me. So, this guy walks in our parking lot and first stops a neighbour's car - he was also going somewhere - neighbour drives away with this guy waving arms and cursing after him - and then stops mine and knocks on the window. I get this mixed up story about him being a war veteran and hungry children and all that, but I get the hint of desperation in the man's voice.
Sure, I could tell him to bugger off, put my hand on the gun, or I don't know what. However, he sounded like a desperate man who might actually turn to violence (as opposed to 'agressive' panhandlers which try to intimidate). His story might be true or might not be true, but I'd rather not get in a fight while having a gun and in the end shoot someone over small change. A man would be killed, in plain sight of my daughter, I would face years of fighting in court, and so on. Some change and he was genuinely grateful and walked off. I may have helped someone, and if I didn't, at least, avoided an altercation while armed. If you carry a gun, it's up to you to behave to a higher standard.