I've slept with a gun under my pillow for at least 15 years. I keep it where I have to make a conscious effort to grab it, and abandoned the revolver for an auto with a safety that has to be pushed off for the trigger to work. For whatever reason (training?) if my hand is on a gun, I go to fully-awake mode Right Now. It's never been an issue.
It's obvious you have played the "what if" game enough to have a plan, and it paid off. No shots fired, no having to justify why you fired, and the only damage was to the window. I'd call that a victory.
As for the cop telling you it would have been okay to shoot, I've been told the same thing, in a situation where I chose not to. In hindsight, if I'd fired, a Grand Jury would likely not have seen it the same way as the cop, and I'd have been indicted. When it's obvious you HAVE to shoot, then shoot. If it's an option, hold off.
I live alone, and I have handguns stashed in every room, bathroom included. My windows are only a few feet off the ground, and even with good lighting outside, stuff still happens. The guy across the street got broken into two weeks ago while he was gone, and the amount of stuff taken made it clear there were several of them, and they were in there for awhile. I work odd (but predictable) hours, and often sleep during the day. But there's a shotgun next to the bed, well hidden, plus the gun under my head and a revolver a few feet away. If they broke a window while I was sleeping, by the time they came into view I'd be armed to the teeth, and I'd be behind cover with at least two weapons at the ready.
Not to mention my attack cats...........
Papajohn