From 9849693bb1f5e77c7d1b4fc37019f6420f2e9c05 Mon Sep 17 00:00:00 2001 From: SteVen Batten Date: Tue, 11 Sep 2018 15:13:06 -0700 Subject: [PATCH] fixes #53479 --- .../parts/titlebar/media/titlebarpart.css | 5 +++++ .../browser/parts/titlebar/menubarControl.ts | 16 +++++++++------- .../browser/parts/titlebar/titlebarPart.ts | 11 +++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css b/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css index 42965aae65c..3f1d2eb5f8a 100644 --- a/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css +++ b/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css @@ -51,6 +51,11 @@ overflow: visible; } +.monaco-workbench.windows > .part.titlebar > .window-title, +.monaco-workbench.linux > .part.titlebar > .window-title { + cursor: default; +} + .monaco-workbench.linux > .part.titlebar > .window-title { font-size: inherit; } diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index e25e91baf01..95ca8d58cd2 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -112,6 +112,7 @@ export class MenubarControl extends Disposable { private mnemonics: Map; private _onVisibilityChange: Emitter; + private _onFocusStateChange: Emitter; private static MAX_MENU_RECENT_ENTRIES = 10; @@ -152,6 +153,7 @@ export class MenubarControl extends Disposable { })); this._onVisibilityChange = this._register(new Emitter()); + this._onFocusStateChange = this._register(new Emitter()); if (isMacintosh || this.currentTitlebarStyleSetting !== 'custom') { for (let topLevelMenuName of Object.keys(this.topLevelMenus)) { @@ -305,6 +307,7 @@ export class MenubarControl extends Disposable { } this._focusState = value; + this._onFocusStateChange.fire(this.focusState >= MenubarState.FOCUSED); } private get mnemonicsInUse(): boolean { @@ -793,11 +796,6 @@ export class MenubarControl extends Disposable { e.stopPropagation(); })); - this._register(DOM.addDisposableListener(this.customMenus[menuIndex].buttonElement, DOM.EventType.CLICK, (e) => { - e.preventDefault(); - e.stopPropagation(); - })); - this._register(DOM.addDisposableListener(this.customMenus[menuIndex].buttonElement, DOM.EventType.MOUSE_ENTER, () => { if (this.isOpen && !this.isCurrentMenu(menuIndex)) { this.customMenus[menuIndex].buttonElement.focus(); @@ -836,8 +834,8 @@ export class MenubarControl extends Disposable { } })); - this._register(DOM.addDisposableListener(window, DOM.EventType.CLICK, () => { - // This click is outside the menubar so it counts as a focus out + this._register(DOM.addDisposableListener(window, DOM.EventType.MOUSE_DOWN, () => { + // This mouse event is outside the menubar so it counts as a focus out if (this.isFocused) { this.setUnfocusedState(); } @@ -1105,6 +1103,10 @@ export class MenubarControl extends Disposable { return this._onVisibilityChange.event; } + public get onFocusStateChange(): Event { + return this._onFocusStateChange.event; + } + public layout(dimension: DOM.Dimension) { if (this.container) { this.container.style.height = `${dimension.height}px`; diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 3c10e3bb14d..6caac3beca0 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -134,6 +134,16 @@ export class TitlebarPart extends Part implements ITitleService { } } + private onMenubarFocusChanged(focused: boolean) { + if (isWindows || isLinux) { + if (focused) { + hide(this.dragRegion); + } else { + show(this.dragRegion); + } + } + } + onMenubarVisibilityChange(): Event { return this.menubarPart.onVisibilityChange; } @@ -285,6 +295,7 @@ export class TitlebarPart extends Part implements ITitleService { if (!isMacintosh) { this._register(this.menubarPart.onVisibilityChange(e => this.onMenubarVisibilityChanged(e))); + this._register(this.menubarPart.onFocusStateChange(e => this.onMenubarFocusChanged(e))); } // Title -- GitLab