@@ -24,7 +24,7 @@ use crate::{
2424 utils:: config:: Config ,
2525 utils:: { assets:: Assets , Env } ,
2626 Context , DeviceEventFilter , EventLoopMessage , Icon , Invoke , InvokeError , InvokeResponse , Manager ,
27- Runtime , Scopes , StateManager , Theme , Window ,
27+ Monitor , Runtime , Scopes , StateManager , Theme , Window ,
2828} ;
2929
3030#[ cfg( feature = "protocol-asset" ) ]
@@ -570,6 +570,35 @@ macro_rules! shared_app_impl {
570570 }
571571 }
572572
573+ /// Returns the primary monitor of the system.
574+ ///
575+ /// Returns None if it can't identify any monitor as a primary one.
576+ pub fn primary_monitor( & self ) -> crate :: Result <Option <Monitor >> {
577+ Ok ( match self . runtime( ) {
578+ RuntimeOrDispatch :: Runtime ( h) => h
579+ . primary_monitor( ) . map( Into :: into) ,
580+ RuntimeOrDispatch :: RuntimeHandle ( h) => h
581+ . primary_monitor( ) . map( Into :: into) ,
582+ _ => unreachable!( )
583+ } )
584+ }
585+
586+ /// Returns the list of all the monitors available on the system.
587+ pub fn available_monitors( & self ) -> crate :: Result <Vec <Monitor >> {
588+ Ok ( match self . runtime( ) {
589+ RuntimeOrDispatch :: Runtime ( h) => h
590+ . available_monitors( )
591+ . into_iter( )
592+ . map( Into :: into)
593+ . collect( ) ,
594+ RuntimeOrDispatch :: RuntimeHandle ( h) => h
595+ . available_monitors( )
596+ . into_iter( )
597+ . map( Into :: into)
598+ . collect( ) ,
599+ _ => unreachable!( )
600+ } )
601+ }
573602 /// Returns the default window icon.
574603 pub fn default_window_icon( & self ) -> Option <& Icon > {
575604 self . manager. inner. default_window_icon. as_ref( )
0 commit comments