You could compare width and height of this viewport size.
If a mouse position as x is greater than width of viewport (window is 854 x 480, in that case youre comparing with 854) you can detect right of edge.
Else if a mouse position as x is lesser than zero to get negative width of the layout, you can detect left of edge
Also it can apply to y of top and bottom