"He had walked away when she looked at him." seems to be an awkward expression.
"When" contracts time into an instance and treats its target as a singular moment.
For example, consider phrases:
When she died...
When the plane has landed..
When I get married...
When will it be possible? etc...
If I get the original intent, I would submit that the given phrase should be rephrased as:
By the time she looked at him, he had walked away
Or, if it is actually emphasizing the relationship of the two actions, as in he walked away (almost) as a result of her looking at him:
He walked away when she looked at him.
Or, to further emphasize the effect:
When she looked at him, he walked away.
The looking could be an actual cause of him walking away or an exclamative action within a grander context. That I will leave up to you to decide. :-)