floating: Change from getters to pub(super)
Browse files at this commit3e13fc3e705f5a9c14cc993d4841ee1346e883f2Parent: befc3994 changed files +20 -44
- src/layout/floating.rs +5 -5
- src/layout/mod.rs +5 -5
- src/layout/tile.rs +3 -27
- src/layout/workspace.rs +7 -7
src/layout/floating.rsmodified+5 -5
| @@ -375,7 +375,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 375 | 375 | ||
| 376 | // Restore the previous floating window size, and in case the tile is fullscreen, | 376 | // Restore the previous floating window size, and in case the tile is fullscreen, |
| 377 | // unfullscreen it. | 377 | // unfullscreen it. |
| 378 | - let floating_size = tile.floating_window_size(); | 378 | + let floating_size = tile.floating_window_size; |
| 379 | let win = tile.window_mut(); | 379 | let win = tile.window_mut(); |
| 380 | let mut size = if win.is_pending_fullscreen() { | 380 | let mut size = if win.is_pending_fullscreen() { |
| 381 | // If the window was fullscreen without a floating size, ask for (0, 0). | 381 | // If the window was fullscreen without a floating size, ask for (0, 0). |
| @@ -410,7 +410,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | let pos = tile | 412 | let pos = tile |
| 413 | - .floating_pos() | 413 | + .floating_pos |
| 414 | .map(|pos| self.scale_by_working_area(pos)) | 414 | .map(|pos| self.scale_by_working_area(pos)) |
| 415 | .unwrap_or_else(|| { | 415 | .unwrap_or_else(|| { |
| 416 | center_preferring_top_left_in_area(self.working_area, tile.tile_size()) | 416 | center_preferring_top_left_in_area(self.working_area, tile.tile_size()) |
| @@ -434,7 +434,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 434 | let tile_size = tile.tile_size(); | 434 | let tile_size = tile.tile_size(); |
| 435 | let pos = above_pos + (above_size.to_point() - tile_size.to_point()).downscale(2.); | 435 | let pos = above_pos + (above_size.to_point() - tile_size.to_point()).downscale(2.); |
| 436 | let pos = self.clamp_within_working_area(pos, tile_size); | 436 | let pos = self.clamp_within_working_area(pos, tile_size); |
| 437 | - tile.set_floating_pos(self.logical_to_size_frac(pos)); | 437 | + tile.floating_pos = Some(self.logical_to_size_frac(pos)); |
| 438 | 438 | ||
| 439 | self.add_tile_at(idx, tile, activate); | 439 | self.add_tile_at(idx, tile, activate); |
| 440 | } | 440 | } |
| @@ -496,10 +496,10 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 496 | 496 | ||
| 497 | // Store the floating size if we have one. | 497 | // Store the floating size if we have one. |
| 498 | if let Some(size) = tile.window().expected_size() { | 498 | if let Some(size) = tile.window().expected_size() { |
| 499 | - tile.set_floating_window_size(size); | 499 | + tile.floating_window_size = Some(size); |
| 500 | } | 500 | } |
| 501 | // Store the floating position. | 501 | // Store the floating position. |
| 502 | - tile.set_floating_pos(data.pos); | 502 | + tile.floating_pos = Some(data.pos); |
| 503 | 503 | ||
| 504 | let width = ColumnWidth::Fixed(tile.window_size().w); | 504 | let width = ColumnWidth::Fixed(tile.window_size().w); |
| 505 | RemovedTile { | 505 | RemovedTile { |
src/layout/mod.rsmodified+5 -5
| @@ -2694,7 +2694,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2694 | 2694 | ||
| 2695 | // When going to floating, restore the floating window size. | 2695 | // When going to floating, restore the floating window size. |
| 2696 | if move_.is_floating { | 2696 | if move_.is_floating { |
| 2697 | - let floating_size = move_.tile.floating_window_size(); | 2697 | + let floating_size = move_.tile.floating_window_size; |
| 2698 | let win = move_.tile.window_mut(); | 2698 | let win = move_.tile.window_mut(); |
| 2699 | let mut size = | 2699 | let mut size = |
| 2700 | floating_size.unwrap_or_else(|| win.expected_size().unwrap_or_default()); | 2700 | floating_size.unwrap_or_else(|| win.expected_size().unwrap_or_default()); |
| @@ -3265,8 +3265,8 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3265 | ); | 3265 | ); |
| 3266 | 3266 | ||
| 3267 | // Unfullscreen. | 3267 | // Unfullscreen. |
| 3268 | - let floating_size = tile.floating_window_size(); | 3268 | + let floating_size = tile.floating_window_size; |
| 3269 | - let unfullscreen_to_floating = tile.unfullscreen_to_floating(); | 3269 | + let unfullscreen_to_floating = tile.unfullscreen_to_floating; |
| 3270 | let win = tile.window_mut(); | 3270 | let win = tile.window_mut(); |
| 3271 | if win.is_pending_fullscreen() { | 3271 | if win.is_pending_fullscreen() { |
| 3272 | // If we're unfullscreening to floating, use the stored floating size, | 3272 | // If we're unfullscreening to floating, use the stored floating size, |
| @@ -3459,12 +3459,12 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3459 | 3459 | ||
| 3460 | let mut tile = move_.tile; | 3460 | let mut tile = move_.tile; |
| 3461 | let pos = mon.workspaces[ws_idx].floating_logical_to_size_frac(pos); | 3461 | let pos = mon.workspaces[ws_idx].floating_logical_to_size_frac(pos); |
| 3462 | - tile.set_floating_pos(pos); | 3462 | + tile.floating_pos = Some(pos); |
| 3463 | 3463 | ||
| 3464 | // Set the floating size so it takes into account any window resizing that | 3464 | // Set the floating size so it takes into account any window resizing that |
| 3465 | // took place during the move. | 3465 | // took place during the move. |
| 3466 | if let Some(size) = tile.window().expected_size() { | 3466 | if let Some(size) = tile.window().expected_size() { |
| 3467 | - tile.set_floating_window_size(size); | 3467 | + tile.floating_window_size = Some(size); |
| 3468 | } | 3468 | } |
| 3469 | 3469 | ||
| 3470 | mon.add_floating_tile(ws_idx, tile, true); | 3470 | mon.add_floating_tile(ws_idx, tile, true); |
src/layout/tile.rsmodified+3 -27
| @@ -52,20 +52,20 @@ pub struct Tile<W: LayoutElement> { | |||
| 52 | fullscreen_size: Size<f64, Logical>, | 52 | fullscreen_size: Size<f64, Logical>, |
| 53 | 53 | ||
| 54 | /// Whether the tile should float upon unfullscreening. | 54 | /// Whether the tile should float upon unfullscreening. |
| 55 | - unfullscreen_to_floating: bool, | 55 | + pub(super) unfullscreen_to_floating: bool, |
| 56 | 56 | ||
| 57 | /// The size that the window should assume when going floating. | 57 | /// The size that the window should assume when going floating. |
| 58 | /// | 58 | /// |
| 59 | /// This is generally the last size the window had when it was floating. It can be unknown if | 59 | /// This is generally the last size the window had when it was floating. It can be unknown if |
| 60 | /// the window starts out in the tiling layout or fullscreen. | 60 | /// the window starts out in the tiling layout or fullscreen. |
| 61 | - floating_window_size: Option<Size<i32, Logical>>, | 61 | + pub(super) floating_window_size: Option<Size<i32, Logical>>, |
| 62 | 62 | ||
| 63 | /// The position that the tile should assume when going floating, relative to the floating | 63 | /// The position that the tile should assume when going floating, relative to the floating |
| 64 | /// space working area. | 64 | /// space working area. |
| 65 | /// | 65 | /// |
| 66 | /// This is generally the last position the tile had when it was floating. It can be unknown if | 66 | /// This is generally the last position the tile had when it was floating. It can be unknown if |
| 67 | /// the window starts out in the tiling layout. | 67 | /// the window starts out in the tiling layout. |
| 68 | - floating_pos: Option<Point<f64, SizeFrac>>, | 68 | + pub(super) floating_pos: Option<Point<f64, SizeFrac>>, |
| 69 | 69 | ||
| 70 | /// The animation upon opening a window. | 70 | /// The animation upon opening a window. |
| 71 | open_animation: Option<OpenAnimation>, | 71 | open_animation: Option<OpenAnimation>, |
| @@ -938,30 +938,6 @@ impl<W: LayoutElement> Tile<W> { | |||
| 938 | self.unmap_snapshot.take() | 938 | self.unmap_snapshot.take() |
| 939 | } | 939 | } |
| 940 | 940 | ||
| 941 | - pub fn unfullscreen_to_floating(&self) -> bool { | ||
| 942 | - self.unfullscreen_to_floating | ||
| 943 | - } | ||
| 944 | - | ||
| 945 | - pub fn set_unfullscreen_to_floating(&mut self, value: bool) { | ||
| 946 | - self.unfullscreen_to_floating = value; | ||
| 947 | - } | ||
| 948 | - | ||
| 949 | - pub fn floating_window_size(&self) -> Option<Size<i32, Logical>> { | ||
| 950 | - self.floating_window_size | ||
| 951 | - } | ||
| 952 | - | ||
| 953 | - pub fn set_floating_window_size(&mut self, floating_window_size: Size<i32, Logical>) { | ||
| 954 | - self.floating_window_size = Some(floating_window_size); | ||
| 955 | - } | ||
| 956 | - | ||
| 957 | - pub fn floating_pos(&self) -> Option<Point<f64, SizeFrac>> { | ||
| 958 | - self.floating_pos | ||
| 959 | - } | ||
| 960 | - | ||
| 961 | - pub fn set_floating_pos(&mut self, floating_pos: Point<f64, SizeFrac>) { | ||
| 962 | - self.floating_pos = Some(floating_pos); | ||
| 963 | - } | ||
| 964 | - | ||
| 965 | #[cfg(test)] | 941 | #[cfg(test)] |
| 966 | pub fn verify_invariants(&self) { | 942 | pub fn verify_invariants(&self) { |
| 967 | use approx::assert_abs_diff_eq; | 943 | use approx::assert_abs_diff_eq; |
src/layout/workspace.rsmodified+7 -7
| @@ -498,7 +498,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 498 | self.clock.clone(), | 498 | self.clock.clone(), |
| 499 | self.options.clone(), | 499 | self.options.clone(), |
| 500 | ); | 500 | ); |
| 501 | - tile.set_unfullscreen_to_floating(is_floating); | 501 | + tile.unfullscreen_to_floating = is_floating; |
| 502 | 502 | ||
| 503 | // If the tile is pending fullscreen, open it in the scrolling layout where it can go | 503 | // If the tile is pending fullscreen, open it in the scrolling layout where it can go |
| 504 | // fullscreen. | 504 | // fullscreen. |
| @@ -566,7 +566,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 566 | self.clock.clone(), | 566 | self.clock.clone(), |
| 567 | self.options.clone(), | 567 | self.options.clone(), |
| 568 | ); | 568 | ); |
| 569 | - tile.set_unfullscreen_to_floating(is_floating); | 569 | + tile.unfullscreen_to_floating = is_floating; |
| 570 | self.add_tile_right_of(right_of, tile, width, is_full_width, is_floating); | 570 | self.add_tile_right_of(right_of, tile, width, is_full_width, is_floating); |
| 571 | } | 571 | } |
| 572 | 572 | ||
| @@ -601,7 +601,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 601 | + (right_of_tile.tile_size().to_point() - tile_size.to_point()).downscale(2.); | 601 | + (right_of_tile.tile_size().to_point() - tile_size.to_point()).downscale(2.); |
| 602 | let pos = self.floating.clamp_within_working_area(pos, tile_size); | 602 | let pos = self.floating.clamp_within_working_area(pos, tile_size); |
| 603 | let pos = self.floating.logical_to_size_frac(pos); | 603 | let pos = self.floating.logical_to_size_frac(pos); |
| 604 | - tile.set_floating_pos(pos); | 604 | + tile.floating_pos = Some(pos); |
| 605 | 605 | ||
| 606 | self.floating.add_tile(tile, activate); | 606 | self.floating.add_tile(tile, activate); |
| 607 | if activate { | 607 | if activate { |
| @@ -1024,7 +1024,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1024 | .tiles() | 1024 | .tiles() |
| 1025 | .find(|tile| tile.window().id() == window) | 1025 | .find(|tile| tile.window().id() == window) |
| 1026 | .unwrap(); | 1026 | .unwrap(); |
| 1027 | - if tile.window().is_pending_fullscreen() && tile.unfullscreen_to_floating() { | 1027 | + if tile.window().is_pending_fullscreen() && tile.unfullscreen_to_floating { |
| 1028 | // Unfullscreen and float in one call so it has a chance to notice and request a | 1028 | // Unfullscreen and float in one call so it has a chance to notice and request a |
| 1029 | // (0, 0) size, rather than the scrolling column size. | 1029 | // (0, 0) size, rather than the scrolling column size. |
| 1030 | self.toggle_window_floating(Some(window)); | 1030 | self.toggle_window_floating(Some(window)); |
| @@ -1042,7 +1042,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1042 | .find(|tile| tile.window().id() == window) | 1042 | .find(|tile| tile.window().id() == window) |
| 1043 | .unwrap(); | 1043 | .unwrap(); |
| 1044 | 1044 | ||
| 1045 | - tile.set_unfullscreen_to_floating(unfullscreen_to_floating); | 1045 | + tile.unfullscreen_to_floating = unfullscreen_to_floating; |
| 1046 | } | 1046 | } |
| 1047 | } | 1047 | } |
| 1048 | 1048 | ||
| @@ -1086,13 +1086,13 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1086 | removed.tile.stop_move_animations(); | 1086 | removed.tile.stop_move_animations(); |
| 1087 | 1087 | ||
| 1088 | // Come up with a default floating position close to the tile position. | 1088 | // Come up with a default floating position close to the tile position. |
| 1089 | - if removed.tile.floating_pos().is_none() { | 1089 | + if removed.tile.floating_pos.is_none() { |
| 1090 | let pos = self.floating.clamp_within_working_area( | 1090 | let pos = self.floating.clamp_within_working_area( |
| 1091 | render_pos + Point::from((50., 50.)), | 1091 | render_pos + Point::from((50., 50.)), |
| 1092 | removed.tile.tile_size(), | 1092 | removed.tile.tile_size(), |
| 1093 | ); | 1093 | ); |
| 1094 | let pos = self.floating.logical_to_size_frac(pos); | 1094 | let pos = self.floating.logical_to_size_frac(pos); |
| 1095 | - removed.tile.set_floating_pos(pos); | 1095 | + removed.tile.floating_pos = Some(pos); |
| 1096 | } | 1096 | } |
| 1097 | 1097 | ||
| 1098 | self.floating.add_tile(removed.tile, target_is_active); | 1098 | self.floating.add_tile(removed.tile, target_is_active); |