Skip to content

Commit

Permalink
Fix scale change bug
Browse files Browse the repository at this point in the history
  • Loading branch information
staniel359 committed Jan 28, 2023
1 parent 9004ae5 commit 6537bb8
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 13 deletions.
20 changes: 9 additions & 11 deletions electron/actions/app/setScale.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
const getTabs = require(
'../tabs/get'
const setMainWindowScale = require(
'../mainWindow/setScale'
)
const setTabBounds = require(
'../tab/setBounds'
const setTabsScale = require(
'../tabs/setScale'
)

function setScale (
value
) {
mainWindow
.webContents
.setZoomFactor(
value
)
setMainWindowScale(
value
)

getTabs().forEach(
setTabBounds
setTabsScale(
value
)
}

Expand Down
2 changes: 1 addition & 1 deletion electron/actions/app/setTopOffset.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
'../../utils'
)

function setTopOffset() {
function setTopOffset () {
const isFullScreen =
mainWindow.isFullScreen()

Expand Down
2 changes: 1 addition & 1 deletion electron/actions/mainWindow/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const setTopOffset = require(
'../app/setTopOffset'
)
const setScale = require(
'../app/setScale'
'./setScale'
)
const callExit = require(
'../app/callExit'
Expand Down
11 changes: 11 additions & 0 deletions electron/actions/mainWindow/setScale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function setScale (
value
) {
mainWindow
.webContents
.setZoomFactor(
value
)
}

module.exports = setScale
22 changes: 22 additions & 0 deletions electron/actions/tab/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const setActive = require(
const setBounds = require(
'./setBounds'
)
const setScale = require(
'./setScale'
)
const {
baseUrl
} = require(
Expand Down Expand Up @@ -115,6 +118,18 @@ function create (
)
}

function handleDomReady () {
const scale =
electronStore.get(
'layout.scale'
)

setScale(
tab,
scale
)
}

tab
.webContents
.setWindowOpenHandler(
Expand All @@ -127,6 +142,13 @@ function create (
'did-start-navigation',
handleDidStartNavigation
)

tab
.webContents
.on(
'dom-ready',
handleDomReady
)
}

module.exports = create
12 changes: 12 additions & 0 deletions electron/actions/tab/setScale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function setScale (
tab,
value
) {
tab
.webContents
.setZoomFactor(
value
)
}

module.exports = setScale
32 changes: 32 additions & 0 deletions electron/actions/tabs/setScale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const getTabs = require(
'./get'
)
const setTabBounds = require(
'../tab/setBounds'
)
const setTabScale = require(
'../tab/setScale'
)

function setScale (
value
) {
function setTabBoundsAndScale (
tab
) {
setTabBounds(
tab
)

setTabScale(
tab,
value
)
}

getTabs().forEach(
setTabBoundsAndScale
)
}

module.exports = setScale

0 comments on commit 6537bb8

Please sign in to comment.