Skip to content

Commit

Permalink
Fix BrowserView position
Browse files Browse the repository at this point in the history
Seems the starting point of bounds.y starts from the underlayer of the title bar.
  • Loading branch information
Watson1978 committed Aug 25, 2019
1 parent 48a131c commit 8325e9e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/BrowserViewProxy.js
Expand Up @@ -70,6 +70,10 @@ export default class BrowserViewProxy {
global.mainWindow.webContents.focus();
}

static titleBarHeight() {
return global.mainWindow.getSize()[1] - global.mainWindow.getContentSize()[1]
}

static executeJavaScript(js) {
return this._webContents.executeJavaScript(js);
}
Expand All @@ -92,19 +96,21 @@ export default class BrowserViewProxy {
if (Platform.isWin()) height -= 35; // menu bar height?
if (Platform.isLinux()) height += 22; // menu bar height?

const titleBar = this.titleBarHeight();

if (this._layout === layout) {
this.setBounds({x: 521, y: 43, width: width - 521, height: height - 43 - 40});
this.setBounds({x: 521, y: 43 + titleBar, width: width - 521, height: height - 43 - 40});
this._layout = null;
} else {
switch (layout) {
case 'single':
this.setBounds({x: 1, y: 43, width: width - 1, height: height - 43 - 40});
this.setBounds({x: 1, y: 43 + titleBar, width: width - 1, height: height - 43 - 40});
break;
case 'two':
this.setBounds({x: 301, y: 43, width: width - 301, height: height - 43 - 40});
this.setBounds({x: 301, y: 43 + titleBar, width: width - 301, height: height - 43 - 40});
break;
case 'three':
this.setBounds({x: 521, y: 43, width: width - 521, height: height - 43 - 40});
this.setBounds({x: 521, y: 43 + titleBar, width: width - 521, height: height - 43 - 40});
break;
}
this._layout = layout;
Expand Down

0 comments on commit 8325e9e

Please sign in to comment.