File tree Expand file tree Collapse file tree
src/vs/platform/issue/electron-main Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments