@@ -25,6 +25,7 @@ function DesktopCaptureMonitor() {
25
25
}
26
26
require ( 'util' ) . inherits ( DesktopCaptureMonitor , exports . Base ) ;
27
27
28
+
28
29
DesktopCaptureMonitor . prototype . start = function ( screens , windows ) {
29
30
if ( this . started )
30
31
return false ;
@@ -43,6 +44,11 @@ DesktopCaptureMonitor.prototype.stop = function () {
43
44
}
44
45
45
46
DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_added' , function ( id , name , order , type ) {
47
+ if ( this . sources . indexOf ( id ) != - 1 )
48
+ {
49
+ //TODO: Find out what this event comes twice on some platforms
50
+ return ;
51
+ }
46
52
this . sources . splice ( order , 0 , id ) ;
47
53
this . emit ( "added" , id , name , order , type ) ;
48
54
for ( var i = order + 1 ; i <= this . sources . length - 1 ; i ++ ) {
@@ -51,7 +57,7 @@ DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_added',
51
57
} ) ;
52
58
53
59
54
- DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_removed' , function ( index ) {
60
+ DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_removed' , function ( index ) {
55
61
var id = this . sources [ index ] ;
56
62
if ( index != - 1 ) {
57
63
this . sources . splice ( index , 1 ) ;
@@ -62,7 +68,7 @@ DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_removed
62
68
}
63
69
} ) ;
64
70
65
- DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_moved' , function ( id , new_index , old_index ) {
71
+ DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_moved' , function ( id , new_index , old_index ) {
66
72
var temp = this . sources [ old_index ] ;
67
73
this . sources . splice ( old_index , 1 ) ;
68
74
this . sources . splice ( new_index , 0 , temp ) ;
@@ -71,14 +77,15 @@ DesktopCaptureMonitor.prototype.on('__nw_desktop_capture_monitor_listner_moved',
71
77
this . emit ( "orderchanged" , this . sources [ i + 1 ] , i + 1 , i ) ;
72
78
} ) ;
73
79
74
- DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_namechanged' , function ( id , name ) {
80
+ DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_namechanged' , function ( id , name ) {
75
81
this . emit ( "namechanged" , id , name ) ;
76
82
} ) ;
77
83
78
- DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_thumbnailchanged' , function ( id , thumbnail ) {
84
+ DesktopCaptureMonitor . prototype . on ( '__nw_desktop_capture_monitor_listner_thumbnailchanged' , function ( id , thumbnail ) {
79
85
this . emit ( "thumbnailchanged" , id , thumbnail ) ;
80
86
} ) ;
81
87
88
+ var listenerCount = 0 ;
82
89
DesktopCaptureMonitor . prototype . on = DesktopCaptureMonitor . prototype . addListener = function ( ev , callback ) {
83
90
//throw except if unsupported event
84
91
if ( ev != "added" && ev != "removed" && ev != "orderchanged" && ev != "namechanged" && ev != "thumbnailchanged" )
@@ -87,6 +94,9 @@ DesktopCaptureMonitor.prototype.on = DesktopCaptureMonitor.prototype.addListener
87
94
process . EventEmitter . prototype . addListener . apply ( this , arguments ) ;
88
95
}
89
96
97
+
98
+ exports . DesktopCaptureMonitor = DesktopCaptureMonitor ;
99
+
90
100
var screenInstance = null ;
91
101
92
102
function Screen ( ) {
0 commit comments