electron/atom/renderer/api/lib/desktop-capturer.coffee

12 lines
520 B
CoffeeScript
Raw Normal View History

2015-12-08 04:58:39 +00:00
{ipcRenderer, NativeImage} = require 'electron'
nextId = 0
getNextId = -> ++nextId
2015-12-08 04:58:39 +00:00
exports.getSources = (options, callback) ->
id = getNextId()
2015-12-08 04:58:39 +00:00
ipcRenderer.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options, id
ipcRenderer.once "ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_#{id}", (error_message, sources) ->
error = if error_message then Error error_message else null
callback error, ({id: source.id, name: source.name, thumbnail: NativeImage.createFromDataUrl source.thumbnail} for source in sources)