floating: Change from getters to pub(super)

These fields are just data storage. They won't have any logic in
getters/setters.
This commit is contained in:
Ivan Molodetskikh
2024-12-25 16:43:15 +03:00
parent befc399506
commit 3e13fc3e70
4 changed files with 20 additions and 44 deletions
+5 -5
View File
@@ -375,7 +375,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
// Restore the previous floating window size, and in case the tile is fullscreen,
// unfullscreen it.
let floating_size = tile.floating_window_size();
let floating_size = tile.floating_window_size;
let win = tile.window_mut();
let mut size = if win.is_pending_fullscreen() {
// If the window was fullscreen without a floating size, ask for (0, 0).
@@ -410,7 +410,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
}
let pos = tile
.floating_pos()
.floating_pos
.map(|pos| self.scale_by_working_area(pos))
.unwrap_or_else(|| {
center_preferring_top_left_in_area(self.working_area, tile.tile_size())
@@ -434,7 +434,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
let tile_size = tile.tile_size();
let pos = above_pos + (above_size.to_point() - tile_size.to_point()).downscale(2.);
let pos = self.clamp_within_working_area(pos, tile_size);
tile.set_floating_pos(self.logical_to_size_frac(pos));
tile.floating_pos = Some(self.logical_to_size_frac(pos));
self.add_tile_at(idx, tile, activate);
}
@@ -496,10 +496,10 @@ impl<W: LayoutElement> FloatingSpace<W> {
// Store the floating size if we have one.
if let Some(size) = tile.window().expected_size() {
tile.set_floating_window_size(size);
tile.floating_window_size = Some(size);
}
// Store the floating position.
tile.set_floating_pos(data.pos);
tile.floating_pos = Some(data.pos);
let width = ColumnWidth::Fixed(tile.window_size().w);
RemovedTile {
+5 -5
View File
@@ -2694,7 +2694,7 @@ impl<W: LayoutElement> Layout<W> {
// When going to floating, restore the floating window size.
if move_.is_floating {
let floating_size = move_.tile.floating_window_size();
let floating_size = move_.tile.floating_window_size;
let win = move_.tile.window_mut();
let mut size =
floating_size.unwrap_or_else(|| win.expected_size().unwrap_or_default());
@@ -3265,8 +3265,8 @@ impl<W: LayoutElement> Layout<W> {
);
// Unfullscreen.
let floating_size = tile.floating_window_size();
let unfullscreen_to_floating = tile.unfullscreen_to_floating();
let floating_size = tile.floating_window_size;
let unfullscreen_to_floating = tile.unfullscreen_to_floating;
let win = tile.window_mut();
if win.is_pending_fullscreen() {
// If we're unfullscreening to floating, use the stored floating size,
@@ -3459,12 +3459,12 @@ impl<W: LayoutElement> Layout<W> {
let mut tile = move_.tile;
let pos = mon.workspaces[ws_idx].floating_logical_to_size_frac(pos);
tile.set_floating_pos(pos);
tile.floating_pos = Some(pos);
// Set the floating size so it takes into account any window resizing that
// took place during the move.
if let Some(size) = tile.window().expected_size() {
tile.set_floating_window_size(size);
tile.floating_window_size = Some(size);
}
mon.add_floating_tile(ws_idx, tile, true);
+3 -27
View File
@@ -52,20 +52,20 @@ pub struct Tile<W: LayoutElement> {
fullscreen_size: Size<f64, Logical>,
/// Whether the tile should float upon unfullscreening.
unfullscreen_to_floating: bool,
pub(super) unfullscreen_to_floating: bool,
/// The size that the window should assume when going floating.
///
/// This is generally the last size the window had when it was floating. It can be unknown if
/// the window starts out in the tiling layout or fullscreen.
floating_window_size: Option<Size<i32, Logical>>,
pub(super) floating_window_size: Option<Size<i32, Logical>>,
/// The position that the tile should assume when going floating, relative to the floating
/// space working area.
///
/// This is generally the last position the tile had when it was floating. It can be unknown if
/// the window starts out in the tiling layout.
floating_pos: Option<Point<f64, SizeFrac>>,
pub(super) floating_pos: Option<Point<f64, SizeFrac>>,
/// The animation upon opening a window.
open_animation: Option<OpenAnimation>,
@@ -938,30 +938,6 @@ impl<W: LayoutElement> Tile<W> {
self.unmap_snapshot.take()
}
pub fn unfullscreen_to_floating(&self) -> bool {
self.unfullscreen_to_floating
}
pub fn set_unfullscreen_to_floating(&mut self, value: bool) {
self.unfullscreen_to_floating = value;
}
pub fn floating_window_size(&self) -> Option<Size<i32, Logical>> {
self.floating_window_size
}
pub fn set_floating_window_size(&mut self, floating_window_size: Size<i32, Logical>) {
self.floating_window_size = Some(floating_window_size);
}
pub fn floating_pos(&self) -> Option<Point<f64, SizeFrac>> {
self.floating_pos
}
pub fn set_floating_pos(&mut self, floating_pos: Point<f64, SizeFrac>) {
self.floating_pos = Some(floating_pos);
}
#[cfg(test)]
pub fn verify_invariants(&self) {
use approx::assert_abs_diff_eq;
+7 -7
View File
@@ -498,7 +498,7 @@ impl<W: LayoutElement> Workspace<W> {
self.clock.clone(),
self.options.clone(),
);
tile.set_unfullscreen_to_floating(is_floating);
tile.unfullscreen_to_floating = is_floating;
// If the tile is pending fullscreen, open it in the scrolling layout where it can go
// fullscreen.
@@ -566,7 +566,7 @@ impl<W: LayoutElement> Workspace<W> {
self.clock.clone(),
self.options.clone(),
);
tile.set_unfullscreen_to_floating(is_floating);
tile.unfullscreen_to_floating = is_floating;
self.add_tile_right_of(right_of, tile, width, is_full_width, is_floating);
}
@@ -601,7 +601,7 @@ impl<W: LayoutElement> Workspace<W> {
+ (right_of_tile.tile_size().to_point() - tile_size.to_point()).downscale(2.);
let pos = self.floating.clamp_within_working_area(pos, tile_size);
let pos = self.floating.logical_to_size_frac(pos);
tile.set_floating_pos(pos);
tile.floating_pos = Some(pos);
self.floating.add_tile(tile, activate);
if activate {
@@ -1024,7 +1024,7 @@ impl<W: LayoutElement> Workspace<W> {
.tiles()
.find(|tile| tile.window().id() == window)
.unwrap();
if tile.window().is_pending_fullscreen() && tile.unfullscreen_to_floating() {
if tile.window().is_pending_fullscreen() && tile.unfullscreen_to_floating {
// Unfullscreen and float in one call so it has a chance to notice and request a
// (0, 0) size, rather than the scrolling column size.
self.toggle_window_floating(Some(window));
@@ -1042,7 +1042,7 @@ impl<W: LayoutElement> Workspace<W> {
.find(|tile| tile.window().id() == window)
.unwrap();
tile.set_unfullscreen_to_floating(unfullscreen_to_floating);
tile.unfullscreen_to_floating = unfullscreen_to_floating;
}
}
@@ -1086,13 +1086,13 @@ impl<W: LayoutElement> Workspace<W> {
removed.tile.stop_move_animations();
// Come up with a default floating position close to the tile position.
if removed.tile.floating_pos().is_none() {
if removed.tile.floating_pos.is_none() {
let pos = self.floating.clamp_within_working_area(
render_pos + Point::from((50., 50.)),
removed.tile.tile_size(),
);
let pos = self.floating.logical_to_size_frac(pos);
removed.tile.set_floating_pos(pos);
removed.tile.floating_pos = Some(pos);
}
self.floating.add_tile(removed.tile, target_is_active);