File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree 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 {
281281
282282 [self sendUserLocales ];
283283 [self updateWindowMetrics ];
284+ [self updateDisplayConfig ];
284285 return YES ;
285286}
286287
@@ -317,6 +318,31 @@ - (NSOpenGLContext*)resourceContext {
317318 return _resourceContext;
318319}
319320
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+
320346- (void )updateWindowMetrics {
321347 if (!_engine) {
322348 return ;
You can’t perform that action at this time.
0 commit comments