diff --git a/app/bg/browser.js b/app/bg/browser.js index 228de49acb..0fb5cc1ab8 100644 --- a/app/bg/browser.js +++ b/app/bg/browser.js @@ -189,6 +189,9 @@ export const WEBAPI = { setSidebarResizeModeEnabled, moveWindow, maximizeWindow, + toggleWindowMaximized, + minimizeWindow, + closeWindow, resizeSiteInfo, refreshTabState, @@ -430,6 +433,25 @@ export async function maximizeWindow () { win.maximize() } +async function toggleWindowMaximized () { + var win = findWebContentsParentWindow(this.sender) + if (win.isMaximized()) { + win.unmaximize() + } else { + win.maximize() + } +} + +async function minimizeWindow () { + var win = findWebContentsParentWindow(this.sender) + win.minimize() +} + +async function closeWindow () { + var win = findWebContentsParentWindow(this.sender) + win.close() +} + export function resizeSiteInfo (bounds) { var win = findWebContentsParentWindow(this.sender) if (!win) return diff --git a/app/bg/web-apis/manifests/internal/browser.js b/app/bg/web-apis/manifests/internal/browser.js index 49fa612b40..8500077546 100644 --- a/app/bg/web-apis/manifests/internal/browser.js +++ b/app/bg/web-apis/manifests/internal/browser.js @@ -44,6 +44,9 @@ export default { setSidebarResizeModeEnabled: 'promise', moveWindow: 'promise', maximizeWindow: 'promise', + toggleWindowMaximized: 'promise', + minimizeWindow: 'promise', + closeWindow: 'promise', resizeSiteInfo: 'promise', refreshTabState: 'promise', diff --git a/app/fg/shell-window/win32.js b/app/fg/shell-window/win32.js index 6a94ba4998..320ac40bd8 100644 --- a/app/fg/shell-window/win32.js +++ b/app/fg/shell-window/win32.js @@ -1,7 +1,6 @@ /* globals customElements */ import { LitElement, html, css } from '../vendor/lit-element/lit-element' -// import * as bg from './bg-process-rpc' -import { remote } from 'electron' +import * as bg from './bg-process-rpc' class ShellWindowWin32 extends LitElement { // rendering @@ -21,20 +20,15 @@ class ShellWindowWin32 extends LitElement { // = onClickMinimize () { - remote.getCurrentWindow().minimize() + bg.beakerBrowser.minimizeWindow() } onClickMaximize () { - var win = remote.getCurrentWindow() - if (win.isMaximized()) { - win.unmaximize() - } else { - win.maximize() - } + bg.beakerBrowser.toggleWindowMaximized() } onClickClose () { - remote.getCurrentWindow().close() + bg.beakerBrowser.closeWindow() } } ShellWindowWin32.styles = css`