Lu Yu lived in the Kingdom of Wei during the Three Kingdom Period (220-280). He was orphaned at age of ten, then lost his elder brothers one after another, so he took the task of supporting his sister-in-law and nephew through a period of extreme hardship. He was praised all around for his noble behaviour and deep knowledge.
Since he was a learned man of integrity, in time Lu Yu became a senior official, and the Emperor of Wei placed great trust in him.
Once the emperor was selecting talents for a post, officials recommended a lot of famous people. The emperor of Wei said, “I would like to let Lu Yu select the right person instead of those well-known but incapable ones. Fame is just like a pancake drawn on the wall. You cannot eat it.”
Lu Yu suggested the emperor to combine examination with selection. From then on, officials were appointed according to their real ability. Lu Yu’s method for selection was widely praised.
The idiom came from what the emperor said. At first, it indicated enjoying an empty fame. Later, people use it to describe satisfying oneself by imagining things or consoling oneself with false hopes. This idiom is sometimes used along with “To quench one’s thirst by looking up at plums“.