summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-08-14 15:19:00 +0300
committerAndrej Mihajlov <and@mullvad.net>2019-08-16 15:21:07 +0300
commit0d1eaf2a466f0056c99c702c0ac9694c321360f2 (patch)
treef2c5ce73fc630c47f5afe32be783bfd4fd32e9b4 /gui/src
parent95af6cd0baf777978d9892c610fe2ee2a0974ebb (diff)
downloadmullvadvpn-0d1eaf2a466f0056c99c702c0ac9694c321360f2.tar.xz
mullvadvpn-0d1eaf2a466f0056c99c702c0ac9694c321360f2.zip
Add IPC handlers for window shape params
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/window-controller.ts4
-rw-r--r--gui/src/renderer/app.tsx16
-rw-r--r--gui/src/shared/ipc-event-channel.ts11
3 files changed, 20 insertions, 11 deletions
diff --git a/gui/src/main/window-controller.ts b/gui/src/main/window-controller.ts
index 3822ecb23f..e681b2a595 100644
--- a/gui/src/main/window-controller.ts
+++ b/gui/src/main/window-controller.ts
@@ -1,4 +1,5 @@
import { BrowserWindow, Display, screen, Tray, WebContents } from 'electron';
+import { IpcMainEventChannel } from '../shared/ipc-event-channel';
interface IPosition {
x: number;
@@ -201,7 +202,8 @@ export default class WindowController {
private notifyUpdateWindowShape() {
const shapeParameters = this.windowPositioning.getWindowShapeParameters(this.windowValue);
- this.windowValue.webContents.send('update-window-shape', shapeParameters);
+
+ IpcMainEventChannel.windowShape.notify(this.windowValue.webContents, shapeParameters);
}
// Installs display event handlers to update the window position on any changes in the display or
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index f4a3e052dc..7bee683701 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -22,7 +22,6 @@ import userInterfaceActions from './redux/userinterface/actions';
import versionActions from './redux/version/actions';
import { IAppUpgradeInfo, ICurrentAppVersionInfo } from '../main';
-import { IWindowShapeParameters } from '../main/window-controller';
import { cities, countries, loadTranslations, messages, relayLocations } from '../shared/gettext';
import { IGuiSettingsState } from '../shared/gui-settings-state';
import { IpcRendererEventChannel } from '../shared/ipc-event-channel';
@@ -84,21 +83,18 @@ export default class AppRenderer {
constructor() {
setupLogging(getRendererLogFile());
- ipcRenderer.on(
- 'update-window-shape',
- (_event: Electron.Event, shapeParams: IWindowShapeParameters) => {
- if (typeof shapeParams.arrowPosition === 'number') {
- this.reduxActions.userInterface.updateWindowArrowPosition(shapeParams.arrowPosition);
- }
- },
- );
-
ipcRenderer.on('window-shown', () => {
if (this.connectedToDaemon) {
this.updateAccountExpiry();
}
});
+ IpcRendererEventChannel.windowShape.listen((windowShapeParams) => {
+ if (typeof windowShapeParams.arrowPosition === 'number') {
+ this.reduxActions.userInterface.updateWindowArrowPosition(windowShapeParams.arrowPosition);
+ }
+ });
+
IpcRendererEventChannel.daemonConnected.listen(() => {
this.onDaemonConnected();
});
diff --git a/gui/src/shared/ipc-event-channel.ts b/gui/src/shared/ipc-event-channel.ts
index 2bb594f5e6..66d1bf2c95 100644
--- a/gui/src/shared/ipc-event-channel.ts
+++ b/gui/src/shared/ipc-event-channel.ts
@@ -5,6 +5,7 @@ import * as uuid from 'uuid';
import { IGuiSettingsState } from './gui-settings-state';
import { IAppUpgradeInfo, ICurrentAppVersionInfo } from '../main/index';
+import { IWindowShapeParameters } from '../main/window-controller';
import {
AccountToken,
BridgeState,
@@ -128,6 +129,8 @@ interface IWireguardKeyHandlers extends ISender<string | undefined> {
/// Events names
+const WINDOW_SHAPE_CHANGED = 'window-shape-changed';
+
const DAEMON_CONNECTED = 'daemon-connected';
const DAEMON_DISCONNECTED = 'daemon-disconnected';
@@ -184,6 +187,10 @@ export class IpcRendererEventChannel {
},
};
+ public static windowShape: IReceiver<IWindowShapeParameters> = {
+ listen: listen(WINDOW_SHAPE_CHANGED),
+ };
+
public static daemonConnected: IReceiver<void> = {
listen: listen(DAEMON_CONNECTED),
};
@@ -265,6 +272,10 @@ export class IpcMainEventChannel {
},
};
+ public static windowShape: ISender<IWindowShapeParameters> = {
+ notify: sender<IWindowShapeParameters>(WINDOW_SHAPE_CHANGED),
+ };
+
public static daemonConnected: ISenderVoid = {
notify: senderVoid(DAEMON_CONNECTED),
};