Refine bounds checking of DesktopManager

Adding to the excellent work on fixing some annoyances in the management of internal panels, here are some enhancements to bounds checking to prevent putting the internal frame in a position where it could not be dragged back to visible area.  More details in the comments in the code.

Also, prevent a NPE occurring on Macs since the browser extension have been re-enabled.