Yawning, sneezing, and scratching are all methods by which a dog shows that it feels pressured to calm down or relax. To show it has no ulterior motives, kind of. Let me explain.
have you ever been playing with your dog and right in the middle the dog turns and and scratches as if it's suddenly gotten a furious itch? This automatically puts a halt to whatver is going on and gives the dog a chance to reduce the stress/activity levels. It's like a 'reset' button of sorts. Dogs will also look away from each other and yawn, break off and sneeze.. all of these basically have the same result.
Now yawning in baboons is a threatening behavior.. ;)