Disable zoom every time a display gets added or removed

This commit is contained in:
Antonio Scandurra
2016-04-01 15:33:48 +02:00
parent 5464883c1e
commit 793f5f9692
2 changed files with 15 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
_ = require 'underscore-plus'
{ipcRenderer, remote, shell, webFrame} = require 'electron'
{screen, ipcRenderer, remote, shell, webFrame} = require 'electron'
ipcHelpers = require './ipc-helpers'
{Disposable} = require 'event-kit'
{getWindowLoadSettings, setWindowLoadSettings} = require './window-load-settings-helpers'
@@ -241,8 +241,19 @@ class ApplicationDelegate
openExternal: (url) ->
shell.openExternal(url)
disablePinchToZoom: ->
webFrame.setZoomLevelLimits(1, 1)
disableZoom: ->
outerCallback = ->
webFrame.setZoomLevelLimits(1, 1)
outerCallback()
# Set the limits every time a display is added or removed, otherwise the
# configuration gets reset to the default, which allows zooming the
# webframe.
screen.on('display-added', outerCallback)
screen.on('display-removed', outerCallback)
new Disposable ->
screen.removeListener('display-added', outerCallback)
screen.removeListener('display-removed', outerCallback)
checkForUpdate: ->
ipcRenderer.send('command', 'application:check-for-update')