2015-12-08 12:58:39 +08:00
|
|
|
{ipcRenderer, NativeImage} = require 'electron'
|
2015-10-04 09:35:00 +08:00
|
|
|
|
2015-10-19 18:07:35 +08:00
|
|
|
nextId = 0
|
|
|
|
getNextId = -> ++nextId
|
|
|
|
|
2015-12-08 12:58:39 +08:00
|
|
|
exports.getSources = (options, callback) ->
|
2015-10-19 18:07:35 +08:00
|
|
|
id = getNextId()
|
2015-12-08 12:58:39 +08:00
|
|
|
ipcRenderer.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options, id
|
|
|
|
ipcRenderer.once "ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_#{id}", (error_message, sources) ->
|
2015-10-19 10:54:12 +08:00
|
|
|
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)
|