From b2483303a3c2c587e4e3502aebe0ca95676ded91 Mon Sep 17 00:00:00 2001 From: Rachel Macfarlane Date: Thu, 8 Feb 2018 10:30:07 -0800 Subject: [PATCH] Fixes #43198 --- .../issue/electron-main/issueService.ts | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/vs/platform/issue/electron-main/issueService.ts b/src/vs/platform/issue/electron-main/issueService.ts index 06355038ac5..13179eb7184 100644 --- a/src/vs/platform/issue/electron-main/issueService.ts +++ b/src/vs/platform/issue/electron-main/issueService.ts @@ -102,8 +102,36 @@ export class IssueService implements IIssueService { x: undefined, y: undefined }; - state.x = displayToUse.bounds.x + (displayToUse.bounds.width / 2) - (state.width / 2); - state.y = displayToUse.bounds.y + (displayToUse.bounds.height / 2) - (state.height / 2); + + const displayBounds = displayToUse.bounds; + state.x = displayBounds.x + (displayBounds.width / 2) - (state.width / 2); + state.y = displayBounds.y + (displayBounds.height / 2) - (state.height / 2); + + if (displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) { + if (state.x < displayBounds.x) { + state.x = displayBounds.x; // prevent window from falling out of the screen to the left + } + + if (state.y < displayBounds.y) { + state.y = displayBounds.y; // prevent window from falling out of the screen to the top + } + + if (state.x > (displayBounds.x + displayBounds.width)) { + state.x = displayBounds.x; // prevent window from falling out of the screen to the right + } + + if (state.y > (displayBounds.y + displayBounds.height)) { + state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom + } + + if (state.width > displayBounds.width) { + state.width = displayBounds.width; // prevent window from exceeding display bounds width + } + + if (state.height > displayBounds.height) { + state.height = displayBounds.height; // prevent window from exceeding display bounds height + } + } return state; }