Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Fix window controls on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Jun 4, 2020
1 parent 6f43e9c commit 2e4d80a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
22 changes: 22 additions & 0 deletions app/bg/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export const WEBAPI = {
setSidebarResizeModeEnabled,
moveWindow,
maximizeWindow,
toggleWindowMaximized,
minimizeWindow,
closeWindow,
resizeSiteInfo,
refreshTabState,

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/bg/web-apis/manifests/internal/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default {
setSidebarResizeModeEnabled: 'promise',
moveWindow: 'promise',
maximizeWindow: 'promise',
toggleWindowMaximized: 'promise',
minimizeWindow: 'promise',
closeWindow: 'promise',
resizeSiteInfo: 'promise',
refreshTabState: 'promise',

Expand Down
14 changes: 4 additions & 10 deletions app/fg/shell-window/win32.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`
Expand Down

0 comments on commit 2e4d80a

Please sign in to comment.