Skip to content

Commit df381b6

Browse files
author
Benjamin Pasero
committed
macOS: Add a setting to enable acceptsFirstMouse for window (fixes microsoft#24634)
1 parent d41edee commit df381b6

5 files changed

Lines changed: 32 additions & 9 deletions

File tree

src/vs/code/electron-main/window.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,16 @@ export class CodeWindow implements ICodeWindow {
151151

152152
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
153153

154+
if (isMacintosh) {
155+
options.acceptFirstMouse = true; // enabled by default
156+
157+
if (windowConfig && windowConfig.clickThroughInactive === false) {
158+
options.acceptFirstMouse = false;
159+
}
160+
}
161+
154162
let useNativeTabs = false;
155-
if (windowConfig && windowConfig.nativeTabs) {
163+
if (isMacintosh && windowConfig && windowConfig.nativeTabs === true) {
156164
options.tabbingIdentifier = product.nameShort; // this opts in to sierra tabs
157165
useNativeTabs = true;
158166
}

src/vs/platform/windows/common/windows.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ export interface IWindowSettings {
226226
enableMenuBarMnemonics: boolean;
227227
closeWhenEmpty: boolean;
228228
smoothScrollingWorkaround: boolean;
229+
clickThroughInactive: boolean;
229230
}
230231

231232
export enum OpenContext {

src/vs/workbench/electron-browser/main.contribution.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ configurationRegistry.registerConfiguration({
412412
'default': false,
413413
'description': nls.localize('window.smoothScrollingWorkaround', "Enable this workaround if scrolling is no longer smooth after restoring a minimized VS Code window. This is a workaround for an issue (https://github.com/Microsoft/vscode/issues/13612) where scrolling starts to lag on devices with precision trackpads like the Surface devices from Microsoft. Enabling this workaround can result in a little bit of layout flickering after restoring the window from minimized state but is otherwise harmless."),
414414
'included': isWindows
415+
},
416+
'window.clickThroughInactive': {
417+
'type': 'boolean',
418+
'default': true,
419+
'description': nls.localize('window.clickThroughInactive', "If enabled, clicking on an inactive window will both activate the window and execute the element under the mouse. If disabled, clicking anywhere on an inactive window will activate it only, without executing the element under the mouse."),
420+
'included': isMacintosh
415421
}
416422
}
417423
});

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ export class Workbench implements IPartService {
424424
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleDevToolsAction, ToggleDevToolsAction.ID, ToggleDevToolsAction.LABEL, isDeveloping ? { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_I } } : void 0), 'Developer: Toggle Developer Tools', localize('developer', "Developer"));
425425
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL, { primary: isDeveloping ? null : KeyMod.CtrlCmd | KeyCode.KEY_R, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_R } }), 'File: Open Recent...', localize('file', "File"));
426426
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowWithExtensionsDisabledAction, ReloadWindowWithExtensionsDisabledAction.ID, ReloadWindowWithExtensionsDisabledAction.LABEL), 'Reload Window Without Extensions');
427+
427428
// Actions for macOS native tabs management (only when enabled)
428429
const windowConfig = this.configurationService.getValue<IWindowConfiguration>();
429430
if (windowConfig && windowConfig.window && windowConfig.window.nativeTabs) {

src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
1717
import { RunOnceScheduler } from 'vs/base/common/async';
1818
import URI from 'vs/base/common/uri';
1919
import { isEqual } from 'vs/base/common/resources';
20-
import { isLinux } from 'vs/base/common/platform';
20+
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
2121
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
2222
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2323

@@ -34,6 +34,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
3434

3535
private titleBarStyle: 'native' | 'custom';
3636
private nativeTabs: boolean;
37+
private clickThroughInactive: boolean;
3738
private updateChannel: string;
3839
private enableCrashReporter: boolean;
3940
private touchbarEnabled: boolean;
@@ -72,18 +73,24 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
7273
private onConfigurationChange(config: IConfiguration, notify: boolean): void {
7374
let changed = false;
7475

75-
// Titlebar style
76-
if (config.window && config.window.titleBarStyle !== this.titleBarStyle && (config.window.titleBarStyle === 'native' || config.window.titleBarStyle === 'custom')) {
76+
// macOS: Titlebar style
77+
if (isMacintosh && config.window && config.window.titleBarStyle !== this.titleBarStyle && (config.window.titleBarStyle === 'native' || config.window.titleBarStyle === 'custom')) {
7778
this.titleBarStyle = config.window.titleBarStyle;
7879
changed = true;
7980
}
8081

81-
// Native tabs
82-
if (config.window && typeof config.window.nativeTabs === 'boolean' && config.window.nativeTabs !== this.nativeTabs) {
82+
// macOS: Native tabs
83+
if (isMacintosh && config.window && typeof config.window.nativeTabs === 'boolean' && config.window.nativeTabs !== this.nativeTabs) {
8384
this.nativeTabs = config.window.nativeTabs;
8485
changed = true;
8586
}
8687

88+
// macOS: Click through (accept first mouse)
89+
if (isMacintosh && config.window && typeof config.window.clickThroughInactive === 'boolean' && config.window.clickThroughInactive !== this.clickThroughInactive) {
90+
this.clickThroughInactive = config.window.clickThroughInactive;
91+
changed = true;
92+
}
93+
8794
// Update channel
8895
if (config.update && typeof config.update.channel === 'string' && config.update.channel !== this.updateChannel) {
8996
this.updateChannel = config.update.channel;
@@ -96,8 +103,8 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
96103
changed = true;
97104
}
98105

99-
// Touchbar config
100-
if (config.keyboard && config.keyboard.touchbar && typeof config.keyboard.touchbar.enabled === 'boolean' && config.keyboard.touchbar.enabled !== this.touchbarEnabled) {
106+
// macOS: Touchbar config
107+
if (isMacintosh && config.keyboard && config.keyboard.touchbar && typeof config.keyboard.touchbar.enabled === 'boolean' && config.keyboard.touchbar.enabled !== this.touchbarEnabled) {
101108
this.touchbarEnabled = config.keyboard.touchbar.enabled;
102109
changed = true;
103110
}
@@ -109,7 +116,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution {
109116
}
110117

111118
// Windows: smooth scrolling workaround
112-
if (config.window && typeof config.window.smoothScrollingWorkaround === 'boolean' && config.window.smoothScrollingWorkaround !== this.windowsSmoothScrollingWorkaround) {
119+
if (isWindows && config.window && typeof config.window.smoothScrollingWorkaround === 'boolean' && config.window.smoothScrollingWorkaround !== this.windowsSmoothScrollingWorkaround) {
113120
this.windowsSmoothScrollingWorkaround = config.window.smoothScrollingWorkaround;
114121
changed = true;
115122
}

0 commit comments

Comments
 (0)