mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Don't hard-code API names
This commit is contained in:
@@ -4,14 +4,12 @@ checkAppIsReady = ->
|
||||
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')
|
||||
|
||||
module.exports =
|
||||
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
|
||||
# On Linux we could not access screen in renderer process.
|
||||
require('remote').require 'screen'
|
||||
else
|
||||
getCursorScreenPoint: ->
|
||||
checkAppIsReady()
|
||||
binding.getCursorScreenPoint()
|
||||
getPrimaryDisplay: ->
|
||||
checkAppIsReady()
|
||||
binding.getPrimaryDisplay()
|
||||
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
|
||||
# On Linux and Windows we could not access screen in renderer process.
|
||||
module.exports = require('remote').require 'screen'
|
||||
else
|
||||
for name, _ of binding
|
||||
do (name) ->
|
||||
module.exports[name] = (args...) ->
|
||||
checkAppIsReady()
|
||||
binding[name](args...)
|
||||
|
||||
Reference in New Issue
Block a user