@@ -87,6 +87,8 @@ class WindowManager {
8787 double WindowManager::GetOpacity ();
8888 void WindowManager::SetOpacity (const flutter::EncodableMap& args);
8989 void WindowManager::StartDragging ();
90+ flutter::EncodableMap WindowManager::GetPrimaryDisplay (
91+ const flutter::EncodableMap& args);
9092
9193 private:
9294 bool g_is_window_fullscreen = false ;
@@ -579,4 +581,29 @@ void WindowManager::StartDragging() {
579581 SendMessage (GetMainWindow (), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0 );
580582}
581583
584+ flutter::EncodableMap WindowManager::GetPrimaryDisplay (
585+ const flutter::EncodableMap& args) {
586+ double devicePixelRatio =
587+ std::get<double >(args.at (flutter::EncodableValue (" devicePixelRatio" )));
588+ POINT ptZero = {0 , 0 };
589+ HMONITOR monitor = MonitorFromPoint (ptZero, MONITOR_DEFAULTTOPRIMARY);
590+ MONITORINFO info;
591+ info.cbSize = sizeof (MONITORINFO);
592+ ::GetMonitorInfo (monitor, &info);
593+
594+ double width =
595+ (info.rcMonitor .right - info.rcMonitor .left ) / devicePixelRatio;
596+ double height =
597+ (info.rcMonitor .bottom - info.rcMonitor .top ) / devicePixelRatio;
598+
599+ flutter::EncodableMap size = flutter::EncodableMap ();
600+ size[flutter::EncodableValue (" width" )] = flutter::EncodableValue (width);
601+ size[flutter::EncodableValue (" height" )] = flutter::EncodableValue (height);
602+
603+ flutter::EncodableMap display = flutter::EncodableMap ();
604+ display[flutter::EncodableValue (" size" )] = flutter::EncodableValue (size);
605+
606+ return display;
607+ }
608+
582609} // namespace
0 commit comments