1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -175,9 +175,20 @@ bool GetIsMonochrome() {
175
175
// Returns the display object with the specified display id.
176
176
Napi::Object GetDisplayFromID (const Napi::CallbackInfo &info) {
177
177
uint32_t display_id = info[0 ].As <Napi::Number>().Uint32Value ();
178
- NSScreen *screen = ScreenForID (display_id);
179
178
180
- return screen ? BuildDisplay (info.Env (), screen) : Napi::Object ();
179
+ NSArray <NSScreen *> *screens = [NSScreen screens ];
180
+
181
+ size_t num_displays = [screens count ];
182
+ for (size_t i = 0 ; i < num_displays; i++) {
183
+ NSScreen *screen = [screens objectAtIndex: i];
184
+ CGDirectDisplayID s_id = [[[screen deviceDescription ]
185
+ objectForKey: @" NSScreenNumber" ] unsignedIntValue ];
186
+ if (s_id == display_id) {
187
+ return BuildDisplay (info.Env (), screen);
188
+ }
189
+ }
190
+
191
+ return Napi::Object ();
181
192
}
182
193
183
194
// Initializes all functions exposed to JS.
0 commit comments