File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,6 +175,9 @@ pub enum Action {
175175
176176 /// Set the window size increment.
177177 SetResizeIncrements ( Id , Option < Size > ) ,
178+
179+ /// Get the size of the monitor on which the window currently resides in logical dimensions.
180+ GetMonitorSize ( Id , oneshot:: Sender < Option < Size > > ) ,
178181}
179182
180183/// Subscribes to the frames of the window of the running application.
@@ -479,3 +482,10 @@ pub fn enable_mouse_passthrough<Message>(id: Id) -> Task<Message> {
479482pub fn disable_mouse_passthrough < Message > ( id : Id ) -> Task < Message > {
480483 task:: effect ( crate :: Action :: Window ( Action :: DisableMousePassthrough ( id) ) )
481484}
485+
486+ /// Get the size of the monitor on which the window currently resides in logical dimensions.
487+ pub fn get_monitor_size ( id : Id ) -> Task < Option < Size > > {
488+ task:: oneshot ( move |channel| {
489+ crate :: Action :: Window ( Action :: GetMonitorSize ( id, channel) )
490+ } )
491+ }
Original file line number Diff line number Diff line change @@ -1491,6 +1491,16 @@ fn run_action<P, C>(
14911491 let _ = window. raw . set_cursor_hittest ( true ) ;
14921492 }
14931493 }
1494+ window:: Action :: GetMonitorSize ( id, channel) => {
1495+ if let Some ( window) = window_manager. get ( id) {
1496+ let size = window. raw . current_monitor ( ) . map ( |monitor| {
1497+ let factor = monitor. scale_factor ( ) ;
1498+ let size = monitor. size ( ) . to_logical ( factor) ;
1499+ Size :: new ( size. width , size. height )
1500+ } ) ;
1501+ let _ = channel. send ( size) ;
1502+ }
1503+ }
14941504 } ,
14951505 Action :: System ( action) => match action {
14961506 system:: Action :: QueryInformation ( _channel) => {
You can’t perform that action at this time.
0 commit comments