Skip to content

Commit

Permalink
electron: fix electron global shortcuts
Browse files Browse the repository at this point in the history
The commit restores a fix that would previously remove the problematic
`attachGlobalShortcuts` refactoring. The changes should now properly
reload the application when necessary, and support commands such as
recursive-search in the terminal.

Signed-off-by: vince-fugnitto <[email protected]>
Co-authored-by: Colin Grant <[email protected]>
  • Loading branch information
vince-fugnitto and colin-grant-work committed Mar 10, 2022
1 parent e62fd33 commit 03e6efd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

- [plugin] added support for `DocumentSymbolProviderMetadata` [#10811](https://github.com/eclipse-theia/theia/pull/10811) - Contributed on behalf of STMicroelectronics

## v1.24.0 - unreleased

[1.24.0 Milestone](https://github.com/eclipse-theia/theia/milestone/32)

<a name="breaking_changes_1.24.0">[Breaking Changes:](#breaking_changes_1.24.0)</a>

- [markers] `ProblemDecorator` reimplemented to reduce redundancy and align more closely with VSCode. `collectMarkers` now returns `Map<string, TreeDecoration.Data>`, `getOverlayIconColor` renamed to `getColor`, `getOverlayIcon` removed, `appendContainerMarkers` returns `void`.
- [markers] `ProblemDecorator` reimplemented to reduce redundancy and align more closely with VSCode. `collectMarkers` now returns `Map<string, TreeDecoration.Data>`, `getOverlayIconColor` renamed to `getColor`, `getOverlayIcon` removed, `appendContainerMarkers` returns `void`.
- [core] removed method `attachGlobalShortcuts` from `ElectronMainApplication`. Attaching shortcuts in that way interfered with internal shortcuts. Use internal keybindings instead of global shortcuts [#10869](https://github.com/eclipse-theia/theia/pull/10869)

## v1.23.0 - 2/24/2022

Expand Down
23 changes: 1 addition & 22 deletions packages/core/src/electron-main/theia-electron-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { FrontendApplicationConfig } from '@theia/application-package';
import { FrontendApplicationState } from '../common/frontend-application-state';
import { APPLICATION_STATE_CHANGE_SIGNAL, CLOSE_REQUESTED_SIGNAL, RELOAD_REQUESTED_SIGNAL, StopReason } from '../electron-common/messaging/electron-messages';
import { BrowserWindow, BrowserWindowConstructorOptions, globalShortcut, ipcMain, IpcMainEvent } from '../../electron-shared/electron';
import { BrowserWindow, BrowserWindowConstructorOptions, ipcMain, IpcMainEvent } from '../../electron-shared/electron';
import { inject, injectable, postConstruct } from '../../shared/inversify';
import { ElectronMainApplicationGlobals } from './electron-main-constants';
import { DisposableCollection, Emitter, Event, isWindows } from '../common';
Expand Down Expand Up @@ -69,7 +69,6 @@ export class TheiaElectronWindow {
this._window = new BrowserWindow(this.options);
this._window.setMenuBarVisibility(false);
this.attachReadyToShow();
this.attachGlobalShortcuts();
this.restoreMaximizedState();
this.attachCloseListeners();
this.trackApplicationState();
Expand Down Expand Up @@ -103,26 +102,6 @@ export class TheiaElectronWindow {
this._window.close();
}

/**
* Catch certain keybindings to prevent reloading the window using keyboard shortcuts.
*/
protected attachGlobalShortcuts(): void {
const handler = this.config.electron?.disallowReloadKeybinding
? () => { }
: () => this.reload();
const accelerators = ['CmdOrCtrl+R', 'F5'];
createDisposableListener(this._window, 'focus', () => {
for (const accelerator of accelerators) {
globalShortcut.register(accelerator, handler);
}
}, this.toDispose);
createDisposableListener(this._window, 'blur', () => {
for (const accelerator of accelerators) {
globalShortcut.unregister(accelerator);
}
}, this.toDispose);
}

close(reason: StopReason = StopReason.Close): Promise<boolean> {
return this.handleStopRequest(() => this.doCloseWindow(), reason);
}
Expand Down

0 comments on commit 03e6efd

Please sign in to comment.