@@ -910,20 +910,18 @@ impl OrbitalScheme {
910910 fn tile_window ( & mut self , window_id : Option < & usize > , position : TilePosition ) {
911911 if let Some ( id) = window_id. or ( self . order . front ( ) ) {
912912 if let Some ( window) = self . windows . get_mut ( id) {
913- let display_index =
914- Self :: get_display_index ( & self . compositor . displays , & window. rect ( ) ) ;
915913 Self :: update_window ( & mut self . compositor , window, |compositor, window| {
916914 let ( x, y, width, height) = match window. restore . take ( ) {
917915 None => {
918916 // we are about to maximize window, so store current size for restore later
919917 window. restore = Some ( window. rect ( ) ) ;
920918
921- let top =
922- compositor. displays [ display_index ] . y + window. title_rect ( ) . height ( ) ;
923- let left = compositor . displays [ display_index ] . x ;
924- let max_height = compositor . displays [ display_index ] . image . height ( )
925- - window. title_rect ( ) . height ( ) ;
926- let max_width = compositor . displays [ display_index ] . image . width ( ) ;
919+ let screen_rect =
920+ compositor. get_screen_rect_for_window ( & window. rect ( ) ) ;
921+ let top = screen_rect . top ( ) + window . title_rect ( ) . height ( ) ;
922+ let left = screen_rect . left ( ) ;
923+ let max_height = screen_rect . height ( ) - window. title_rect ( ) . height ( ) ;
924+ let max_width = screen_rect . width ( ) ;
927925 let half_width = ( max_width / 2 ) as u32 ;
928926 let half_height = ( max_height / 2 ) as u32 ;
929927
@@ -1274,15 +1272,15 @@ impl OrbitalScheme {
12741272 // This logic assumes horizontal and touching, but not overlapping, screens
12751273 let mut max_x = 0 ;
12761274 let mut max_y = 0 ;
1277- for display in self . compositor . displays . iter ( ) {
1275+ for display in self . compositor . displays ( ) {
12781276 let rect = display. screen_rect ( ) ;
12791277 max_x = cmp:: max ( max_x, rect. right ( ) - 1 ) ;
12801278 max_y = cmp:: max ( max_y, rect. bottom ( ) - 1 ) ;
12811279 }
12821280
12831281 let x = cmp:: max ( 0 , cmp:: min ( max_x, self . cursor_x + event. dx ) ) ;
12841282 let mut y = cmp:: max ( 0 , cmp:: min ( max_y, self . cursor_y + event. dy ) ) ;
1285- for display in self . compositor . displays . iter ( ) {
1283+ for display in self . compositor . displays ( ) {
12861284 let rect = display. screen_rect ( ) ;
12871285 if x >= rect. left ( ) && x < rect. right ( ) {
12881286 y = cmp:: max ( rect. top ( ) , cmp:: min ( rect. bottom ( ) - 1 , y) ) ;
@@ -1292,23 +1290,6 @@ impl OrbitalScheme {
12921290 self . mouse_event ( MouseEvent { x, y } ) ;
12931291 }
12941292
1295- // Find the display that a window (`rect`) most overlaps and return the index of it
1296- fn get_display_index ( displays : & [ Display ] , rect : & Rect ) -> usize {
1297- // Find the index of the Display this window has the most overlap with
1298- let mut display_index = 0 ;
1299- let mut max_intersection_area = 0 ;
1300- for ( display_i, display) in displays. iter ( ) . enumerate ( ) {
1301- let intersect = display. screen_rect ( ) . intersection ( rect) ;
1302- let area = intersect. area ( ) ;
1303- if area > max_intersection_area {
1304- display_index = display_i;
1305- max_intersection_area = area;
1306- }
1307- }
1308-
1309- display_index
1310- }
1311-
13121293 fn button_event ( & mut self , event : ButtonEvent ) {
13131294 // Check for focus switch, dragging, and forward mouse events to applications
13141295 match self . dragging {
0 commit comments