Skip to content

Commit

Permalink
Create a Buffer Window, which is used consistently to open new window…
Browse files Browse the repository at this point in the history
…s more instantly

A buffer window is created at startup, and any time a previous buffer window is detached in order to be utilized as a real window.
This type of window is not shown and has no tabs (pinned or non-pinned) until it is shown.
State is not persisted for Buffer Windows until they are utilized as real windows.

A new command-line flag is introduced: '--debug-window-events' which shows logging around Buffer Window creation and utilization, as well as all other window events. No additional logging should be present without this flag.

Fix brave#12437
  • Loading branch information
petemill authored and ryanml committed Feb 27, 2018
1 parent 771ee45 commit ab3959a
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 81 deletions.
27 changes: 4 additions & 23 deletions app/browser/reducers/windowsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ const {makeImmutable, isImmutable} = require('../../common/state/immutableUtil')
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const firstDefinedValue = require('../../../js/lib/functional').firstDefinedValue
const appConfig = require('../../../js/constants/appConfig')
const settings = require('../../../js/constants/settings')
const getSetting = require('../../../js/settings').getSetting

const platformUtil = require('../../common/lib/platformUtil')

const isDarwin = platformUtil.isDarwin()
const isWindows = platformUtil.isWindows()

// TODO cleanup all this createWindow crap
function isModal (browserOpts) {
// this needs some better checks
Expand Down Expand Up @@ -100,6 +94,8 @@ const setWindowPosition = (browserOpts, defaults, immutableWindowState) => {
const screenPos = electron.screen.getCursorScreenPoint()
browserOpts.x = screenPos.x
browserOpts.y = screenPos.y
// ensure only valid BrowserWindow opts remain in browserOpts
delete browserOpts.positionByMouseCursor
} else if (immutableWindowState.getIn(['windowInfo'])) {
// Position comes from window state
browserOpts.x = firstDefinedValue(browserOpts.x, immutableWindowState.getIn(['windowInfo', 'left']))
Expand All @@ -120,7 +116,7 @@ const setMaximized = (state, browserOpts, immutableWindowState) => {
if (Object.keys(browserOpts).length > 0 && !browserOpts.checkMaximized) {
return false
}

delete browserOpts.checkMaximized
if (immutableWindowState.getIn(['windowInfo'])) {
return immutableWindowState.getIn(['windowInfo', 'state']) === 'maximized'
}
Expand All @@ -138,12 +134,7 @@ function windowDefaults (state) {
minHeight: 300,
minModalHeight: 100,
minModalWidth: 100,
windowOffset: 20,
webPreferences: {
// XXX: Do not edit without security review
sharedWorker: true,
partition: 'default'
}
windowOffset: 20
}
}

Expand Down Expand Up @@ -246,20 +237,10 @@ const handleCreateWindowAction = (state, action) => {
browserOpts.width = browserOpts.width < minWidth ? minWidth : browserOpts.width
browserOpts.height = browserOpts.height < minHeight ? minHeight : browserOpts.height

const autoHideMenuBarSetting = isDarwin || getSetting(settings.AUTO_HIDE_MENU)

const windowProps = {
// smaller min size for "modal" windows
minWidth,
minHeight,
// Neither a frame nor a titlebar
// frame: false,
// A frame but no title bar and windows buttons in titlebar 10.10 OSX and up only?
titleBarStyle: 'hidden-inset',
autoHideMenuBar: autoHideMenuBarSetting,
title: appConfig.name,
webPreferences: defaults.webPreferences,
frame: !isWindows,
disposition: frameOpts.disposition
}

Expand Down
Loading

0 comments on commit ab3959a

Please sign in to comment.