This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 1 file changed +26
-0
lines changed
shell/platform/darwin/macos/framework/Source 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,7 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint {
281
281
282
282
[self sendUserLocales ];
283
283
[self updateWindowMetrics ];
284
+ [self updateDisplayConfig ];
284
285
return YES ;
285
286
}
286
287
@@ -317,6 +318,31 @@ - (NSOpenGLContext*)resourceContext {
317
318
return _resourceContext;
318
319
}
319
320
321
+ - (void )updateDisplayConfig {
322
+ if (!_engine) {
323
+ return ;
324
+ }
325
+
326
+ CVDisplayLinkRef displayLinkRef;
327
+ CGDirectDisplayID mainDisplayID = CGMainDisplayID ();
328
+ CVDisplayLinkCreateWithCGDisplay (mainDisplayID, &displayLinkRef);
329
+ CVTime nominal = CVDisplayLinkGetNominalOutputVideoRefreshPeriod (displayLinkRef);
330
+ if (!(nominal.flags & kCVTimeIsIndefinite )) {
331
+ double refreshRate = static_cast <double >(nominal.timeScale ) / nominal.timeValue ;
332
+
333
+ FlutterEngineDisplay display;
334
+ display.struct_size = sizeof (display);
335
+ display.display_id = mainDisplayID;
336
+ display.refresh_rate = round (refreshRate);
337
+
338
+ std::vector<FlutterEngineDisplay> displays = {display};
339
+ FlutterEngineNotifyDisplayUpdate (_engine, kFlutterEngineDisplaysUpdateTypeStartup ,
340
+ displays.data (), displays.size ());
341
+ }
342
+
343
+ CVDisplayLinkRelease (displayLinkRef);
344
+ }
345
+
320
346
- (void )updateWindowMetrics {
321
347
if (!_engine) {
322
348
return ;
You can’t perform that action at this time.
0 commit comments