fixed a lot of bugs when using custom global borders with masked viewports