layout: Pass and store view_size on a Tile
Browse files at this commit28b78a563b3a2275874c8c4ae802be074c8b51b2Parent: 2f380de6 changed files +105 -44
- niri-visual-tests/src/cases/tile.rs +13 -4
- src/layout/floating.rs +27 -14
- src/layout/mod.rs +6 -0
- src/layout/scrolling.rs +4 -3
- src/layout/tile.rs +48 -23
- src/layout/workspace.rs +7 -0
niri-visual-tests/src/cases/tile.rsmodified+13 -4
| @@ -55,6 +55,8 @@ impl Tile { | ||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | pub fn with_window(args: Args, window: TestWindow) -> Self { |
| 58 | + let Args { size, clock } = args; | |
| 59 | + | |
| 58 | 60 | let options = Options { |
| 59 | 61 | focus_ring: niri_config::FocusRing { |
| 60 | 62 | off: true, |
| @@ -69,10 +71,15 @@ impl Tile { | ||
| 69 | 71 | ..Default::default() |
| 70 | 72 | }; |
| 71 | 73 | |
| 72 | - let mut tile = | |
| 73 | - niri::layout::tile::Tile::new(window.clone(), 1., args.clock, Rc::new(options)); | |
| 74 | + let mut tile = niri::layout::tile::Tile::new( | |
| 75 | + window.clone(), | |
| 76 | + size.to_f64(), | |
| 77 | + 1., | |
| 78 | + clock, | |
| 79 | + Rc::new(options), | |
| 80 | + ); | |
| 74 | 81 | |
| 75 | - tile.request_tile_size(args.size.to_f64(), false, None); | |
| 82 | + tile.request_tile_size(size.to_f64(), false, None); | |
| 76 | 83 | window.communicate(); |
| 77 | 84 | |
| 78 | 85 | Self { window, tile } |
| @@ -81,8 +88,10 @@ impl Tile { | ||
| 81 | 88 | |
| 82 | 89 | impl TestCase for Tile { |
| 83 | 90 | fn resize(&mut self, width: i32, height: i32) { |
| 91 | + let size = Size::from((width, height)).to_f64(); | |
| 84 | 92 | self.tile |
| 85 | - .request_tile_size(Size::from((width, height)).to_f64(), false, None); | |
| 93 | + .update_config(size, 1., self.tile.options().clone()); | |
| 94 | + self.tile.request_tile_size(size, false, None); | |
| 86 | 95 | self.window.communicate(); |
| 87 | 96 | } |
| 88 | 97 |
src/layout/floating.rsmodified+27 -14
| @@ -50,6 +50,9 @@ pub struct FloatingSpace<W: LayoutElement> { | ||
| 50 | 50 | /// Windows in the closing animation. |
| 51 | 51 | closing_windows: Vec<ClosingWindow>, |
| 52 | 52 | |
| 53 | + /// View size for this space. | |
| 54 | + view_size: Size<f64, Logical>, | |
| 55 | + | |
| 53 | 56 | /// Working area for this space. |
| 54 | 57 | working_area: Rectangle<f64, Logical>, |
| 55 | 58 | |
| @@ -193,6 +196,7 @@ impl Data { | ||
| 193 | 196 | |
| 194 | 197 | impl<W: LayoutElement> FloatingSpace<W> { |
| 195 | 198 | pub fn new( |
| 199 | + view_size: Size<f64, Logical>, | |
| 196 | 200 | working_area: Rectangle<f64, Logical>, |
| 197 | 201 | scale: f64, |
| 198 | 202 | clock: Clock, |
| @@ -204,6 +208,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 204 | 208 | active_window_id: None, |
| 205 | 209 | interactive_resize: None, |
| 206 | 210 | closing_windows: Vec::new(), |
| 211 | + view_size, | |
| 207 | 212 | working_area, |
| 208 | 213 | scale, |
| 209 | 214 | clock, |
| @@ -213,16 +218,18 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 213 | 218 | |
| 214 | 219 | pub fn update_config( |
| 215 | 220 | &mut self, |
| 221 | + view_size: Size<f64, Logical>, | |
| 216 | 222 | working_area: Rectangle<f64, Logical>, |
| 217 | 223 | scale: f64, |
| 218 | 224 | options: Rc<Options>, |
| 219 | 225 | ) { |
| 220 | 226 | for (tile, data) in zip(&mut self.tiles, &mut self.data) { |
| 221 | - tile.update_config(scale, options.clone()); | |
| 227 | + tile.update_config(view_size, scale, options.clone()); | |
| 222 | 228 | data.update(tile); |
| 223 | 229 | data.update_config(working_area); |
| 224 | 230 | } |
| 225 | 231 | |
| 232 | + self.view_size = view_size; | |
| 226 | 233 | self.working_area = working_area; |
| 227 | 234 | self.scale = scale; |
| 228 | 235 | self.options = options; |
| @@ -371,7 +378,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 371 | 378 | } |
| 372 | 379 | |
| 373 | 380 | fn add_tile_at(&mut self, mut idx: usize, mut tile: Tile<W>, activate: bool) { |
| 374 | - tile.update_config(self.scale, self.options.clone()); | |
| 381 | + tile.update_config(self.view_size, self.scale, self.options.clone()); | |
| 375 | 382 | |
| 376 | 383 | // Restore the previous floating window size, and in case the tile is fullscreen, |
| 377 | 384 | // unfullscreen it. |
| @@ -602,7 +609,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 602 | 609 | }; |
| 603 | 610 | let idx = self.idx_of(&id).unwrap(); |
| 604 | 611 | |
| 605 | - let view_size = self.working_area.size.w; | |
| 612 | + let available_size = self.working_area.size.w; | |
| 606 | 613 | |
| 607 | 614 | let tile = &mut self.tiles[idx]; |
| 608 | 615 | let preset_idx = if let Some(idx) = tile.floating_preset_width_idx { |
| @@ -615,7 +622,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 615 | 622 | .preset_column_widths |
| 616 | 623 | .iter() |
| 617 | 624 | .position(|preset| { |
| 618 | - let resolved = preset.resolve_no_gaps(&self.options, view_size); | |
| 625 | + let resolved = preset.resolve_no_gaps(&self.options, available_size); | |
| 619 | 626 | match resolved { |
| 620 | 627 | // Some allowance for fractional scaling purposes. |
| 621 | 628 | ResolvedSize::Tile(resolved) => current_tile + 1. < resolved, |
| @@ -643,7 +650,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 643 | 650 | }; |
| 644 | 651 | let idx = self.idx_of(&id).unwrap(); |
| 645 | 652 | |
| 646 | - let view_size = self.working_area.size.h; | |
| 653 | + let available_size = self.working_area.size.h; | |
| 647 | 654 | |
| 648 | 655 | let tile = &mut self.tiles[idx]; |
| 649 | 656 | let preset_idx = if let Some(idx) = tile.floating_preset_height_idx { |
| @@ -656,7 +663,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 656 | 663 | .preset_window_heights |
| 657 | 664 | .iter() |
| 658 | 665 | .position(|preset| { |
| 659 | - let resolved = resolve_preset_size(*preset, view_size); | |
| 666 | + let resolved = resolve_preset_size(*preset, available_size); | |
| 660 | 667 | match resolved { |
| 661 | 668 | // Some allowance for fractional scaling purposes. |
| 662 | 669 | ResolvedSize::Tile(resolved) => current_tile + 1. < resolved, |
| @@ -687,7 +694,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 687 | 694 | let tile = &mut self.tiles[idx]; |
| 688 | 695 | tile.floating_preset_width_idx = None; |
| 689 | 696 | |
| 690 | - let view_size = self.working_area.size.w; | |
| 697 | + let available_size = self.working_area.size.w; | |
| 691 | 698 | let win = tile.window(); |
| 692 | 699 | let current_window = win.expected_size().unwrap_or_else(|| win.size()).w; |
| 693 | 700 | let current_tile = tile.tile_expected_or_current_size().w; |
| @@ -699,14 +706,14 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 699 | 706 | SizeChange::SetFixed(win_width) => f64::from(win_width), |
| 700 | 707 | SizeChange::SetProportion(prop) => { |
| 701 | 708 | let prop = (prop / 100.).clamp(0., MAX_F); |
| 702 | - let tile_width = view_size * prop; | |
| 709 | + let tile_width = available_size * prop; | |
| 703 | 710 | tile.window_width_for_tile_width(tile_width) |
| 704 | 711 | } |
| 705 | 712 | SizeChange::AdjustFixed(delta) => f64::from(current_window.saturating_add(delta)), |
| 706 | 713 | SizeChange::AdjustProportion(delta) => { |
| 707 | - let current_prop = current_tile / view_size; | |
| 714 | + let current_prop = current_tile / available_size; | |
| 708 | 715 | let prop = (current_prop + delta / 100.).clamp(0., MAX_F); |
| 709 | - let tile_width = view_size * prop; | |
| 716 | + let tile_width = available_size * prop; | |
| 710 | 717 | tile.window_width_for_tile_width(tile_width) |
| 711 | 718 | } |
| 712 | 719 | }; |
| @@ -734,7 +741,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 734 | 741 | let tile = &mut self.tiles[idx]; |
| 735 | 742 | tile.floating_preset_width_idx = None; |
| 736 | 743 | |
| 737 | - let view_size = self.working_area.size.h; | |
| 744 | + let available_size = self.working_area.size.h; | |
| 738 | 745 | let win = tile.window(); |
| 739 | 746 | let current_window = win.expected_size().unwrap_or_else(|| win.size()).h; |
| 740 | 747 | let current_tile = tile.tile_expected_or_current_size().h; |
| @@ -746,14 +753,14 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 746 | 753 | SizeChange::SetFixed(win_height) => f64::from(win_height), |
| 747 | 754 | SizeChange::SetProportion(prop) => { |
| 748 | 755 | let prop = (prop / 100.).clamp(0., MAX_F); |
| 749 | - let tile_height = view_size * prop; | |
| 756 | + let tile_height = available_size * prop; | |
| 750 | 757 | tile.window_height_for_tile_height(tile_height) |
| 751 | 758 | } |
| 752 | 759 | SizeChange::AdjustFixed(delta) => f64::from(current_window.saturating_add(delta)), |
| 753 | 760 | SizeChange::AdjustProportion(delta) => { |
| 754 | - let current_prop = current_tile / view_size; | |
| 761 | + let current_prop = current_tile / available_size; | |
| 755 | 762 | let prop = (current_prop + delta / 100.).clamp(0., MAX_F); |
| 756 | - let tile_height = view_size * prop; | |
| 763 | + let tile_height = available_size * prop; | |
| 757 | 764 | tile.window_height_for_tile_height(tile_height) |
| 758 | 765 | } |
| 759 | 766 | }; |
| @@ -1095,6 +1102,11 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 1095 | 1102 | } |
| 1096 | 1103 | } |
| 1097 | 1104 | |
| 1105 | + #[cfg(test)] | |
| 1106 | + pub fn view_size(&self) -> Size<f64, Logical> { | |
| 1107 | + self.view_size | |
| 1108 | + } | |
| 1109 | + | |
| 1098 | 1110 | #[cfg(test)] |
| 1099 | 1111 | pub fn working_area(&self) -> Rectangle<f64, Logical> { |
| 1100 | 1112 | self.working_area |
| @@ -1123,6 +1135,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | ||
| 1123 | 1135 | |
| 1124 | 1136 | for (i, (tile, data)) in zip(&self.tiles, &self.data).enumerate() { |
| 1125 | 1137 | assert!(Rc::ptr_eq(&self.options, &tile.options)); |
| 1138 | + assert_eq!(self.view_size, tile.view_size()); | |
| 1126 | 1139 | assert_eq!(self.clock, tile.clock); |
| 1127 | 1140 | assert_eq!(self.scale, tile.scale()); |
| 1128 | 1141 | tile.verify_invariants(); |
src/layout/mod.rsmodified+6 -0
| @@ -2577,8 +2577,10 @@ impl<W: LayoutElement> Layout<W> { | ||
| 2577 | 2577 | let options = Rc::new(options); |
| 2578 | 2578 | |
| 2579 | 2579 | if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move { |
| 2580 | + let view_size = output_size(&move_.output); | |
| 2580 | 2581 | let scale = move_.output.current_scale().fractional_scale(); |
| 2581 | 2582 | move_.tile.update_config( |
| 2583 | + view_size, | |
| 2582 | 2584 | scale, |
| 2583 | 2585 | Rc::new(Options::clone(&options).adjusted_for_scale(scale)), |
| 2584 | 2586 | ); |
| @@ -3261,8 +3263,10 @@ impl<W: LayoutElement> Layout<W> { | ||
| 3261 | 3263 | output.current_transform(), |
| 3262 | 3264 | ); |
| 3263 | 3265 | |
| 3266 | + let view_size = output_size(&output); | |
| 3264 | 3267 | let scale = output.current_scale().fractional_scale(); |
| 3265 | 3268 | tile.update_config( |
| 3269 | + view_size, | |
| 3266 | 3270 | scale, |
| 3267 | 3271 | Rc::new(Options::clone(&self.options).adjusted_for_scale(scale)), |
| 3268 | 3272 | ); |
| @@ -3324,8 +3328,10 @@ impl<W: LayoutElement> Layout<W> { | ||
| 3324 | 3328 | output.current_scale(), |
| 3325 | 3329 | output.current_transform(), |
| 3326 | 3330 | ); |
| 3331 | + let view_size = output_size(&output); | |
| 3327 | 3332 | let scale = output.current_scale().fractional_scale(); |
| 3328 | 3333 | move_.tile.update_config( |
| 3334 | + view_size, | |
| 3329 | 3335 | scale, |
| 3330 | 3336 | Rc::new(Options::clone(&self.options).adjusted_for_scale(scale)), |
| 3331 | 3337 | ); |
src/layout/scrolling.rsmodified+4 -3
| @@ -2933,7 +2933,7 @@ impl<W: LayoutElement> Column<W> { | ||
| 2933 | 2933 | } |
| 2934 | 2934 | |
| 2935 | 2935 | for (tile, data) in zip(&mut self.tiles, &mut self.data) { |
| 2936 | - tile.update_config(scale, options.clone()); | |
| 2936 | + tile.update_config(view_size, scale, options.clone()); | |
| 2937 | 2937 | data.update(tile); |
| 2938 | 2938 | } |
| 2939 | 2939 | |
| @@ -3033,7 +3033,7 @@ impl<W: LayoutElement> Column<W> { | ||
| 3033 | 3033 | } |
| 3034 | 3034 | |
| 3035 | 3035 | fn add_tile_at(&mut self, idx: usize, mut tile: Tile<W>, animate: bool) { |
| 3036 | - tile.update_config(self.scale, self.options.clone()); | |
| 3036 | + tile.update_config(self.view_size, self.scale, self.options.clone()); | |
| 3037 | 3037 | |
| 3038 | 3038 | // Inserting a tile pushes down all tiles below it, but also in always-centering mode it |
| 3039 | 3039 | // will affect the X position of all tiles in the column. |
| @@ -3096,7 +3096,7 @@ impl<W: LayoutElement> Column<W> { | ||
| 3096 | 3096 | |
| 3097 | 3097 | fn update_tile_sizes_with_transaction(&mut self, animate: bool, transaction: Transaction) { |
| 3098 | 3098 | if self.is_fullscreen { |
| 3099 | - self.tiles[0].request_fullscreen(self.view_size); | |
| 3099 | + self.tiles[0].request_fullscreen(); | |
| 3100 | 3100 | return; |
| 3101 | 3101 | } |
| 3102 | 3102 | |
| @@ -3787,6 +3787,7 @@ impl<W: LayoutElement> Column<W> { | ||
| 3787 | 3787 | assert_eq!(self.clock, tile.clock); |
| 3788 | 3788 | assert_eq!(self.scale, tile.scale()); |
| 3789 | 3789 | assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen()); |
| 3790 | + assert_eq!(self.view_size, tile.view_size()); | |
| 3790 | 3791 | tile.verify_invariants(); |
| 3791 | 3792 | |
| 3792 | 3793 | let mut data2 = *data; |
src/layout/tile.rsmodified+48 -23
| @@ -48,9 +48,6 @@ pub struct Tile<W: LayoutElement> { | ||
| 48 | 48 | /// The black backdrop for fullscreen windows. |
| 49 | 49 | fullscreen_backdrop: SolidColorBuffer, |
| 50 | 50 | |
| 51 | - /// The size we were requested to fullscreen into. | |
| 52 | - fullscreen_size: Size<f64, Logical>, | |
| 53 | - | |
| 54 | 51 | /// Whether the tile should float upon unfullscreening. |
| 55 | 52 | pub(super) unfullscreen_to_floating: bool, |
| 56 | 53 | |
| @@ -94,6 +91,11 @@ pub struct Tile<W: LayoutElement> { | ||
| 94 | 91 | /// Extra damage for clipped surface corner radius changes. |
| 95 | 92 | rounded_corner_damage: RoundedCornerDamage, |
| 96 | 93 | |
| 94 | + /// The view size for the tile's workspace. | |
| 95 | + /// | |
| 96 | + /// Used as the fullscreen target size. | |
| 97 | + view_size: Size<f64, Logical>, | |
| 98 | + | |
| 97 | 99 | /// Scale of the output the tile is on (and rounds its sizes to). |
| 98 | 100 | scale: f64, |
| 99 | 101 | |
| @@ -134,18 +136,24 @@ struct MoveAnimation { | ||
| 134 | 136 | } |
| 135 | 137 | |
| 136 | 138 | impl<W: LayoutElement> Tile<W> { |
| 137 | - pub fn new(window: W, scale: f64, clock: Clock, options: Rc<Options>) -> Self { | |
| 139 | + pub fn new( | |
| 140 | + window: W, | |
| 141 | + view_size: Size<f64, Logical>, | |
| 142 | + scale: f64, | |
| 143 | + clock: Clock, | |
| 144 | + options: Rc<Options>, | |
| 145 | + ) -> Self { | |
| 138 | 146 | let rules = window.rules(); |
| 139 | 147 | let border_config = rules.border.resolve_against(options.border); |
| 140 | 148 | let focus_ring_config = rules.focus_ring.resolve_against(options.focus_ring.into()); |
| 149 | + let is_fullscreen = window.is_fullscreen(); | |
| 141 | 150 | |
| 142 | 151 | Self { |
| 143 | 152 | window, |
| 144 | 153 | border: FocusRing::new(border_config.into()), |
| 145 | 154 | focus_ring: FocusRing::new(focus_ring_config.into()), |
| 146 | - is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size. | |
| 147 | - fullscreen_backdrop: SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.]), | |
| 148 | - fullscreen_size: Default::default(), | |
| 155 | + is_fullscreen, | |
| 156 | + fullscreen_backdrop: SolidColorBuffer::new(view_size, [0., 0., 0., 1.]), | |
| 149 | 157 | unfullscreen_to_floating: false, |
| 150 | 158 | floating_window_size: None, |
| 151 | 159 | floating_pos: None, |
| @@ -158,13 +166,19 @@ impl<W: LayoutElement> Tile<W> { | ||
| 158 | 166 | interactive_move_offset: Point::from((0., 0.)), |
| 159 | 167 | unmap_snapshot: None, |
| 160 | 168 | rounded_corner_damage: Default::default(), |
| 169 | + view_size, | |
| 161 | 170 | scale, |
| 162 | 171 | clock, |
| 163 | 172 | options, |
| 164 | 173 | } |
| 165 | 174 | } |
| 166 | 175 | |
| 167 | - pub fn update_config(&mut self, scale: f64, options: Rc<Options>) { | |
| 176 | + pub fn update_config( | |
| 177 | + &mut self, | |
| 178 | + view_size: Size<f64, Logical>, | |
| 179 | + scale: f64, | |
| 180 | + options: Rc<Options>, | |
| 181 | + ) { | |
| 168 | 182 | // If preset widths or heights changed, clear our stored preset index. |
| 169 | 183 | if self.options.preset_column_widths != options.preset_column_widths { |
| 170 | 184 | self.floating_preset_width_idx = None; |
| @@ -173,6 +187,7 @@ impl<W: LayoutElement> Tile<W> { | ||
| 173 | 187 | self.floating_preset_height_idx = None; |
| 174 | 188 | } |
| 175 | 189 | |
| 190 | + self.view_size = view_size; | |
| 176 | 191 | self.scale = scale; |
| 177 | 192 | self.options = options; |
| 178 | 193 | |
| @@ -185,6 +200,8 @@ impl<W: LayoutElement> Tile<W> { | ||
| 185 | 200 | .focus_ring |
| 186 | 201 | .resolve_against(self.options.focus_ring.into()); |
| 187 | 202 | self.focus_ring.update_config(focus_ring_config.into()); |
| 203 | + | |
| 204 | + self.fullscreen_backdrop.resize(view_size); | |
| 188 | 205 | } |
| 189 | 206 | |
| 190 | 207 | pub fn update_shaders(&mut self) { |
| @@ -193,10 +210,7 @@ impl<W: LayoutElement> Tile<W> { | ||
| 193 | 210 | } |
| 194 | 211 | |
| 195 | 212 | pub fn update_window(&mut self) { |
| 196 | - // FIXME: remove when we can get a fullscreen size right away. | |
| 197 | - if self.fullscreen_size != Size::from((0., 0.)) { | |
| 198 | - self.is_fullscreen = self.window.is_fullscreen(); | |
| 199 | - } | |
| 213 | + self.is_fullscreen = self.window.is_fullscreen(); | |
| 200 | 214 | |
| 201 | 215 | if let Some(animate_from) = self.window.take_animation_snapshot() { |
| 202 | 216 | let size_from = if let Some(resize) = self.resize_animation.take() { |
| @@ -448,7 +462,7 @@ impl<W: LayoutElement> Tile<W> { | ||
| 448 | 462 | // In fullscreen, center the window in the given size. |
| 449 | 463 | if self.is_fullscreen { |
| 450 | 464 | let window_size = self.window_size(); |
| 451 | - let target_size = self.fullscreen_size; | |
| 465 | + let target_size = self.view_size; | |
| 452 | 466 | |
| 453 | 467 | // Windows aren't supposed to be larger than the fullscreen size, but in case we get |
| 454 | 468 | // one, leave it at the top-left as usual. |
| @@ -478,8 +492,8 @@ impl<W: LayoutElement> Tile<W> { | ||
| 478 | 492 | if self.is_fullscreen { |
| 479 | 493 | // Normally we'd just return the fullscreen size here, but this makes things a bit |
| 480 | 494 | // nicer if a fullscreen window is bigger than the fullscreen size for some reason. |
| 481 | - size.w = f64::max(size.w, self.fullscreen_size.w); | |
| 482 | - size.h = f64::max(size.h, self.fullscreen_size.h); | |
| 495 | + size.w = f64::max(size.w, self.view_size.w); | |
| 496 | + size.h = f64::max(size.h, self.view_size.h); | |
| 483 | 497 | return size; |
| 484 | 498 | } |
| 485 | 499 | |
| @@ -497,8 +511,8 @@ impl<W: LayoutElement> Tile<W> { | ||
| 497 | 511 | if self.is_fullscreen { |
| 498 | 512 | // Normally we'd just return the fullscreen size here, but this makes things a bit |
| 499 | 513 | // nicer if a fullscreen window is bigger than the fullscreen size for some reason. |
| 500 | - size.w = f64::max(size.w, self.fullscreen_size.w); | |
| 501 | - size.h = f64::max(size.h, self.fullscreen_size.h); | |
| 514 | + size.w = f64::max(size.w, self.view_size.w); | |
| 515 | + size.h = f64::max(size.h, self.view_size.h); | |
| 502 | 516 | return size; |
| 503 | 517 | } |
| 504 | 518 | |
| @@ -550,8 +564,8 @@ impl<W: LayoutElement> Tile<W> { | ||
| 550 | 564 | if self.is_fullscreen { |
| 551 | 565 | // Normally we'd just return the fullscreen size here, but this makes things a bit |
| 552 | 566 | // nicer if a fullscreen window is bigger than the fullscreen size for some reason. |
| 553 | - size.w = f64::max(size.w, self.fullscreen_size.w); | |
| 554 | - size.h = f64::max(size.h, self.fullscreen_size.h); | |
| 567 | + size.w = f64::max(size.w, self.view_size.w); | |
| 568 | + size.h = f64::max(size.h, self.view_size.h); | |
| 555 | 569 | return size; |
| 556 | 570 | } |
| 557 | 571 | |
| @@ -632,10 +646,9 @@ impl<W: LayoutElement> Tile<W> { | ||
| 632 | 646 | } |
| 633 | 647 | } |
| 634 | 648 | |
| 635 | - pub fn request_fullscreen(&mut self, size: Size<f64, Logical>) { | |
| 636 | - self.fullscreen_backdrop.resize(size); | |
| 637 | - self.fullscreen_size = size; | |
| 638 | - self.window.request_fullscreen(size.to_i32_round()); | |
| 649 | + pub fn request_fullscreen(&mut self) { | |
| 650 | + self.window | |
| 651 | + .request_fullscreen(self.view_size.to_i32_round()); | |
| 639 | 652 | } |
| 640 | 653 | |
| 641 | 654 | pub fn min_size(&self) -> Size<f64, Logical> { |
| @@ -982,10 +995,22 @@ impl<W: LayoutElement> Tile<W> { | ||
| 982 | 995 | self.unmap_snapshot.take() |
| 983 | 996 | } |
| 984 | 997 | |
| 998 | + pub fn options(&self) -> &Rc<Options> { | |
| 999 | + &self.options | |
| 1000 | + } | |
| 1001 | + | |
| 1002 | + #[cfg(test)] | |
| 1003 | + pub fn view_size(&self) -> Size<f64, Logical> { | |
| 1004 | + self.view_size | |
| 1005 | + } | |
| 1006 | + | |
| 985 | 1007 | #[cfg(test)] |
| 986 | 1008 | pub fn verify_invariants(&self) { |
| 987 | 1009 | use approx::assert_abs_diff_eq; |
| 988 | 1010 | |
| 1011 | + assert_eq!(self.is_fullscreen, self.window.is_fullscreen()); | |
| 1012 | + assert_eq!(self.fullscreen_backdrop.size(), self.view_size); | |
| 1013 | + | |
| 989 | 1014 | let scale = self.scale; |
| 990 | 1015 | let size = self.tile_size(); |
| 991 | 1016 | let rounded = size.to_physical_precise_round(scale).to_logical(scale); |
src/layout/workspace.rsmodified+7 -0
| @@ -203,6 +203,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 203 | 203 | ); |
| 204 | 204 | |
| 205 | 205 | let floating = FloatingSpace::new( |
| 206 | + view_size, | |
| 206 | 207 | working_area, |
| 207 | 208 | scale.fractional_scale(), |
| 208 | 209 | clock.clone(), |
| @@ -255,6 +256,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 255 | 256 | ); |
| 256 | 257 | |
| 257 | 258 | let floating = FloatingSpace::new( |
| 259 | + view_size, | |
| 258 | 260 | working_area, |
| 259 | 261 | scale.fractional_scale(), |
| 260 | 262 | clock.clone(), |
| @@ -337,6 +339,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 337 | 339 | ); |
| 338 | 340 | |
| 339 | 341 | self.floating.update_config( |
| 342 | + self.view_size, | |
| 340 | 343 | self.working_area, |
| 341 | 344 | self.scale.fractional_scale(), |
| 342 | 345 | options.clone(), |
| @@ -467,6 +470,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 467 | 470 | self.options.clone(), |
| 468 | 471 | ); |
| 469 | 472 | self.floating.update_config( |
| 473 | + size, | |
| 470 | 474 | working_area, |
| 471 | 475 | scale.fractional_scale(), |
| 472 | 476 | self.options.clone(), |
| @@ -494,6 +498,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 494 | 498 | ) { |
| 495 | 499 | let mut tile = Tile::new( |
| 496 | 500 | window, |
| 501 | + self.view_size, | |
| 497 | 502 | self.scale.fractional_scale(), |
| 498 | 503 | self.clock.clone(), |
| 499 | 504 | self.options.clone(), |
| @@ -562,6 +567,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 562 | 567 | ) { |
| 563 | 568 | let mut tile = Tile::new( |
| 564 | 569 | window, |
| 570 | + self.view_size, | |
| 565 | 571 | self.scale.fractional_scale(), |
| 566 | 572 | self.clock.clone(), |
| 567 | 573 | self.options.clone(), |
| @@ -1471,6 +1477,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 1471 | 1477 | assert!(Rc::ptr_eq(&self.options, self.scrolling.options())); |
| 1472 | 1478 | self.scrolling.verify_invariants(self.working_area); |
| 1473 | 1479 | |
| 1480 | + assert_eq!(self.view_size, self.floating.view_size()); | |
| 1474 | 1481 | assert_eq!(self.working_area, self.floating.working_area()); |
| 1475 | 1482 | assert_eq!(&self.clock, self.floating.clock()); |
| 1476 | 1483 | assert!(Rc::ptr_eq(&self.options, self.floating.options())); |