How to fix a Macbook that does not always draw its internal screen after waking from sleep and having unplugged external display while asleep? I have a 2012 MacBook Pro (Retina) which I mostly use on my desk. The computer is "docked" via a Thunderbolt display, and additionally a third-party DVI display, which I have hooked up via an Apple Mini Display Port to DVI adapter (the active one, doing 2560x1440).

I use the MacBook during the day with the lid closed. So I work on the two external monitors. Via the Apple menu I put the Mac to sleep in the evening.

Sometimes, later in the evening, I like to take it downstairs and use it on my lap, so I unplug everything while the Mac is still asleep. I take the computer down and open it up.

Sometimes, when I open the lid up (not always) the internal screen does not come on. The back light illuminates, but there is no display.

I know the MacBook is alive because I can SSH into it.

Plugging the external monitors back in, in this state, has no effect.
My only workaround at the moment is to wake it up and do my replugging while it's awake but I don't think I should need to do this.

So, what might be causing this how to resolve it?
I would pay attention to two factors:

1) Do you have an external keyboard attached?

2) The power situation - how/when sleep happens is affected by this

3) If the lid is closed at the time you move the mac.

A couple of examples will help illustrate this:   

Recently I found that my external keyboard was not waking up the closed lid mac as I thought it should.  I found that this was because the power was unplugged and the 'lid closed' operation only worked with the power actually plugged in.

As another example I found that when my computer was asleep, in order to wake it up - without opening the lid! - the trick was to plug an external keyboard/mouse in and hit a key / move the mouse.  This then took the mac out of sleep (though again that may depend on whether you have power plugged in or not).