forge
Explore
Log in

Don't you dare go Hollow

Rename window -> tile, fix popup unconstraining window_y

Browse files at this commit

777ad4ee5c8cf84b2bfa13c6bdb0d254c24881f9Ivan MolodetskikhParent: c21805b
I missed the window_y thing and found it thanks to the rename. Too lazy
to split it into a commit.
src/layout/mod.rsmodified+3 -3
@@ -141,7 +141,7 @@ pub struct Options {
141 border: config::FocusRing,141 border: config::FocusRing,
142 /// Column widths that `toggle_width()` switches between.142 /// Column widths that `toggle_width()` switches between.
143 preset_widths: Vec<ColumnWidth>,143 preset_widths: Vec<ColumnWidth>,
144- /// Initial width for new windows.144+ /// Initial width for new columns.
145 default_width: Option<ColumnWidth>,145 default_width: Option<ColumnWidth>,
146 }146 }
147 147
@@ -717,7 +717,7 @@ impl<W: LayoutElement> Layout<W> {
717 }717 }
718 718
719 let col = &ws.columns[ws.active_column_idx];719 let col = &ws.columns[ws.active_column_idx];
720- Some((&col.windows[col.active_window_idx].window(), &mon.output))720+ Some((&col.tiles[col.active_tile_idx].window(), &mon.output))
721 }721 }
722 722
723 pub fn windows_for_output(&self, output: &Output) -> impl Iterator<Item = &W> + '_ {723 pub fn windows_for_output(&self, output: &Output) -> impl Iterator<Item = &W> + '_ {
@@ -1138,7 +1138,7 @@ impl<W: LayoutElement> Layout<W> {
1138 let column = &ws.columns[ws.active_column_idx];1138 let column = &ws.columns[ws.active_column_idx];
1139 let width = column.width;1139 let width = column.width;
1140 let is_full_width = column.is_full_width;1140 let is_full_width = column.is_full_width;
1141- let window = ws.remove_window_by_idx(ws.active_column_idx, column.active_window_idx);1141+ let window = ws.remove_window_by_idx(ws.active_column_idx, column.active_tile_idx);
1142 1142
1143 let workspace_idx = monitors[new_idx].active_workspace_idx;1143 let workspace_idx = monitors[new_idx].active_workspace_idx;
1144 self.add_window_by_idx(new_idx, workspace_idx, window, true, width, is_full_width);1144 self.add_window_by_idx(new_idx, workspace_idx, window, true, width, is_full_width);
src/layout/monitor.rsmodified+10 -10
@@ -166,8 +166,8 @@ impl<W: LayoutElement> Monitor<W> {
166 return;166 return;
167 }167 }
168 let column = &mut workspace.columns[workspace.active_column_idx];168 let column = &mut workspace.columns[workspace.active_column_idx];
169- let curr_idx = column.active_window_idx;169+ let curr_idx = column.active_tile_idx;
170- let new_idx = min(column.active_window_idx + 1, column.windows.len() - 1);170+ let new_idx = min(column.active_tile_idx + 1, column.tiles.len() - 1);
171 if curr_idx == new_idx {171 if curr_idx == new_idx {
172 self.move_to_workspace_down();172 self.move_to_workspace_down();
173 } else {173 } else {
@@ -180,7 +180,7 @@ impl<W: LayoutElement> Monitor<W> {
180 if workspace.columns.is_empty() {180 if workspace.columns.is_empty() {
181 return;181 return;
182 }182 }
183- let curr_idx = workspace.columns[workspace.active_column_idx].active_window_idx;183+ let curr_idx = workspace.columns[workspace.active_column_idx].active_tile_idx;
184 let new_idx = curr_idx.saturating_sub(1);184 let new_idx = curr_idx.saturating_sub(1);
185 if curr_idx == new_idx {185 if curr_idx == new_idx {
186 self.move_to_workspace_up();186 self.move_to_workspace_up();
@@ -211,8 +211,8 @@ impl<W: LayoutElement> Monitor<W> {
211 self.switch_workspace_down();211 self.switch_workspace_down();
212 } else {212 } else {
213 let column = &workspace.columns[workspace.active_column_idx];213 let column = &workspace.columns[workspace.active_column_idx];
214- let curr_idx = column.active_window_idx;214+ let curr_idx = column.active_tile_idx;
215- let new_idx = min(column.active_window_idx + 1, column.windows.len() - 1);215+ let new_idx = min(column.active_tile_idx + 1, column.tiles.len() - 1);
216 if curr_idx == new_idx {216 if curr_idx == new_idx {
217 self.switch_workspace_down();217 self.switch_workspace_down();
218 } else {218 } else {
@@ -226,7 +226,7 @@ impl<W: LayoutElement> Monitor<W> {
226 if workspace.columns.is_empty() {226 if workspace.columns.is_empty() {
227 self.switch_workspace_up();227 self.switch_workspace_up();
228 } else {228 } else {
229- let curr_idx = workspace.columns[workspace.active_column_idx].active_window_idx;229+ let curr_idx = workspace.columns[workspace.active_column_idx].active_tile_idx;
230 let new_idx = curr_idx.saturating_sub(1);230 let new_idx = curr_idx.saturating_sub(1);
231 if curr_idx == new_idx {231 if curr_idx == new_idx {
232 self.switch_workspace_up();232 self.switch_workspace_up();
@@ -253,7 +253,7 @@ impl<W: LayoutElement> Monitor<W> {
253 let width = column.width;253 let width = column.width;
254 let is_full_width = column.is_full_width;254 let is_full_width = column.is_full_width;
255 let window =255 let window =
256- workspace.remove_window_by_idx(workspace.active_column_idx, column.active_window_idx);256+ workspace.remove_window_by_idx(workspace.active_column_idx, column.active_tile_idx);
257 257
258 self.add_window(new_idx, window, true, width, is_full_width);258 self.add_window(new_idx, window, true, width, is_full_width);
259 }259 }
@@ -275,7 +275,7 @@ impl<W: LayoutElement> Monitor<W> {
275 let width = column.width;275 let width = column.width;
276 let is_full_width = column.is_full_width;276 let is_full_width = column.is_full_width;
277 let window =277 let window =
278- workspace.remove_window_by_idx(workspace.active_column_idx, column.active_window_idx);278+ workspace.remove_window_by_idx(workspace.active_column_idx, column.active_tile_idx);
279 279
280 self.add_window(new_idx, window, true, width, is_full_width);280 self.add_window(new_idx, window, true, width, is_full_width);
281 }281 }
@@ -297,7 +297,7 @@ impl<W: LayoutElement> Monitor<W> {
297 let width = column.width;297 let width = column.width;
298 let is_full_width = column.is_full_width;298 let is_full_width = column.is_full_width;
299 let window =299 let window =
300- workspace.remove_window_by_idx(workspace.active_column_idx, column.active_window_idx);300+ workspace.remove_window_by_idx(workspace.active_column_idx, column.active_tile_idx);
301 301
302 self.add_window(new_idx, window, true, width, is_full_width);302 self.add_window(new_idx, window, true, width, is_full_width);
303 303
@@ -345,7 +345,7 @@ impl<W: LayoutElement> Monitor<W> {
345 }345 }
346 346
347 let column = &workspace.columns[workspace.active_column_idx];347 let column = &workspace.columns[workspace.active_column_idx];
348- Some(column.windows[column.active_window_idx].window())348+ Some(column.tiles[column.active_tile_idx].window())
349 }349 }
350 350
351 pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {351 pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {
src/layout/tile.rsmodified+1 -1
@@ -91,7 +91,7 @@ impl<W: LayoutElement> Tile<W> {
91 }91 }
92 92
93 /// Returns the location of the window's visual geometry within this Tile.93 /// Returns the location of the window's visual geometry within this Tile.
94- fn window_loc(&self) -> Point<i32, Logical> {94+ pub fn window_loc(&self) -> Point<i32, Logical> {
95 let mut loc = Point::from((0, 0));95 let mut loc = Point::from((0, 0));
96 96
97 // In fullscreen, center the window in the given size.97 // In fullscreen, center the window in the given size.
src/layout/workspace.rsmodified+120 -118
@@ -127,17 +127,17 @@ pub struct Column<W: LayoutElement> {
127 /// Tiles in this column.127 /// Tiles in this column.
128 ///128 ///
129 /// Must be non-empty.129 /// Must be non-empty.
130- pub windows: Vec<Tile<W>>,130+ pub tiles: Vec<Tile<W>>,
131 131
132 /// Heights of the windows.132 /// Heights of the windows.
133 ///133 ///
134- /// Must have the same number of elements as `windows`.134+ /// Must have the same number of elements as `tiles`.
135 ///135 ///
136- /// These heights are window heights, so they exclude tile decorations, if any.136+ /// These heights are window heights, not tile heights, so they exclude tile decorations.
137 heights: Vec<WindowHeight>,137 heights: Vec<WindowHeight>,
138 138
139 /// Index of the currently active tile.139 /// Index of the currently active tile.
140- pub active_window_idx: usize,140+ pub active_tile_idx: usize,
141 141
142 /// Desired width of this column.142 /// Desired width of this column.
143 ///143 ///
@@ -237,10 +237,10 @@ impl<W: LayoutElement> Workspace<W> {
237 let view_pos = self.view_pos();237 let view_pos = self.view_pos();
238 238
239 for (col_idx, col) in self.columns.iter_mut().enumerate() {239 for (col_idx, col) in self.columns.iter_mut().enumerate() {
240- for (win_idx, tile) in col.windows.iter_mut().enumerate() {240+ for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {
241 let is_active = is_active241 let is_active = is_active
242 && col_idx == self.active_column_idx242 && col_idx == self.active_column_idx
243- && win_idx == col.active_window_idx;243+ && tile_idx == col.active_tile_idx;
244 tile.advance_animations(current_time, is_active);244 tile.advance_animations(current_time, is_active);
245 }245 }
246 }246 }
@@ -248,16 +248,16 @@ impl<W: LayoutElement> Workspace<W> {
248 // This shall one day become a proper animation.248 // This shall one day become a proper animation.
249 if !self.columns.is_empty() {249 if !self.columns.is_empty() {
250 let col = &self.columns[self.active_column_idx];250 let col = &self.columns[self.active_column_idx];
251- let active_win = &col.windows[col.active_window_idx];251+ let active_tile = &col.tiles[col.active_tile_idx];
252- let size = active_win.tile_size();252+ let size = active_tile.tile_size();
253- let has_ssd = active_win.has_ssd();253+ let has_ssd = active_tile.has_ssd();
254 254
255- let win_pos = Point::from((255+ let tile_pos = Point::from((
256 self.column_x(self.active_column_idx) - view_pos,256 self.column_x(self.active_column_idx) - view_pos,
257- col.window_y(col.active_window_idx),257+ col.tile_y(col.active_tile_idx),
258 ));258 ));
259 259
260- self.focus_ring.update(win_pos, size, has_ssd);260+ self.focus_ring.update(tile_pos, size, has_ssd);
261 self.focus_ring.set_active(is_active);261 self.focus_ring.set_active(is_active);
262 }262 }
263 }263 }
@@ -280,7 +280,7 @@ impl<W: LayoutElement> Workspace<W> {
280 pub fn windows(&self) -> impl Iterator<Item = &W> + '_ {280 pub fn windows(&self) -> impl Iterator<Item = &W> + '_ {
281 self.columns281 self.columns
282 .iter()282 .iter()
283- .flat_map(|col| col.windows.iter())283+ .flat_map(|col| col.tiles.iter())
284 .map(Tile::window)284 .map(Tile::window)
285 }285 }
286 286
@@ -508,14 +508,14 @@ impl<W: LayoutElement> Workspace<W> {
508 508
509 pub fn remove_window_by_idx(&mut self, column_idx: usize, window_idx: usize) -> W {509 pub fn remove_window_by_idx(&mut self, column_idx: usize, window_idx: usize) -> W {
510 let column = &mut self.columns[column_idx];510 let column = &mut self.columns[column_idx];
511- let window = column.windows.remove(window_idx).into_window();511+ let window = column.tiles.remove(window_idx).into_window();
512 column.heights.remove(window_idx);512 column.heights.remove(window_idx);
513 513
514 if let Some(output) = &self.output {514 if let Some(output) = &self.output {
515 window.output_leave(output);515 window.output_leave(output);
516 }516 }
517 517
518- if column.windows.is_empty() {518+ if column.tiles.is_empty() {
519 if column_idx + 1 == self.active_column_idx {519 if column_idx + 1 == self.active_column_idx {
520 // The previous column, that we were going to activate upon removal of the active520 // The previous column, that we were going to activate upon removal of the active
521 // column, has just been itself removed.521 // column, has just been itself removed.
@@ -544,8 +544,8 @@ impl<W: LayoutElement> Workspace<W> {
544 return window;544 return window;
545 }545 }
546 546
547- column.active_window_idx = min(column.active_window_idx, column.windows.len() - 1);547+ column.active_tile_idx = min(column.active_tile_idx, column.tiles.len() - 1);
548- column.update_window_sizes();548+ column.update_tile_sizes();
549 549
550 window550 window
551 }551 }
@@ -569,7 +569,7 @@ impl<W: LayoutElement> Workspace<W> {
569 .enumerate()569 .enumerate()
570 .find(|(_, col)| col.contains(window))570 .find(|(_, col)| col.contains(window))
571 .unwrap();571 .unwrap();
572- column.update_window_sizes();572+ column.update_tile_sizes();
573 573
574 if idx == self.active_column_idx {574 if idx == self.active_column_idx {
575 // We might need to move the view to ensure the resized window is still visible.575 // We might need to move the view to ensure the resized window is still visible.
@@ -706,14 +706,14 @@ impl<W: LayoutElement> Workspace<W> {
706 }706 }
707 707
708 let source_column = &self.columns[self.active_column_idx];708 let source_column = &self.columns[self.active_column_idx];
709- if source_column.windows.len() == 1 {709+ if source_column.tiles.len() == 1 {
710 return;710 return;
711 }711 }
712 712
713 let width = source_column.width;713 let width = source_column.width;
714 let is_full_width = source_column.is_full_width;714 let is_full_width = source_column.is_full_width;
715 let window =715 let window =
716- self.remove_window_by_idx(self.active_column_idx, source_column.active_window_idx);716+ self.remove_window_by_idx(self.active_column_idx, source_column.active_tile_idx);
717 717
718 self.add_window(window, true, width, is_full_width);718 self.add_window(window, true, width, is_full_width);
719 }719 }
@@ -770,26 +770,26 @@ impl<W: LayoutElement> Workspace<W> {
770 770
771 // Prefer the active window since it's drawn on top.771 // Prefer the active window since it's drawn on top.
772 let col = &self.columns[self.active_column_idx];772 let col = &self.columns[self.active_column_idx];
773- let active_win = &col.windows[col.active_window_idx];773+ let active_tile = &col.tiles[col.active_tile_idx];
774- let win_pos = Point::from((774+ let tile_pos = Point::from((
775 self.column_x(self.active_column_idx) - view_pos,775 self.column_x(self.active_column_idx) - view_pos,
776- col.window_y(col.active_window_idx),776+ col.tile_y(col.active_tile_idx),
777 ));777 ));
778- if active_win.is_in_input_region(pos - win_pos.to_f64()) {778+ if active_tile.is_in_input_region(pos - tile_pos.to_f64()) {
779- return Some((active_win.window(), win_pos + active_win.buf_loc()));779+ return Some((active_tile.window(), tile_pos + active_tile.buf_loc()));
780 }780 }
781 781
782 let mut x = -view_pos;782 let mut x = -view_pos;
783 for col in &self.columns {783 for col in &self.columns {
784- for (win, y) in zip(&col.windows, col.window_ys()) {784+ for (tile, y) in zip(&col.tiles, col.tile_ys()) {
785- if win.window() == active_win.window() {785+ if tile.window() == active_tile.window() {
786 // Already handled it above.786 // Already handled it above.
787 continue;787 continue;
788 }788 }
789 789
790- let win_pos = Point::from((x, y));790+ let tile_pos = Point::from((x, y));
791- if win.is_in_input_region(pos - win_pos.to_f64()) {791+ if tile.is_in_input_region(pos - tile_pos.to_f64()) {
792- return Some((win.window(), win_pos + win.buf_loc()));792+ return Some((tile.window(), tile_pos + tile.buf_loc()));
793 }793 }
794 }794 }
795 795
@@ -832,23 +832,23 @@ impl<W: LayoutElement> Workspace<W> {
832 }832 }
833 833
834 pub fn set_fullscreen(&mut self, window: &W, is_fullscreen: bool) {834 pub fn set_fullscreen(&mut self, window: &W, is_fullscreen: bool) {
835- let (mut col_idx, win_idx) = self835+ let (mut col_idx, tile_idx) = self
836 .columns836 .columns
837 .iter()837 .iter()
838 .enumerate()838 .enumerate()
839- .find_map(|(col_idx, col)| col.position(window).map(|win_idx| (col_idx, win_idx)))839+ .find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx)))
840 .unwrap();840 .unwrap();
841 841
842 let mut col = &mut self.columns[col_idx];842 let mut col = &mut self.columns[col_idx];
843 843
844- if is_fullscreen && col.windows.len() > 1 {844+ if is_fullscreen && col.tiles.len() > 1 {
845 // This wasn't the only window in its column; extract it into a separate column.845 // This wasn't the only window in its column; extract it into a separate column.
846 let target_window_was_focused =846 let target_window_was_focused =
847- self.active_column_idx == col_idx && col.active_window_idx == win_idx;847+ self.active_column_idx == col_idx && col.active_tile_idx == tile_idx;
848- let window = col.windows.remove(win_idx).into_window();848+ let window = col.tiles.remove(tile_idx).into_window();
849- col.heights.remove(win_idx);849+ col.heights.remove(tile_idx);
850- col.active_window_idx = min(col.active_window_idx, col.windows.len() - 1);850+ col.active_tile_idx = min(col.active_tile_idx, col.tiles.len() - 1);
851- col.update_window_sizes();851+ col.update_tile_sizes();
852 let width = col.width;852 let width = col.width;
853 let is_full_width = col.is_full_width;853 let is_full_width = col.is_full_width;
854 854
@@ -902,9 +902,9 @@ impl Workspace<Window> {
902 let bounds = self.toplevel_bounds();902 let bounds = self.toplevel_bounds();
903 903
904 for (col_idx, col) in self.columns.iter().enumerate() {904 for (col_idx, col) in self.columns.iter().enumerate() {
905- for (win_idx, tile) in col.windows.iter().enumerate() {905+ for (tile_idx, tile) in col.tiles.iter().enumerate() {
906 let win = tile.window();906 let win = tile.window();
907- let active = self.active_column_idx == col_idx && col.active_window_idx == win_idx;907+ let active = self.active_column_idx == col_idx && col.active_tile_idx == tile_idx;
908 win.set_activated(active);908 win.set_activated(active);
909 909
910 win.toplevel().with_pending_state(|state| {910 win.toplevel().with_pending_state(|state| {
@@ -938,28 +938,28 @@ impl Workspace<Window> {
938 938
939 // Draw the active window on top.939 // Draw the active window on top.
940 let col = &self.columns[self.active_column_idx];940 let col = &self.columns[self.active_column_idx];
941- let active_win = &col.windows[col.active_window_idx];941+ let active_tile = &col.tiles[col.active_tile_idx];
942- let win_pos = Point::from((942+ let tile_pos = Point::from((
943 self.column_x(self.active_column_idx) - view_pos,943 self.column_x(self.active_column_idx) - view_pos,
944- col.window_y(col.active_window_idx),944+ col.tile_y(col.active_tile_idx),
945 ));945 ));
946 946
947 // Draw the window itself.947 // Draw the window itself.
948- rv.extend(active_win.render(renderer, win_pos, output_scale));948+ rv.extend(active_tile.render(renderer, tile_pos, output_scale));
949 949
950 // Draw the focus ring.950 // Draw the focus ring.
951 rv.extend(self.focus_ring.render(output_scale).map(Into::into));951 rv.extend(self.focus_ring.render(output_scale).map(Into::into));
952 952
953 let mut x = -view_pos;953 let mut x = -view_pos;
954 for col in &self.columns {954 for col in &self.columns {
955- for (win, y) in zip(&col.windows, col.window_ys()) {955+ for (tile, y) in zip(&col.tiles, col.tile_ys()) {
956- if win.window() == active_win.window() {956+ if tile.window() == active_tile.window() {
957 // Already handled it above.957 // Already handled it above.
958 continue;958 continue;
959 }959 }
960 960
961- let win_pos = Point::from((x, y));961+ let tile_pos = Point::from((x, y));
962- rv.extend(win.render(renderer, win_pos, output_scale));962+ rv.extend(tile.render(renderer, tile_pos, output_scale));
963 }963 }
964 964
965 x += col.width() + self.options.gaps;965 x += col.width() + self.options.gaps;
@@ -979,9 +979,9 @@ impl<W: LayoutElement> Column<W> {
979 is_full_width: bool,979 is_full_width: bool,
980 ) -> Self {980 ) -> Self {
981 let mut rv = Self {981 let mut rv = Self {
982- windows: vec![],982+ tiles: vec![],
983 heights: vec![],983 heights: vec![],
984- active_window_idx: 0,984+ active_tile_idx: 0,
985 width,985 width,
986 is_full_width,986 is_full_width,
987 is_fullscreen: false,987 is_fullscreen: false,
@@ -1003,7 +1003,7 @@ impl<W: LayoutElement> Column<W> {
1003 self.view_size = size;1003 self.view_size = size;
1004 self.working_area = working_area;1004 self.working_area = working_area;
1005 1005
1006- self.update_window_sizes();1006+ self.update_tile_sizes();
1007 }1007 }
1008 1008
1009 fn update_config(&mut self, options: Rc<Options>) {1009 fn update_config(&mut self, options: Rc<Options>) {
@@ -1026,32 +1026,29 @@ impl<W: LayoutElement> Column<W> {
1026 update_sizes = true;1026 update_sizes = true;
1027 }1027 }
1028 1028
1029- for tile in &mut self.windows {1029+ for tile in &mut self.tiles {
1030 tile.update_config(options.clone());1030 tile.update_config(options.clone());
1031 }1031 }
1032 1032
1033 self.options = options;1033 self.options = options;
1034 1034
1035 if update_sizes {1035 if update_sizes {
1036- self.update_window_sizes();1036+ self.update_tile_sizes();
1037 }1037 }
1038 }1038 }
1039 1039
1040 fn set_width(&mut self, width: ColumnWidth) {1040 fn set_width(&mut self, width: ColumnWidth) {
1041 self.width = width;1041 self.width = width;
1042 self.is_full_width = false;1042 self.is_full_width = false;
1043- self.update_window_sizes();1043+ self.update_tile_sizes();
1044 }1044 }
1045 1045
1046 pub fn contains(&self, window: &W) -> bool {1046 pub fn contains(&self, window: &W) -> bool {
1047- self.windows1047+ self.tiles.iter().map(Tile::window).any(|win| win == window)
1048- .iter()
1049- .map(Tile::window)
1050- .any(|win| win == window)
1051 }1048 }
1052 1049
1053 pub fn position(&self, window: &W) -> Option<usize> {1050 pub fn position(&self, window: &W) -> Option<usize> {
1054- self.windows1051+ self.tiles
1055 .iter()1052 .iter()
1056 .map(Tile::window)1053 .map(Tile::window)
1057 .position(|win| win == window)1054 .position(|win| win == window)
@@ -1059,25 +1056,25 @@ impl<W: LayoutElement> Column<W> {
1059 1056
1060 fn activate_window(&mut self, window: &W) {1057 fn activate_window(&mut self, window: &W) {
1061 let idx = self.position(window).unwrap();1058 let idx = self.position(window).unwrap();
1062- self.active_window_idx = idx;1059+ self.active_tile_idx = idx;
1063 }1060 }
1064 1061
1065 fn add_window(&mut self, window: W) {1062 fn add_window(&mut self, window: W) {
1066 let tile = Tile::new(window, self.options.clone());1063 let tile = Tile::new(window, self.options.clone());
1067 self.is_fullscreen = false;1064 self.is_fullscreen = false;
1068- self.windows.push(tile);1065+ self.tiles.push(tile);
1069 self.heights.push(WindowHeight::Auto);1066 self.heights.push(WindowHeight::Auto);
1070- self.update_window_sizes();1067+ self.update_tile_sizes();
1071 }1068 }
1072 1069
1073- fn update_window_sizes(&mut self) {1070+ fn update_tile_sizes(&mut self) {
1074 if self.is_fullscreen {1071 if self.is_fullscreen {
1075- self.windows[0].request_fullscreen(self.view_size);1072+ self.tiles[0].request_fullscreen(self.view_size);
1076 return;1073 return;
1077 }1074 }
1078 1075
1079- let min_size: Vec<_> = self.windows.iter().map(Tile::min_size).collect();1076+ let min_size: Vec<_> = self.tiles.iter().map(Tile::min_size).collect();
1080- let max_size: Vec<_> = self.windows.iter().map(Tile::max_size).collect();1077+ let max_size: Vec<_> = self.tiles.iter().map(Tile::max_size).collect();
1081 1078
1082 // Compute the column width.1079 // Compute the column width.
1083 let min_width = min_size1080 let min_width = min_size
@@ -1115,8 +1112,8 @@ impl<W: LayoutElement> Column<W> {
1115 let width = width.resolve(&self.options, self.working_area.size.w);1112 let width = width.resolve(&self.options, self.working_area.size.w);
1116 let width = max(min(width, max_width), min_width);1113 let width = max(min(width, max_width), min_width);
1117 1114
1118- // Compute the window heights. Start by converting window heights to tile heights.1115+ // Compute the tile heights. Start by converting window heights to tile heights.
1119- let mut heights = zip(&self.windows, &self.heights)1116+ let mut heights = zip(&self.tiles, &self.heights)
1120 .map(|(tile, height)| match *height {1117 .map(|(tile, height)| match *height {
1121 WindowHeight::Auto => WindowHeight::Auto,1118 WindowHeight::Auto => WindowHeight::Auto,
1122 WindowHeight::Fixed(height) => {1119 WindowHeight::Fixed(height) => {
@@ -1125,11 +1122,11 @@ impl<W: LayoutElement> Column<W> {
1125 })1122 })
1126 .collect::<Vec<_>>();1123 .collect::<Vec<_>>();
1127 let mut height_left = self.working_area.size.h - self.options.gaps;1124 let mut height_left = self.working_area.size.h - self.options.gaps;
1128- let mut auto_windows_left = self.windows.len();1125+ let mut auto_tiles_left = self.tiles.len();
1129 1126
1130- // Subtract all fixed-height windows.1127+ // Subtract all fixed-height tiles.
1131 for (h, (min_size, max_size)) in zip(&mut heights, zip(&min_size, &max_size)) {1128 for (h, (min_size, max_size)) in zip(&mut heights, zip(&min_size, &max_size)) {
1132- // Check if the window has an exact height constraint.1129+ // Check if the tile has an exact height constraint.
1133 if min_size.h > 0 && min_size.h == max_size.h {1130 if min_size.h > 0 && min_size.h == max_size.h {
1134 *h = WindowHeight::Fixed(min_size.h);1131 *h = WindowHeight::Fixed(min_size.h);
1135 }1132 }
@@ -1144,30 +1141,30 @@ impl<W: LayoutElement> Column<W> {
1144 *h = max(*h, 1);1141 *h = max(*h, 1);
1145 1142
1146 height_left -= *h + self.options.gaps;1143 height_left -= *h + self.options.gaps;
1147- auto_windows_left -= 1;1144+ auto_tiles_left -= 1;
1148 }1145 }
1149 }1146 }
1150 1147
1151- // Iteratively try to distribute the remaining height, checking against window min heights.1148+ // Iteratively try to distribute the remaining height, checking against tile min heights.
1152 // Pick an auto height according to the current sizes, then check if it satisfies all1149 // Pick an auto height according to the current sizes, then check if it satisfies all
1153- // remaining min heights. If not, allocate fixed height to those windows and repeat the1150+ // remaining min heights. If not, allocate fixed height to those tiles and repeat the
1154 // loop. On each iteration the auto height will get smaller.1151 // loop. On each iteration the auto height will get smaller.
1155 //1152 //
1156 // NOTE: we do not respect max height here. Doing so would complicate things: if the current1153 // NOTE: we do not respect max height here. Doing so would complicate things: if the current
1157- // auto height is above some window's max height, then the auto height can become larger.1154+ // auto height is above some tile's max height, then the auto height can become larger.
1158 // Combining this with the min height loop is where the complexity appears.1155 // Combining this with the min height loop is where the complexity appears.
1159 //1156 //
1160 // However, most max height uses are for fixed-size dialogs, where min height == max_height.1157 // However, most max height uses are for fixed-size dialogs, where min height == max_height.
1161 // This case is separately handled above.1158 // This case is separately handled above.
1162- while auto_windows_left > 0 {1159+ while auto_tiles_left > 0 {
1163 // Compute the current auto height.1160 // Compute the current auto height.
1164- let auto_height = height_left / auto_windows_left as i32 - self.options.gaps;1161+ let auto_height = height_left / auto_tiles_left as i32 - self.options.gaps;
1165 let auto_height = max(auto_height, 1);1162 let auto_height = max(auto_height, 1);
1166 1163
1167 // Integer division above can result in imperfect height distribution. We will make some1164 // Integer division above can result in imperfect height distribution. We will make some
1168- // windows 1 px taller to account for this.1165+ // tiles 1 px taller to account for this.
1169 let mut ones_left = height_left1166 let mut ones_left = height_left
1170- .saturating_sub((auto_height + self.options.gaps) * auto_windows_left as i32);1167+ .saturating_sub((auto_height + self.options.gaps) * auto_tiles_left as i32);
1171 1168
1172 let mut unsatisfied_min = false;1169 let mut unsatisfied_min = false;
1173 let mut ones_left_2 = ones_left;1170 let mut ones_left_2 = ones_left;
@@ -1186,13 +1183,13 @@ impl<W: LayoutElement> Column<W> {
1186 if min_size.h > 0 && min_size.h > auto {1183 if min_size.h > 0 && min_size.h > auto {
1187 *h = WindowHeight::Fixed(min_size.h);1184 *h = WindowHeight::Fixed(min_size.h);
1188 height_left -= min_size.h + self.options.gaps;1185 height_left -= min_size.h + self.options.gaps;
1189- auto_windows_left -= 1;1186+ auto_tiles_left -= 1;
1190 unsatisfied_min = true;1187 unsatisfied_min = true;
1191 }1188 }
1192 }1189 }
1193 1190
1194- // If some min height was unsatisfied, then we allocated the window more than the auto1191+ // If some min height was unsatisfied, then we allocated the tile more than the auto
1195- // height, which means that the remaining auto windows now have less height to work1192+ // height, which means that the remaining auto tiles now have less height to work
1196 // with, and the loop must run again.1193 // with, and the loop must run again.
1197 if unsatisfied_min {1194 if unsatisfied_min {
1198 continue;1195 continue;
@@ -1211,13 +1208,13 @@ impl<W: LayoutElement> Column<W> {
1211 }1208 }
1212 1209
1213 *h = WindowHeight::Fixed(auto);1210 *h = WindowHeight::Fixed(auto);
1214- auto_windows_left -= 1;1211+ auto_tiles_left -= 1;
1215 }1212 }
1216 1213
1217- assert_eq!(auto_windows_left, 0);1214+ assert_eq!(auto_tiles_left, 0);
1218 }1215 }
1219 1216
1220- for (tile, h) in zip(&mut self.windows, heights) {1217+ for (tile, h) in zip(&mut self.tiles, heights) {
1221 let WindowHeight::Fixed(height) = h else {1218 let WindowHeight::Fixed(height) = h else {
1222 unreachable!()1219 unreachable!()
1223 };1220 };
@@ -1228,51 +1225,51 @@ impl<W: LayoutElement> Column<W> {
1228 }1225 }
1229 1226
1230 fn width(&self) -> i32 {1227 fn width(&self) -> i32 {
1231- self.windows1228+ self.tiles
1232 .iter()1229 .iter()
1233- .map(|win| win.tile_size().w)1230+ .map(|tile| tile.tile_size().w)
1234 .max()1231 .max()
1235 .unwrap()1232 .unwrap()
1236 }1233 }
1237 1234
1238 fn focus_up(&mut self) {1235 fn focus_up(&mut self) {
1239- self.active_window_idx = self.active_window_idx.saturating_sub(1);1236+ self.active_tile_idx = self.active_tile_idx.saturating_sub(1);
1240 }1237 }
1241 1238
1242 fn focus_down(&mut self) {1239 fn focus_down(&mut self) {
1243- self.active_window_idx = min(self.active_window_idx + 1, self.windows.len() - 1);1240+ self.active_tile_idx = min(self.active_tile_idx + 1, self.tiles.len() - 1);
1244 }1241 }
1245 1242
1246 fn move_up(&mut self) {1243 fn move_up(&mut self) {
1247- let new_idx = self.active_window_idx.saturating_sub(1);1244+ let new_idx = self.active_tile_idx.saturating_sub(1);
1248- if self.active_window_idx == new_idx {1245+ if self.active_tile_idx == new_idx {
1249 return;1246 return;
1250 }1247 }
1251 1248
1252- self.windows.swap(self.active_window_idx, new_idx);1249+ self.tiles.swap(self.active_tile_idx, new_idx);
1253- self.heights.swap(self.active_window_idx, new_idx);1250+ self.heights.swap(self.active_tile_idx, new_idx);
1254- self.active_window_idx = new_idx;1251+ self.active_tile_idx = new_idx;
1255 }1252 }
1256 1253
1257 fn move_down(&mut self) {1254 fn move_down(&mut self) {
1258- let new_idx = min(self.active_window_idx + 1, self.windows.len() - 1);1255+ let new_idx = min(self.active_tile_idx + 1, self.tiles.len() - 1);
1259- if self.active_window_idx == new_idx {1256+ if self.active_tile_idx == new_idx {
1260 return;1257 return;
1261 }1258 }
1262 1259
1263- self.windows.swap(self.active_window_idx, new_idx);1260+ self.tiles.swap(self.active_tile_idx, new_idx);
1264- self.heights.swap(self.active_window_idx, new_idx);1261+ self.heights.swap(self.active_tile_idx, new_idx);
1265- self.active_window_idx = new_idx;1262+ self.active_tile_idx = new_idx;
1266 }1263 }
1267 1264
1268 #[cfg(test)]1265 #[cfg(test)]
1269 fn verify_invariants(&self) {1266 fn verify_invariants(&self) {
1270- assert!(!self.windows.is_empty(), "columns can't be empty");1267+ assert!(!self.tiles.is_empty(), "columns can't be empty");
1271- assert!(self.active_window_idx < self.windows.len());1268+ assert!(self.active_tile_idx < self.tiles.len());
1272- assert_eq!(self.windows.len(), self.heights.len());1269+ assert_eq!(self.tiles.len(), self.heights.len());
1273 1270
1274 if self.is_fullscreen {1271 if self.is_fullscreen {
1275- assert_eq!(self.windows.len(), 1);1272+ assert_eq!(self.tiles.len(), 1);
1276 }1273 }
1277 }1274 }
1278 1275
@@ -1302,7 +1299,7 @@ impl<W: LayoutElement> Column<W> {
1302 1299
1303 fn toggle_full_width(&mut self) {1300 fn toggle_full_width(&mut self) {
1304 self.is_full_width = !self.is_full_width;1301 self.is_full_width = !self.is_full_width;
1305- self.update_window_sizes();1302+ self.update_tile_sizes();
1306 }1303 }
1307 1304
1308 fn set_column_width(&mut self, change: SizeChange) {1305 fn set_column_width(&mut self, change: SizeChange) {
@@ -1328,7 +1325,7 @@ impl<W: LayoutElement> Column<W> {
1328 // As a special case, setting a fixed column width will compute it in such a way1325 // As a special case, setting a fixed column width will compute it in such a way
1329 // that the active window gets that width. This is the intention behind the ability1326 // that the active window gets that width. This is the intention behind the ability
1330 // to set a fixed size.1327 // to set a fixed size.
1331- let tile = &self.windows[self.active_window_idx];1328+ let tile = &self.tiles[self.active_tile_idx];
1332 ColumnWidth::Fixed(tile.tile_width_for_window_width(fixed).clamp(1, MAX_PX))1329 ColumnWidth::Fixed(tile.tile_width_for_window_width(fixed).clamp(1, MAX_PX))
1333 }1330 }
1334 (_, SizeChange::SetProportion(proportion)) => {1331 (_, SizeChange::SetProportion(proportion)) => {
@@ -1355,8 +1352,8 @@ impl<W: LayoutElement> Column<W> {
1355 }1352 }
1356 1353
1357 fn set_window_height(&mut self, change: SizeChange) {1354 fn set_window_height(&mut self, change: SizeChange) {
1358- let current = self.heights[self.active_window_idx];1355+ let current = self.heights[self.active_tile_idx];
1359- let tile = &self.windows[self.active_window_idx];1356+ let tile = &self.tiles[self.active_tile_idx];
1360 let current_window_px = match current {1357 let current_window_px = match current {
1361 WindowHeight::Auto => tile.window_size().h,1358 WindowHeight::Auto => tile.window_size().h,
1362 WindowHeight::Fixed(height) => height,1359 WindowHeight::Fixed(height) => height,
@@ -1389,7 +1386,7 @@ impl<W: LayoutElement> Column<W> {
1389 };1386 };
1390 1387
1391 // Clamp it against the window height constraints.1388 // Clamp it against the window height constraints.
1392- let win = &self.windows[self.active_window_idx].window();1389+ let win = &self.tiles[self.active_tile_idx].window();
1393 let min_h = win.min_size().h;1390 let min_h = win.min_size().h;
1394 let max_h = win.max_size().h;1391 let max_h = win.max_size().h;
1395 1392
@@ -1400,30 +1397,35 @@ impl<W: LayoutElement> Column<W> {
1400 window_height = window_height.max(min_h);1397 window_height = window_height.max(min_h);
1401 }1398 }
1402 1399
1403- self.heights[self.active_window_idx] = WindowHeight::Fixed(window_height.clamp(1, MAX_PX));1400+ self.heights[self.active_tile_idx] = WindowHeight::Fixed(window_height.clamp(1, MAX_PX));
1404- self.update_window_sizes();1401+ self.update_tile_sizes();
1405 }1402 }
1406 1403
1407 fn set_fullscreen(&mut self, is_fullscreen: bool) {1404 fn set_fullscreen(&mut self, is_fullscreen: bool) {
1408- assert_eq!(self.windows.len(), 1);1405+ assert_eq!(self.tiles.len(), 1);
1409 self.is_fullscreen = is_fullscreen;1406 self.is_fullscreen = is_fullscreen;
1410- self.update_window_sizes();1407+ self.update_tile_sizes();
1408+ }
1409+
1410+ pub fn window_y(&self, tile_idx: usize) -> i32 {
1411+ let (tile, tile_y) = zip(&self.tiles, self.tile_ys()).nth(tile_idx).unwrap();
1412+ tile_y + tile.window_loc().y
1411 }1413 }
1412 1414
1413- pub fn window_y(&self, window_idx: usize) -> i32 {1415+ fn tile_y(&self, tile_idx: usize) -> i32 {
1414- self.window_ys().nth(window_idx).unwrap()1416+ self.tile_ys().nth(tile_idx).unwrap()
1415 }1417 }
1416 1418
1417- fn window_ys(&self) -> impl Iterator<Item = i32> + '_ {1419+ fn tile_ys(&self) -> impl Iterator<Item = i32> + '_ {
1418 let mut y = 0;1420 let mut y = 0;
1419 1421
1420 if !self.is_fullscreen {1422 if !self.is_fullscreen {
1421 y = self.working_area.loc.y + self.options.gaps;1423 y = self.working_area.loc.y + self.options.gaps;
1422 }1424 }
1423 1425
1424- self.windows.iter().map(move |win| {1426+ self.tiles.iter().map(move |tile| {
1425 let pos = y;1427 let pos = y;
1426- y += win.tile_size().h + self.options.gaps;1428+ y += tile.tile_size().h + self.options.gaps;
1427 pos1429 pos
1428 })1430 })
1429 }1431 }
@@ -1441,7 +1443,7 @@ fn compute_new_view_offset(
1441 return 0;1443 return 0;
1442 }1444 }
1443 1445
1444- // Compute the padding in case it needs to be smaller due to large window width.1446+ // Compute the padding in case it needs to be smaller due to large tile width.
1445 let padding = ((view_width - new_col_width) / 2).clamp(0, gaps);1447 let padding = ((view_width - new_col_width) / 2).clamp(0, gaps);
1446 1448
1447 // Compute the desired new X with padding.1449 // Compute the desired new X with padding.