Better implementation of draggable windows.

This will likely also fix the issues with the close button not properly working on the debug window.
Merge remote-tracking branch 'origin/master'