Disable widget dragging/splitting (#940)

This commit is contained in:
Mark Sujew 2022-04-05 12:21:49 +02:00 committed by GitHub
parent 1969e292f0
commit c430cf0d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 13 deletions

View File

@ -39,13 +39,14 @@ import {
import { MessageService } from '@theia/core/lib/common/message-service'; import { MessageService } from '@theia/core/lib/common/message-service';
import URI from '@theia/core/lib/common/uri'; import URI from '@theia/core/lib/common/uri';
import { import {
EditorCommands,
EditorMainMenu, EditorMainMenu,
EditorManager, EditorManager,
EditorOpenerOptions, EditorOpenerOptions,
} from '@theia/editor/lib/browser'; } from '@theia/editor/lib/browser';
import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution'; import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution';
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu'; import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
import { FileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution'; import { FileNavigatorCommands, FileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution'; import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
import { OutputContribution } from '@theia/output/lib/browser/output-contribution'; import { OutputContribution } from '@theia/output/lib/browser/output-contribution';
import { ScmContribution } from '@theia/scm/lib/browser/scm-contribution'; import { ScmContribution } from '@theia/scm/lib/browser/scm-contribution';
@ -344,14 +345,14 @@ export class ArduinoFrontendContribution
app.shell.leftPanelHandler.removeBottomMenu('settings-menu'); app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
this.fileSystemFrontendContribution.onDidChangeEditorFile(e => { this.fileSystemFrontendContribution.onDidChangeEditorFile(e => {
if (e.type === FileChangeType.DELETED) { if (e.type === FileChangeType.DELETED) {
const editorWidget = e.editor; const editorWidget = e.editor;
if (SaveableWidget.is(editorWidget)) { if (SaveableWidget.is(editorWidget)) {
editorWidget.closeWithoutSaving(); editorWidget.closeWithoutSaving();
} else { } else {
editorWidget.close(); editorWidget.close();
}
} }
}
}); });
} }
@ -485,6 +486,18 @@ export class ArduinoFrontendContribution
} }
}, },
}); });
for (const command of [
EditorCommands.SPLIT_EDITOR_DOWN,
EditorCommands.SPLIT_EDITOR_LEFT,
EditorCommands.SPLIT_EDITOR_RIGHT,
EditorCommands.SPLIT_EDITOR_UP,
EditorCommands.SPLIT_EDITOR_VERTICAL,
EditorCommands.SPLIT_EDITOR_HORIZONTAL,
FileNavigatorCommands.REVEAL_IN_NAVIGATOR
]) {
registry.unregisterCommand(command);
}
} }
registerMenus(registry: MenuModelRegistry) { registerMenus(registry: MenuModelRegistry) {

View File

@ -9,6 +9,7 @@ import {
} from '@theia/core/lib/browser/connection-status-service'; } from '@theia/core/lib/browser/connection-status-service';
import { import {
ApplicationShell as TheiaApplicationShell, ApplicationShell as TheiaApplicationShell,
DockPanel,
Panel, Panel,
Widget, Widget,
} from '@theia/core/lib/browser'; } from '@theia/core/lib/browser';
@ -74,6 +75,11 @@ export class ApplicationShell extends TheiaApplicationShell {
return super.addWidget(widget, { ...options, ref }); return super.addWidget(widget, { ...options, ref });
} }
handleEvent(): boolean {
// NOOP, dragging has been disabled
return false
}
// Avoid hiding top panel as we use it for arduino toolbar // Avoid hiding top panel as we use it for arduino toolbar
protected createTopPanel(): Panel { protected createTopPanel(): Panel {
const topPanel = super.createTopPanel(); const topPanel = super.createTopPanel();
@ -101,3 +107,16 @@ export class ApplicationShell extends TheiaApplicationShell {
); );
} }
} }
const originalHandleEvent = DockPanel.prototype.handleEvent;
DockPanel.prototype.handleEvent = function (event) {
switch (event.type) {
case 'p-dragenter':
case 'p-dragleave':
case 'p-dragover':
case 'p-drop':
return;
}
originalHandleEvent(event);
};

View File

@ -11,7 +11,15 @@ export class CommonFrontendContribution extends TheiaCommonFrontendContribution
registerCommands(commandRegistry: CommandRegistry): void { registerCommands(commandRegistry: CommandRegistry): void {
super.registerCommands(commandRegistry); super.registerCommands(commandRegistry);
for (const command of [CommonCommands.CONFIGURE_DISPLAY_LANGUAGE]) { for (const command of [
CommonCommands.CONFIGURE_DISPLAY_LANGUAGE,
CommonCommands.CLOSE_TAB,
CommonCommands.CLOSE_SAVED_TABS,
CommonCommands.CLOSE_OTHER_TABS,
CommonCommands.CLOSE_ALL_TABS,
CommonCommands.COLLAPSE_PANEL,
CommonCommands.TOGGLE_MAXIMIZED,
]) {
commandRegistry.unregisterCommand(command); commandRegistry.unregisterCommand(command);
} }
} }
@ -32,10 +40,6 @@ export class CommonFrontendContribution extends TheiaCommonFrontendContribution
CommonCommands.SELECT_ICON_THEME, CommonCommands.SELECT_ICON_THEME,
CommonCommands.SELECT_COLOR_THEME, CommonCommands.SELECT_COLOR_THEME,
CommonCommands.ABOUT_COMMAND, CommonCommands.ABOUT_COMMAND,
CommonCommands.CLOSE_TAB,
CommonCommands.CLOSE_OTHER_TABS,
CommonCommands.CLOSE_ALL_TABS,
CommonCommands.COLLAPSE_PANEL,
CommonCommands.SAVE_WITHOUT_FORMATTING, // Patched for https://github.com/eclipse-theia/theia/pull/8877 CommonCommands.SAVE_WITHOUT_FORMATTING, // Patched for https://github.com/eclipse-theia/theia/pull/8877
]) { ]) {
registry.unregisterMenuAction(command); registry.unregisterMenuAction(command);