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

Commit

Permalink
Merge pull request #5170 from bsclifton/fix-win32-border
Browse files Browse the repository at this point in the history
Fix multiple issues discovered by testers
  • Loading branch information
bbondy authored Oct 27, 2016
2 parents badd82d + 4a5a5ea commit 1352fa1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
1 change: 1 addition & 0 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ class Main extends ImmutableComponent {
return <div id='window'
className={cx({
isFullScreen: activeFrame && activeFrame.get('isFullScreen'),
isMaximized: customTitlebar.isMaximized,
frameless: customTitlebar.captionButtonsVisible
})}
ref={(node) => { this.mainWindow = node }}
Expand Down
4 changes: 2 additions & 2 deletions js/lib/eventUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
const {isDarwin} = require('../../app/common/lib/platformUtil')

module.exports.isForSecondaryAction = (e) =>
e.ctrlKey && !isDarwin ||
e.metaKey && isDarwin ||
(e.ctrlKey && !isDarwin()) ||
(e.metaKey && isDarwin()) ||
e.button === 1

module.exports.eventElHasAncestorWithClasses = (e, classesToCheck) => {
Expand Down
48 changes: 34 additions & 14 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,62 @@ function isModal (browserOpts) {
return browserOpts.scrollbars === false
}

function navbarHeight () {
const navbarHeight = () => {
// TODO there has to be a better way to get this or at least add a test
return 75
}

const createWindow = (browserOpts, defaults, frameOpts, windowState) => {
const parentWindowKey = browserOpts.parentWindowKey

/**
* Determine window dimensions (width / height)
*/
const setWindowDimensions = (browserOpts, defaults, windowState) => {
if (windowState.ui && windowState.ui.size) {
browserOpts.width = firstDefinedValue(browserOpts.width, windowState.ui.size[0])
browserOpts.height = firstDefinedValue(browserOpts.height, windowState.ui.size[1])
}

browserOpts.width = firstDefinedValue(browserOpts.width, browserOpts.innerWidth, defaults.width)
// height and innerHeight are the frame webview size
browserOpts.height = firstDefinedValue(browserOpts.height, browserOpts.innerHeight)
if (isNaN(browserOpts.height)) {
if (typeof browserOpts.height === 'number') {
// add navbar height to get total height for BrowserWindow
browserOpts.height = browserOpts.height + navbarHeight()
} else {
// no inner height so check outer height or use default
browserOpts.height = firstDefinedValue(browserOpts.outerHeight, defaults.height)
} else {
// BrowserWindow height is window height so add navbar height
browserOpts.height = browserOpts.height + navbarHeight()
}
return browserOpts
}

/**
* Determine window position (x / y)
*/
const setWindowPosition = (browserOpts, defaults, windowState) => {
if (windowState.ui && windowState.ui.position) {
// Position comes from window state
browserOpts.x = firstDefinedValue(browserOpts.x, windowState.ui.position[0])
browserOpts.y = firstDefinedValue(browserOpts.y, windowState.ui.position[1])
} else if (typeof defaults.x === 'number' && typeof defaults.y === 'number') {
// Position comes from the default position
browserOpts.x = firstDefinedValue(browserOpts.x, defaults.x)
browserOpts.y = firstDefinedValue(browserOpts.y, defaults.y)
} else {
// Default the position
browserOpts.x = firstDefinedValue(browserOpts.x, browserOpts.left, browserOpts.screenX)
browserOpts.y = firstDefinedValue(browserOpts.y, browserOpts.top, browserOpts.screenY)
}
return browserOpts
}

const createWindow = (browserOpts, defaults, frameOpts, windowState) => {
browserOpts = setWindowDimensions(browserOpts, defaults, windowState)
browserOpts = setWindowPosition(browserOpts, defaults, windowState)

browserOpts.x = firstDefinedValue(browserOpts.x, browserOpts.left, browserOpts.screenX, defaults.x)
browserOpts.y = firstDefinedValue(browserOpts.y, browserOpts.top, browserOpts.screenY, defaults.y)
delete browserOpts.left
delete browserOpts.top

const screen = electron.screen
const primaryDisplay = screen.getPrimaryDisplay()
const parentWindowKey = browserOpts.parentWindowKey
const parentWindow = parentWindowKey ? BrowserWindow.fromId(parentWindowKey) : BrowserWindow.getFocusedWindow()
const bounds = parentWindow ? parentWindow.getBounds() : primaryDisplay.bounds

Expand All @@ -100,7 +120,7 @@ const createWindow = (browserOpts, defaults, frameOpts, windowState) => {

// if no parentWindow, x, y or center is defined then go ahead
// and center it if it's smaller than the display width
// typeof and isNaN are used because 0 is falsy
// typeof and isNaN are used because 0 is falsey
if (!(parentWindow ||
browserOpts.center === false ||
browserOpts.x > 0 ||
Expand Down Expand Up @@ -258,8 +278,8 @@ function windowDefaults () {
show: false,
width: appState.getIn(['defaultWindowParams', 'width']) || appState.get('defaultWindowWidth'),
height: appState.getIn(['defaultWindowParams', 'height']) || appState.get('defaultWindowHeight'),
x: appState.getIn(['defaultWindowParams', 'x']),
y: appState.getIn(['defaultWindowParams', 'y']),
x: appState.getIn(['defaultWindowParams', 'x']) || undefined,
y: appState.getIn(['defaultWindowParams', 'y']) || undefined,
minWidth: 480,
minHeight: 300,
minModalHeight: 100,
Expand Down
2 changes: 1 addition & 1 deletion less/about/bookmarks.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
height: 1rem;
&.selected >*,
&.isDragOver >* {
font-weight: 800;
font-weight: 600;
}
&.isDragOver {
background-color: lighten(@braveOrange, 20%);
Expand Down
6 changes: 3 additions & 3 deletions less/navigationBar.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

// Windows specific styles
.platform--win32 {
div#window.frameless {
div#window.frameless:not(.isFullScreen):not(.isMaximized) {
border: 1px solid #000;
box-sizing: border-box;
}
Expand Down Expand Up @@ -222,10 +222,10 @@

// Windows 10 specific styles
&.win10 {
&.inactive div#window.frameless {
&.inactive div#window.frameless:not(.isFullScreen):not(.isMaximized) {
border: 1px solid #aaaaaa;
}
div#window.frameless {
div#window.frameless:not(.isFullScreen):not(.isMaximized) {
border: 1px solid #2283d3;
}
.windowCaptionButtons {
Expand Down

0 comments on commit 1352fa1

Please sign in to comment.