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