mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
* clicking on the window, group entry should reveal /focus that window (fix #196456) * 💄
This commit is contained in:
parent
e685838c2d
commit
35b8096c9f
|
@ -6,7 +6,7 @@
|
|||
import { localize } from 'vs/nls';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { Dimension, isAncestor, $, EventHelper, addDisposableGenericMouseDownListener } from 'vs/base/browser/dom';
|
||||
import { Dimension, isAncestor, $, EventHelper, addDisposableGenericMouseDownListener, getWindow } from 'vs/base/browser/dom';
|
||||
import { Event, Emitter, Relay } from 'vs/base/common/event';
|
||||
import { contrastBorder, editorBackground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { GroupDirection, GroupsArrangement, GroupOrientation, IMergeGroupOptions, MergeGroupMode, GroupsOrder, GroupLocation, IFindGroupScope, EditorGroupLayout, GroupLayoutArgument, IEditorSideGroup, IEditorDropTargetDelegate, IAuxiliaryEditorPart, IEditorPart } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
|
@ -32,6 +32,7 @@ import { DeferredPromise, Promises } from 'vs/base/common/async';
|
|||
import { findGroup } from 'vs/workbench/services/editor/common/editorGroupFinder';
|
||||
import { SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IBoundarySashes } from 'vs/base/browser/ui/sash/sash';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
|
||||
interface IEditorPartUIState {
|
||||
readonly serializedGrid: ISerializedGrid;
|
||||
|
@ -152,6 +153,7 @@ export class EditorPart extends Part implements IEditorPart {
|
|||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@IHostService private readonly hostService: IHostService
|
||||
) {
|
||||
super(id, { hasTitle: false }, themeService, storageService, layoutService);
|
||||
|
||||
|
@ -660,6 +662,10 @@ export class EditorPart extends Part implements IEditorPart {
|
|||
}
|
||||
|
||||
private doSetGroupActive(group: IEditorGroupView): void {
|
||||
|
||||
// Ensure window on top
|
||||
this.hostService.moveTop(getWindow(this.element));
|
||||
|
||||
if (this._activeGroup !== group) {
|
||||
const previousActiveGroup = this._activeGroup;
|
||||
this._activeGroup = group;
|
||||
|
@ -1315,9 +1321,10 @@ export class MainEditorPart extends EditorPart {
|
|||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@IHostService hostService: IHostService
|
||||
) {
|
||||
super(editorPartsView, Parts.EDITOR_PART, '', instantiationService, themeService, configurationService, storageService, layoutService);
|
||||
super(editorPartsView, Parts.EDITOR_PART, '', instantiationService, themeService, configurationService, storageService, layoutService, hostService);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1334,10 +1341,11 @@ export class AuxiliaryEditorPart extends EditorPart implements IAuxiliaryEditorP
|
|||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@IHostService hostService: IHostService
|
||||
) {
|
||||
const id = AuxiliaryEditorPart.COUNTER++;
|
||||
super(editorPartsView, `workbench.parts.auxiliaryEditor.${id}`, localize('auxiliaryEditorPartLabel', "Window {0}", id + 1), instantiationService, themeService, configurationService, storageService, layoutService);
|
||||
super(editorPartsView, `workbench.parts.auxiliaryEditor.${id}`, localize('auxiliaryEditorPartLabel', "Window {0}", id + 1), instantiationService, themeService, configurationService, storageService, layoutService, hostService);
|
||||
}
|
||||
|
||||
protected override saveState(): void {
|
||||
|
|
|
@ -286,6 +286,9 @@ export class OpenEditorsView extends ViewPane {
|
|||
this.openEditor(e.element, { preserveFocus: e.editorOptions.preserveFocus, pinned: e.editorOptions.pinned, sideBySide: e.sideBySide });
|
||||
} else {
|
||||
this.editorGroupService.activateGroup(e.element);
|
||||
if (!e.editorOptions.preserveFocus) {
|
||||
e.element.focus();
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { equals } from 'vs/base/common/objects';
|
||||
import { EventType, EventHelper, addDisposableListener, ModifierKeyEmitter, getActiveElement } from 'vs/base/browser/dom';
|
||||
import { EventType, EventHelper, addDisposableListener, ModifierKeyEmitter, getActiveElement, getActiveWindow } from 'vs/base/browser/dom';
|
||||
import { Separator, WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from 'vs/base/common/actions';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { EditorResourceAccessor, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors, IResourceDiffEditorInput, IUntypedEditorInput, IEditorPane, isResourceEditorInput, IResourceMergeEditorInput } from 'vs/workbench/common/editor';
|
||||
|
@ -680,6 +680,10 @@ export class NativeWindow extends Disposable {
|
|||
const that = this;
|
||||
const originalWindowFocus = window.focus.bind(window);
|
||||
window.focus = async function () {
|
||||
if (getActiveWindow() === window) {
|
||||
return;
|
||||
}
|
||||
|
||||
originalWindowFocus();
|
||||
|
||||
await that.nativeHostService.focusWindow();
|
||||
|
|
|
@ -13,17 +13,16 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
|
|||
import { INativeHostService } from 'vs/platform/native/common/native';
|
||||
import { DeferredPromise } from 'vs/base/common/async';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { getActiveWindow } from 'vs/base/browser/dom';
|
||||
|
||||
type AuxiliaryWindow = BaseAuxiliaryWindow & {
|
||||
readonly vscodeWindowId: Promise<number>;
|
||||
|
||||
moveTop: () => void;
|
||||
};
|
||||
|
||||
export function isAuxiliaryWindow(obj: unknown): obj is AuxiliaryWindow {
|
||||
const candidate = obj as AuxiliaryWindow | undefined;
|
||||
|
||||
return candidate?.vscodeWindowId instanceof Promise && typeof candidate?.moveTop === 'function';
|
||||
return candidate?.vscodeWindowId instanceof Promise;
|
||||
}
|
||||
|
||||
export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService {
|
||||
|
@ -70,20 +69,14 @@ export class NativeAuxiliaryWindowService extends BrowserAuxiliaryWindowService
|
|||
const that = this;
|
||||
const originalWindowFocus = auxiliaryWindow.focus.bind(auxiliaryWindow);
|
||||
auxiliaryWindow.focus = async function () {
|
||||
if (getActiveWindow() === auxiliaryWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
originalWindowFocus();
|
||||
|
||||
await that.nativeHostService.focusWindow({ targetWindowId: await windowId.p });
|
||||
};
|
||||
|
||||
// Add a method to move window to the top
|
||||
Object.defineProperty(auxiliaryWindow, 'moveTop', {
|
||||
value: async () => {
|
||||
await that.nativeHostService.moveWindowTop({ targetWindowId: await windowId.p });
|
||||
},
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import { NativeHostService } from 'vs/platform/native/electron-sandbox/nativeHos
|
|||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { IMainProcessService } from 'vs/platform/ipc/common/mainProcessService';
|
||||
import { isAuxiliaryWindow } from 'vs/workbench/services/auxiliaryWindow/electron-sandbox/auxiliaryWindowService';
|
||||
import { getActiveWindow } from 'vs/base/browser/dom';
|
||||
|
||||
class WorkbenchNativeHostService extends NativeHostService {
|
||||
|
||||
|
@ -115,14 +116,12 @@ class WorkbenchHostService extends Disposable implements IHostService {
|
|||
return this.nativeHostService.toggleFullScreen();
|
||||
}
|
||||
|
||||
async moveTop(win: Window & typeof globalThis): Promise<void> {
|
||||
if (win === window) {
|
||||
return this.nativeHostService.moveWindowTop();
|
||||
async moveTop(window: Window & typeof globalThis): Promise<void> {
|
||||
if (getActiveWindow() === window) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isAuxiliaryWindow(win)) {
|
||||
return win.moveTop();
|
||||
}
|
||||
return this.nativeHostService.moveWindowTop(isAuxiliaryWindow(window) ? { targetWindowId: await window.vscodeWindowId } : undefined);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
|
Loading…
Reference in a new issue