Skip to content

Commit b248330

Browse files
author
Rachel Macfarlane
committed
1 parent d5ef5ac commit b248330

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

src/vs/platform/issue/electron-main/issueService.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,36 @@ export class IssueService implements IIssueService {
102102
x: undefined,
103103
y: undefined
104104
};
105-
state.x = displayToUse.bounds.x + (displayToUse.bounds.width / 2) - (state.width / 2);
106-
state.y = displayToUse.bounds.y + (displayToUse.bounds.height / 2) - (state.height / 2);
105+
106+
const displayBounds = displayToUse.bounds;
107+
state.x = displayBounds.x + (displayBounds.width / 2) - (state.width / 2);
108+
state.y = displayBounds.y + (displayBounds.height / 2) - (state.height / 2);
109+
110+
if (displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) {
111+
if (state.x < displayBounds.x) {
112+
state.x = displayBounds.x; // prevent window from falling out of the screen to the left
113+
}
114+
115+
if (state.y < displayBounds.y) {
116+
state.y = displayBounds.y; // prevent window from falling out of the screen to the top
117+
}
118+
119+
if (state.x > (displayBounds.x + displayBounds.width)) {
120+
state.x = displayBounds.x; // prevent window from falling out of the screen to the right
121+
}
122+
123+
if (state.y > (displayBounds.y + displayBounds.height)) {
124+
state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom
125+
}
126+
127+
if (state.width > displayBounds.width) {
128+
state.width = displayBounds.width; // prevent window from exceeding display bounds width
129+
}
130+
131+
if (state.height > displayBounds.height) {
132+
state.height = displayBounds.height; // prevent window from exceeding display bounds height
133+
}
134+
}
107135

108136
return state;
109137
}

0 commit comments

Comments
 (0)