Praise be to Allah
What is prohibited is walking in front of a worshipper, as the Prophet (blessings and peace of Allah be upon him) said: “If one of you prays facing towards something that is screening him from the people, and someone wants to pass in front of him, let him push him away, and if he insists then let him fight him, for he is a devil.”
Narrated by al-Bukhaari (509) and Muslim (505).
This action (stretching out the arm) is not regarded as passing in front of a worshipper; it is no more than placing part of the body in front of the worshipper. ‘Aa’ishah (may Allah be pleased with her) used to stretch her legs out in front of the Messenger of Allah (blessings and peace of Allah be upon him) when he was praying and she was sleeping, and that did not interrupt his prayer.
It was narrated from ‘Aa’ishah, the wife of the Prophet (blessings and peace of Allah be upon him), that she said: I was sleeping in front of the Messenger of Allah (blessings and peace of Allah be upon him), and my legs were in front of him as he faced the qiblah. When he prostrated he nudged me and I drew up my legs, and when he stood up I straightened them out again. And there were no lamps in the houses in those days.
Narrated by al-Bukhaari (382) and Muslim (512).
Shaykh Muhammad ibn ‘Uthaymeen (may Allah have mercy on him) said, commenting on this hadith: So there is a difference between passing in front of someone and lying down in front of them. If a woman is lying in front of a worshipper, that does not interrupt his prayer. End quote from ash-Sharh al-Mumti‘ (3/205).
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him) was asked:
Sometimes I am praying a naafil prayer, and it so happens that the man who is sitting on my right shakes hands with the man who is sitting on my left, whilst I am praying. Does this interrupt the prayer?
He replied: It does not matter, because what matters is if someone passes in front of the worshipper. But if one man reaches out to shake another man’s hand, and the other one reaches out his hand (in front of the worshipper), there is no harm in that.
End quote from Fataawa Noor ‘ala ad-Darb (9/348).
And Allah knows best.