The X and Y coordinates start on the top left corner with 0,0
So if your game is 1280px by 720px the right bottom corner would be 1280, 720
If you want a mouse movement only occur on the top half you just take 360 (720/2).
So the 400 only represent some random Y value I took - so the mouse only follows if the mouse is maximum 400 away from the top.
To stop mouse movement if your cursor is off screen you can add another event like
if smaller then windowWidht (or WindowHight depending if X or Y)
and greater then 0