@@ -11,7 +11,7 @@ import { Emitter, Event } from '../../../base/common/event.js';
11
11
import { Disposable } from '../../../base/common/lifecycle.js' ;
12
12
import { FileAccess , Schemas } from '../../../base/common/network.js' ;
13
13
import { getMarks , mark } from '../../../base/common/performance.js' ;
14
- import { isBigSurOrNewer , isMacintosh , isWindows } from '../../../base/common/platform.js' ;
14
+ import { isBigSurOrNewer , isLinux , isMacintosh , isWindows } from '../../../base/common/platform.js' ;
15
15
import { URI } from '../../../base/common/uri.js' ;
16
16
import { localize } from '../../../nls.js' ;
17
17
import { release } from 'os' ;
@@ -172,30 +172,15 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {
172
172
}
173
173
}
174
174
175
- // Setup windows system context menu so it only is allowed in certain cases
176
- if ( isWindows && useCustomTitleStyle ) {
177
- this . _register ( Event . fromNodeEventEmitter ( win , 'system-context-menu' , ( event : Electron . Event , point : Electron . Point ) => ( { event, point } ) ) ( ( e ) => {
175
+ // Setup windows/linux system context menu so it only is allowed over the app icon
176
+ if ( ( isWindows || ( isLinux && typeof electron . screen . screenToDipPoint === 'function' ) /* TODO@bpasero remove check */ ) && useCustomTitleStyle ) {
177
+ this . _register ( Event . fromNodeEventEmitter ( win , 'system-context-menu' , ( event : Electron . Event , point : Electron . Point ) => ( { event, point } ) ) ( e => {
178
178
const [ x , y ] = win . getPosition ( ) ;
179
179
const cursorPos = electron . screen . screenToDipPoint ( e . point ) ;
180
180
const cx = Math . floor ( cursorPos . x ) - x ;
181
181
const cy = Math . floor ( cursorPos . y ) - y ;
182
182
183
- // In some cases, show the default system context menu
184
- // 1) The mouse position is not within the title bar
185
- // 2) The mouse position is within the title bar, but over the app icon
186
- // We do not know the exact title bar height but we make an estimate based on window height
187
- const shouldTriggerDefaultSystemContextMenu = ( ) => {
188
- // Use the custom context menu when over the title bar, but not over the app icon
189
- // The app icon is estimated to be 30px wide
190
- // The title bar is estimated to be the max of 35px and 15% of the window height
191
- if ( cx > 30 && cy >= 0 && cy <= Math . max ( win . getBounds ( ) . height * 0.15 , 35 ) ) {
192
- return false ;
193
- }
194
-
195
- return true ;
196
- } ;
197
-
198
- if ( ! shouldTriggerDefaultSystemContextMenu ( ) ) {
183
+ if ( cx > 35 /* Cursor is beyond app icon in title bar */ ) {
199
184
e . event . preventDefault ( ) ;
200
185
201
186
this . _onDidTriggerSystemContextMenu . fire ( { x : cx , y : cy } ) ;
0 commit comments