Don't hard-code API names
This commit is contained in:
parent
ab9e1dd650
commit
509294b228
1 changed files with 9 additions and 11 deletions
|
@ -4,14 +4,12 @@ checkAppIsReady = ->
|
||||||
unless process.type is 'renderer' or require('app').isReady()
|
unless process.type is 'renderer' or require('app').isReady()
|
||||||
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
|
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
|
||||||
|
|
||||||
module.exports =
|
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
|
||||||
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
|
# On Linux and Windows we could not access screen in renderer process.
|
||||||
# On Linux we could not access screen in renderer process.
|
module.exports = require('remote').require 'screen'
|
||||||
require('remote').require 'screen'
|
else
|
||||||
else
|
for name, _ of binding
|
||||||
getCursorScreenPoint: ->
|
do (name) ->
|
||||||
checkAppIsReady()
|
module.exports[name] = (args...) ->
|
||||||
binding.getCursorScreenPoint()
|
checkAppIsReady()
|
||||||
getPrimaryDisplay: ->
|
binding[name](args...)
|
||||||
checkAppIsReady()
|
|
||||||
binding.getPrimaryDisplay()
|
|
||||||
|
|
Loading…
Reference in a new issue