Skip to content

Commit

Permalink
Enable clients to change electron windowOptions either by using the "…
Browse files Browse the repository at this point in the history
…set-window-options" IPC-Event or by specifying the windowOptions inside package.json under theia/frontend/config/electron/windowOptions".

Move "disallowReloadKeybinding" to the aforementioned "electron" object.

Signed-off-by: Luca Jaeger <[email protected]>
  • Loading branch information
owlJaeger authored and vince-fugnitto committed May 22, 2020
1 parent 244f34f commit 82cc44c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

## v1.2.0

- [application-manager] enabled clients to add `windowOptions` using an IPC-Event [#7803](https://github.com/eclipse-theia/theia/pull/7803)
- [application-package] enabled client to change default `windowOptions` [#7803](https://github.com/eclipse-theia/theia/pull/7803)

Breaking changes:

- [scm] support file tree mode in Source Control view. Classes that extend ScmWidget will likely require changes [#7505](https://github.com/eclipse-theia/theia/pull/7505)
- [task] removed `taskId` from `TaskTerminalWidgetOpenerOptions` [#7765](https://github.com/eclipse-theia/theia/pull/7765)
- [core] `KeybindingRegistry` registers a new keybinding with a higher priority than previously in the same scope [#7839](https://github.com/eclipse-theia/theia/pull/7839)
- [application-package] moved `disallowReloadKeybinding` under the `electron` subsection [#7803](https://github.com/eclipse-theia/theia/pull/7803)

## v1.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ const { ElectronSecurityToken } = require('@theia/core/lib/electron-common/elect
const applicationName = \`${this.pck.props.frontend.config.applicationName}\`;
const isSingleInstance = ${this.pck.props.backend.config.singleInstance === true ? 'true' : 'false'};
const disallowReloadKeybinding = ${this.pck.props.frontend.config.disallowReloadKeybinding === true ? 'true' : 'false'};
const disallowReloadKeybinding = ${this.pck.props.frontend.config.electron?.disallowReloadKeybinding === true ? 'true' : 'false'};
const defaultWindowOptionsAdditions = ${this.prettyStringify(this.pck.props.frontend.config.electron?.windowOptions || {})};
if (isSingleInstance && !app.requestSingleInstanceLock()) {
// There is another instance running, exit now. The other instance will request focus.
Expand Down Expand Up @@ -184,6 +186,13 @@ app.on('ready', () => {
width, height, x, y
});
const persistedWindowOptionsAdditions = electronStore.get('windowOptions');

This comment has been minimized.

Copy link
@kittaakos

kittaakos May 25, 2020

Contributor

This is strange, I have just pulled from master (8bb713f) and I can see errors in the generated the electron-main.js.

Store (from electron-store) is a subclass of Conf (from conf), which has the following get API:

  get(key, defaultValue)

@owlJaeger, can you please fix the generator so that it does not produce code with errors?

CC: @vince-fugnitto

This comment has been minimized.

Copy link
@owlJaeger

owlJaeger May 25, 2020

Author Contributor

Will take care 👍

This comment has been minimized.

Copy link
@kittaakos

kittaakos May 25, 2020

Contributor

Thank you! I assume, it won't change anything regarding the behavior, it's a quality thing. Please ping me if you need someone for the review.

This comment has been minimized.

Copy link
@owlJaeger

owlJaeger May 25, 2020

Author Contributor

The PR for adding the default option is here

const windowOptionsAdditions = {
...defaultWindowOptionsAdditions,
...persistedWindowOptionsAdditions
};
let windowOptions = {
show: false,
title: applicationName,
Expand All @@ -193,7 +202,8 @@ app.on('ready', () => {
minHeight: 120,
x: windowState.x,
y: windowState.y,
isMaximized: windowState.isMaximized
isMaximized: windowState.isMaximized,
...windowOptionsAdditions
};
// Always hide the window, we will show the window when it is ready to be shown in any case.
Expand Down Expand Up @@ -291,6 +301,12 @@ app.on('ready', () => {
ipcMain.on('open-external', (event, url) => {
shell.openExternal(url);
});
ipcMain.on('set-window-options', (event, options) => {
electronStore.set('windowOptions', options);
});
ipcMain.on('get-persisted-window-options-additions', event => {
event.returnValue = electronStore.get('windowOptions');
});
// Check whether we are in bundled application or development mode.
// @ts-ignore
Expand Down
14 changes: 14 additions & 0 deletions dev-packages/application-package/src/application-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import type { BrowserWindowConstructorOptions } from 'electron';

export interface NpmRegistryProps {

/**
Expand Down Expand Up @@ -113,12 +115,24 @@ export interface FrontendApplicationConfig extends ApplicationConfig {
*/
readonly applicationName: string;

/**
* Electron specific configuration.
*/
readonly electron?: Readonly<ElectronFrontendApplicationConfig>;
}

export interface ElectronFrontendApplicationConfig {

/**
* If set to `true`, reloading the current browser window won't be possible with the `Ctrl/Cmd + R` keybinding.
* It is `false` by default. Has no effect if not in an electron environment.
*/
readonly disallowReloadKeybinding?: boolean;

/**
* Override or add properties to the electron `windowOptions`.
*/
readonly windowOptions?: BrowserWindowConstructorOptions;
}

/**
Expand Down

0 comments on commit 82cc44c

Please sign in to comment.