forge
Explore
Log in

Don't you dare go Hollow

layout/scrolling: Track pending vs. current fullscreen for Columns

Browse files at this commit

c832bdecdda44648542f60dab73904f3e80dc857Ivan MolodetskikhParent: b8995a1
We already did that for Tiles, but for Columns we only tracked what was
effectively pending fullscreen. We used it in several places where the current
fullscreen should've been used instead, like the tile origin or the view offset.

This commit splits the two and makes every place use the right one.

Fixes things like tiles briefly appearing at y=0 between issuing the fullscreen
command and the tile committing in response to the fullscreen configure.
src/layout/scrolling.rsmodified+90 -35
@@ -166,8 +166,15 @@ pub struct Column<W: LayoutElement> {
166 /// Whether this column is full-width.166 /// Whether this column is full-width.
167 is_full_width: bool,167 is_full_width: bool,
168 168
169- /// Whether this column contains a single full-screened window.169+ /// Whether this column is going to be fullscreen.
170- is_fullscreen: bool,170+ ///
171+ /// This is the compositor-side fullscreen state, so it changes immediately upon
172+ /// set_fullscreen(). The actual tiles will take some time to respond to the fullscreen request
173+ /// and become fullscreen.
174+ ///
175+ /// Similarly, unsetting fullscreen will change this value to false immediately, and tiles will
176+ /// take some time to catch up and actually unfullscreen.
177+ is_pending_fullscreen: bool,
171 178
172 /// How this column displays and arranges windows.179 /// How this column displays and arranges windows.
173 display_mode: ColumnDisplay,180 display_mode: ColumnDisplay,
@@ -426,13 +433,13 @@ impl<W: LayoutElement> ScrollingSpace<W> {
426 Some(&mut col.tiles[col.active_tile_idx])433 Some(&mut col.tiles[col.active_tile_idx])
427 }434 }
428 435
429- pub fn is_active_fullscreen(&self) -> bool {436+ pub fn is_active_pending_fullscreen(&self) -> bool {
430 if self.columns.is_empty() {437 if self.columns.is_empty() {
431 return false;438 return false;
432 }439 }
433 440
434 let col = &self.columns[self.active_column_idx];441 let col = &self.columns[self.active_column_idx];
435- col.is_fullscreen442+ col.is_pending_fullscreen
436 }443 }
437 444
438 pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size<i32, Logical> {445 pub fn new_window_toplevel_bounds(&self, rules: &ResolvedWindowRules) -> Size<i32, Logical> {
@@ -570,7 +577,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
570 target_x,577 target_x,
571 self.column_x(idx),578 self.column_x(idx),
572 col.width(),579 col.width(),
573- col.is_fullscreen,580+ col.is_fullscreen(),
574 )581 )
575 }582 }
576 583
@@ -584,7 +591,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
584 target_x,591 target_x,
585 self.column_x(idx),592 self.column_x(idx),
586 col.width(),593 col.width(),
587- col.is_fullscreen,594+ col.is_fullscreen(),
588 )595 )
589 }596 }
590 597
@@ -1052,14 +1059,14 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1052 tile.animate_alpha(0., 1., movement_config);1059 tile.animate_alpha(0., 1., movement_config);
1053 }1060 }
1054 1061
1055- let was_fullscreen = column.is_any_fullscreen();1062+ let was_fullscreen = column.is_fullscreen();
1056 1063
1057 let tile = column.tiles.remove(tile_idx);1064 let tile = column.tiles.remove(tile_idx);
1058 column.data.remove(tile_idx);1065 column.data.remove(tile_idx);
1059 1066
1060 // If an active column became non-fullscreen after removing the tile, clear the stored1067 // If an active column became non-fullscreen after removing the tile, clear the stored
1061 // unfullscreen offset.1068 // unfullscreen offset.
1062- if column_idx == self.active_column_idx && was_fullscreen && !column.is_any_fullscreen() {1069+ if column_idx == self.active_column_idx && was_fullscreen && !column.is_fullscreen() {
1063 self.view_offset_before_fullscreen = None;1070 self.view_offset_before_fullscreen = None;
1064 }1071 }
1065 1072
@@ -1218,7 +1225,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1218 .enumerate()1225 .enumerate()
1219 .find(|(_, col)| col.contains(window))1226 .find(|(_, col)| col.contains(window))
1220 .unwrap();1227 .unwrap();
1221- let was_fullscreen = column.is_any_fullscreen();1228+ let was_fullscreen = column.is_fullscreen();
1222 1229
1223 let (tile_idx, tile) = column1230 let (tile_idx, tile) = column
1224 .tiles1231 .tiles
@@ -1317,7 +1324,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1317 }1324 }
1318 1325
1319 // When the active column goes fullscreen, store the view offset to restore later.1326 // When the active column goes fullscreen, store the view offset to restore later.
1320- let is_fullscreen = self.columns[col_idx].is_any_fullscreen();1327+ let is_fullscreen = self.columns[col_idx].is_fullscreen();
1321 if !was_fullscreen && is_fullscreen {1328 if !was_fullscreen && is_fullscreen {
1322 self.view_offset_before_fullscreen = Some(self.view_offset.stationary());1329 self.view_offset_before_fullscreen = Some(self.view_offset.stationary());
1323 }1330 }
@@ -2450,7 +2457,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2450 2457
2451 // Adjust for place-within-column tab indicator.2458 // Adjust for place-within-column tab indicator.
2452 let origin_x = col.tiles_origin().x;2459 let origin_x = col.tiles_origin().x;
2453- let extra_w = if is_tabbed && !col.is_fullscreen {2460+ let extra_w = if is_tabbed && !col.is_fullscreen() {
2454 col.tab_indicator.extra_size(col.tiles.len(), col.scale).w2461 col.tab_indicator.extra_size(col.tiles.len(), col.scale).w
2455 } else {2462 } else {
2456 0.2463 0.
@@ -2669,7 +2676,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2669 }2676 }
2670 2677
2671 let col = &mut self.columns[self.active_column_idx];2678 let col = &mut self.columns[self.active_column_idx];
2672- if col.is_fullscreen || col.is_full_width {2679+ if col.is_pending_fullscreen || col.is_full_width {
2673 return;2680 return;
2674 }2681 }
2675 2682
@@ -2765,7 +2772,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2765 .find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx)))2772 .find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx)))
2766 .unwrap();2773 .unwrap();
2767 2774
2768- if is_fullscreen == self.columns[col_idx].is_fullscreen {2775+ if is_fullscreen == self.columns[col_idx].is_pending_fullscreen {
2769 return false;2776 return false;
2770 }2777 }
2771 2778
@@ -2813,7 +2820,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2813 return false;2820 return false;
2814 }2821 }
2815 2822
2816- self.columns[self.active_column_idx].is_fullscreen2823+ self.columns[self.active_column_idx].is_fullscreen()
2817 }2824 }
2818 2825
2819 pub fn render_elements<R: NiriRenderer>(2826 pub fn render_elements<R: NiriRenderer>(
@@ -2893,7 +2900,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2893 let col_render_off = col.render_offset();2900 let col_render_off = col.render_offset();
2894 2901
2895 // Hit the tab indicator.2902 // Hit the tab indicator.
2896- if col.display_mode == ColumnDisplay::Tabbed && !col.is_fullscreen {2903+ if col.display_mode == ColumnDisplay::Tabbed && !col.is_fullscreen() {
2897 let col_pos = view_off + col_off + col_render_off;2904 let col_pos = view_off + col_off + col_render_off;
2898 let col_pos = col_pos.to_physical_precise_round(scale).to_logical(scale);2905 let col_pos = col_pos.to_physical_precise_round(scale).to_logical(scale);
2899 2906
@@ -3133,7 +3140,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
3133 for (col_idx, col) in self.columns.iter().enumerate() {3140 for (col_idx, col) in self.columns.iter().enumerate() {
3134 let col_w = col.width();3141 let col_w = col.width();
3135 3142
3136- let view_pos = if col.is_fullscreen {3143+ let view_pos = if col.is_fullscreen() {
3137 col_x3144 col_x
3138 } else if self.working_area.size.w <= col_w {3145 } else if self.working_area.size.w <= col_w {
3139 col_x - left_strut3146 col_x - left_strut
@@ -3160,7 +3167,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
3160 3167
3161 // Normal columns align with the working area, but fullscreen columns align with3168 // Normal columns align with the working area, but fullscreen columns align with
3162 // the view size.3169 // the view size.
3163- if col.is_fullscreen {3170+ if col.is_fullscreen() {
3164 let left = col_x;3171 let left = col_x;
3165 let right = col_x + col_w;3172 let right = col_x + col_w;
3166 (left, right)3173 (left, right)
@@ -3287,7 +3294,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
3287 let col_x = self.column_x(col_idx);3294 let col_x = self.column_x(col_idx);
3288 let col_w = col.width();3295 let col_w = col.width();
3289 3296
3290- if col.is_fullscreen {3297+ if col.is_fullscreen() {
3291 if target_snap.view_pos + self.view_size.w < col_x + col_w {3298 if target_snap.view_pos + self.view_size.w < col_x + col_w {
3292 break;3299 break;
3293 }3300 }
@@ -3309,7 +3316,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
3309 let col_x = self.column_x(col_idx);3316 let col_x = self.column_x(col_idx);
3310 let col_w = col.width();3317 let col_w = col.width();
3311 3318
3312- if col.is_fullscreen {3319+ if col.is_fullscreen() {
3313 if col_x < target_snap.view_pos {3320 if col_x < target_snap.view_pos {
3314 break;3321 break;
3315 }3322 }
@@ -3382,7 +3389,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
3382 .find(|col| col.contains(&window))3389 .find(|col| col.contains(&window))
3383 .unwrap();3390 .unwrap();
3384 3391
3385- if col.is_fullscreen {3392+ if col.is_pending_fullscreen {
3386 return false;3393 return false;
3387 }3394 }
3388 3395
@@ -3630,7 +3637,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
3630 3637
3631 if self.view_offset_before_fullscreen.is_some() {3638 if self.view_offset_before_fullscreen.is_some() {
3632 assert!(3639 assert!(
3633- col.is_any_fullscreen(),3640+ col.is_fullscreen(),
3634 "when view_offset_before_fullscreen is set, \3641 "when view_offset_before_fullscreen is set, \
3635 the active column must be fullscreen"3642 the active column must be fullscreen"
3636 );3643 );
@@ -3807,7 +3814,7 @@ impl<W: LayoutElement> Column<W> {
3807 width,3814 width,
3808 preset_width_idx: None,3815 preset_width_idx: None,
3809 is_full_width,3816 is_full_width,
3810- is_fullscreen: false,3817+ is_pending_fullscreen: false,
3811 display_mode,3818 display_mode,
3812 tab_indicator: TabIndicator::new(options.tab_indicator),3819 tab_indicator: TabIndicator::new(options.tab_indicator),
3813 move_animation: None,3820 move_animation: None,
@@ -3829,7 +3836,7 @@ impl<W: LayoutElement> Column<W> {
3829 // Animate the tab indicator for new columns.3836 // Animate the tab indicator for new columns.
3830 if display_mode == ColumnDisplay::Tabbed3837 if display_mode == ColumnDisplay::Tabbed
3831 && !rv.options.tab_indicator.hide_when_single_tab3838 && !rv.options.tab_indicator.hide_when_single_tab
3832- && !is_pending_fullscreen3839+ && !rv.is_fullscreen()
3833 {3840 {
3834 // Usually new columns are created together with window movement actions. For new3841 // Usually new columns are created together with window movement actions. For new
3835 // windows, we handle that in start_open_animation().3842 // windows, we handle that in start_open_animation().
@@ -3945,7 +3952,7 @@ impl<W: LayoutElement> Column<W> {
3945 // you don't want that to happen in fullscreen. Also, laying things out correctly when the3952 // you don't want that to happen in fullscreen. Also, laying things out correctly when the
3946 // tab indicator is within the column and the column goes fullscreen, would require too3953 // tab indicator is within the column and the column goes fullscreen, would require too
3947 // many changes to the code for too little benefit (it's mostly invisible anyway).3954 // many changes to the code for too little benefit (it's mostly invisible anyway).
3948- let enabled = self.display_mode == ColumnDisplay::Tabbed && !self.is_fullscreen;3955+ let enabled = self.display_mode == ColumnDisplay::Tabbed && !self.is_fullscreen();
3949 3956
3950 self.tab_indicator.update_render_elements(3957 self.tab_indicator.update_render_elements(
3951 enabled,3958 enabled,
@@ -4003,7 +4010,52 @@ impl<W: LayoutElement> Column<W> {
4003 }4010 }
4004 }4011 }
4005 4012
4006- fn is_any_fullscreen(&self) -> bool {4013+ /// Returns whether this column is currently fullscreen.
4014+ ///
4015+ /// As in, if it contains one currently-fullscreen tile, or in tabbed mode, if it contains at
4016+ /// least one currently-fullscreen tile.
4017+ ///
4018+ /// This will lag behind is_pending_fullscreen, depending on when the tiles actually respond to
4019+ /// the un/fullscreen request. But, it's possible for is_fullscreen() to flip instantly, for
4020+ /// example when consuming a fullscreen tile into a non-pending-fullscreen column.
4021+ ///
4022+ /// This controls things like:
4023+ ///
4024+ /// - whether the column draws at the top of the screen or at the start of the working area
4025+ /// - whether the column draws above the top layer-shell layer
4026+ /// - whether the tab indicator is shown
4027+ /// - restoring view_offset_before_fullscreen
4028+ ///
4029+ /// Edge cases to watch out for:
4030+ ///
4031+ /// - Consuming a fullscreen tile into a non-tabbed column will keep that tile fullscreen until
4032+ /// it responds to the unfullscreen request. This tile may be anywhere in the column,
4033+ /// including at the active position.
4034+ ///
4035+ /// - Changing a fullscreen tabbed column into normal mode is an easy way to get randomly
4036+ /// delayed unfullscreening tiles in a normal column.
4037+ ///
4038+ /// - is_fullscreen() can suddenly change when consuming/expelling a fullscreen tile into/from a
4039+ /// non-fullscreen column. This can influence the code that saves/restores the unfullscreen
4040+ /// view offset.
4041+ fn is_fullscreen(&self) -> bool {
4042+ // Behaviors that we want:
4043+ //
4044+ // 1. The common case: single tile in a column. Assume no animations. Fullscreening the tile
4045+ // should make it jump to the top-left of the screen only when the tile finishes
4046+ // fullscreening. Similarly, unfullscreening should keep it at the top-left until the
4047+ // tile had unfullscreened.
4048+ //
4049+ // 2. Unfullscreening a tabbed column with multiple tiles should restore the view offset
4050+ // correctly. This means waiting for *all* tiles to unfullscreen, because otherwise the
4051+ // restored view offset will immediately get overwritted by the still screen-wide column
4052+ // (it uses the largest tile's width).
4053+ //
4054+ // 3. Changing a fullscreen tabbed column to normal should probably also restore the view
4055+ // offset correctly. Same problem as above, but now for normal columns (since display
4056+ // mode change applies instantly).
4057+ //
4058+ // The logic that satisfies these behaviors is to check if *any* tile is fullscreen.
4007 self.tiles.iter().any(|tile| tile.is_fullscreen())4059 self.tiles.iter().any(|tile| tile.is_fullscreen())
4008 }4060 }
4009 4061
@@ -4047,7 +4099,7 @@ impl<W: LayoutElement> Column<W> {
4047 prev_offsets.extend(self.tile_offsets().take(self.tiles.len()));4099 prev_offsets.extend(self.tile_offsets().take(self.tiles.len()));
4048 4100
4049 if self.display_mode != ColumnDisplay::Tabbed {4101 if self.display_mode != ColumnDisplay::Tabbed {
4050- self.is_fullscreen = false;4102+ self.is_pending_fullscreen = false;
4051 }4103 }
4052 4104
4053 self.data4105 self.data
@@ -4159,7 +4211,7 @@ impl<W: LayoutElement> Column<W> {
4159 }4211 }
4160 4212
4161 fn update_tile_sizes_with_transaction(&mut self, animate: bool, transaction: Transaction) {4213 fn update_tile_sizes_with_transaction(&mut self, animate: bool, transaction: Transaction) {
4162- if self.is_fullscreen {4214+ if self.is_pending_fullscreen {
4163 for (tile_idx, tile) in self.tiles.iter_mut().enumerate() {4215 for (tile_idx, tile) in self.tiles.iter_mut().enumerate() {
4164 // In tabbed mode, only the visible window participates in the transaction.4216 // In tabbed mode, only the visible window participates in the transaction.
4165 let is_active = tile_idx == self.active_tile_idx;4217 let is_active = tile_idx == self.active_tile_idx;
@@ -4456,7 +4508,7 @@ impl<W: LayoutElement> Column<W> {
4456 .map(NotNan::into_inner)4508 .map(NotNan::into_inner)
4457 .unwrap();4509 .unwrap();
4458 4510
4459- if self.display_mode == ColumnDisplay::Tabbed && !self.is_fullscreen {4511+ if self.display_mode == ColumnDisplay::Tabbed && !self.is_fullscreen() {
4460 let extra_size = self.tab_indicator.extra_size(self.tiles.len(), self.scale);4512 let extra_size = self.tab_indicator.extra_size(self.tiles.len(), self.scale);
4461 tiles_width += extra_size.w;4513 tiles_width += extra_size.w;
4462 }4514 }
@@ -4807,7 +4859,7 @@ impl<W: LayoutElement> Column<W> {
4807 }4859 }
4808 4860
4809 fn set_fullscreen(&mut self, is_fullscreen: bool) {4861 fn set_fullscreen(&mut self, is_fullscreen: bool) {
4810- if self.is_fullscreen == is_fullscreen {4862+ if self.is_pending_fullscreen == is_fullscreen {
4811 return;4863 return;
4812 }4864 }
4813 4865
@@ -4815,7 +4867,7 @@ impl<W: LayoutElement> Column<W> {
4815 assert!(self.tiles.len() == 1 || self.display_mode == ColumnDisplay::Tabbed);4867 assert!(self.tiles.len() == 1 || self.display_mode == ColumnDisplay::Tabbed);
4816 }4868 }
4817 4869
4818- self.is_fullscreen = is_fullscreen;4870+ self.is_pending_fullscreen = is_fullscreen;
4819 self.update_tile_sizes(false);4871 self.update_tile_sizes(false);
4820 }4872 }
4821 4873
@@ -4880,7 +4932,7 @@ impl<W: LayoutElement> Column<W> {
4880 fn tiles_origin(&self) -> Point<f64, Logical> {4932 fn tiles_origin(&self) -> Point<f64, Logical> {
4881 let mut origin = Point::from((0., 0.));4933 let mut origin = Point::from((0., 0.));
4882 4934
4883- if self.is_fullscreen {4935+ if self.is_fullscreen() {
4884 return origin;4936 return origin;
4885 }4937 }
4886 4938
@@ -5040,7 +5092,7 @@ impl<W: LayoutElement> Column<W> {
5040 5092
5041 // Animate the appearance of the tab indicator.5093 // Animate the appearance of the tab indicator.
5042 if self.display_mode == ColumnDisplay::Tabbed5094 if self.display_mode == ColumnDisplay::Tabbed
5043- && !self.is_fullscreen5095+ && !self.is_fullscreen()
5044 && self.tiles.len() == 15096 && self.tiles.len() == 1
5045 && !self.tab_indicator.config().hide_when_single_tab5097 && !self.tab_indicator.config().hide_when_single_tab
5046 {5098 {
@@ -5063,7 +5115,7 @@ impl<W: LayoutElement> Column<W> {
5063 assert!(self.active_tile_idx < self.tiles.len());5115 assert!(self.active_tile_idx < self.tiles.len());
5064 assert_eq!(self.tiles.len(), self.data.len());5116 assert_eq!(self.tiles.len(), self.data.len());
5065 5117
5066- if self.is_fullscreen {5118+ if self.is_pending_fullscreen {
5067 assert!(self.tiles.len() == 1 || self.display_mode == ColumnDisplay::Tabbed);5119 assert!(self.tiles.len() == 1 || self.display_mode == ColumnDisplay::Tabbed);
5068 }5120 }
5069 5121
@@ -5094,7 +5146,10 @@ impl<W: LayoutElement> Column<W> {
5094 assert!(Rc::ptr_eq(&self.options, &tile.options));5146 assert!(Rc::ptr_eq(&self.options, &tile.options));
5095 assert_eq!(self.clock, tile.clock);5147 assert_eq!(self.clock, tile.clock);
5096 assert_eq!(self.scale, tile.scale());5148 assert_eq!(self.scale, tile.scale());
5097- assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen());5149+ assert_eq!(
5150+ self.is_pending_fullscreen,
5151+ tile.window().is_pending_fullscreen()
5152+ );
5098 assert_eq!(self.view_size, tile.view_size());5153 assert_eq!(self.view_size, tile.view_size());
5099 tile.verify_invariants();5154 tile.verify_invariants();
5100 5155
@@ -5119,7 +5174,7 @@ impl<W: LayoutElement> Column<W> {
5119 tile.tile_height_for_window_height(f64::from(requested_size.h));5174 tile.tile_height_for_window_height(f64::from(requested_size.h));
5120 let min_tile_height = f64::max(1., tile.min_size_nonfullscreen().h);5175 let min_tile_height = f64::max(1., tile.min_size_nonfullscreen().h);
5121 5176
5122- if !self.is_fullscreen5177+ if !self.is_pending_fullscreen
5123 && self.scale.round() == self.scale5178 && self.scale.round() == self.scale
5124 && working_size.h.round() == working_size.h5179 && working_size.h.round() == working_size.h
5125 && gaps.round() == gaps5180 && gaps.round() == gaps
src/layout/workspace.rsmodified+3 -3
@@ -444,8 +444,8 @@ impl<W: LayoutElement> Workspace<W> {
444 }444 }
445 }445 }
446 446
447- pub fn is_active_fullscreen(&self) -> bool {447+ pub fn is_active_pending_fullscreen(&self) -> bool {
448- self.scrolling.is_active_fullscreen()448+ self.scrolling.is_active_pending_fullscreen()
449 }449 }
450 450
451 pub fn set_output(&mut self, output: Option<Output>) {451 pub fn set_output(&mut self, output: Option<Output>) {
@@ -571,7 +571,7 @@ impl<W: LayoutElement> Workspace<W> {
571 match target {571 match target {
572 WorkspaceAddWindowTarget::Auto => {572 WorkspaceAddWindowTarget::Auto => {
573 // Don't steal focus from an active fullscreen window.573 // Don't steal focus from an active fullscreen window.
574- let activate = activate.map_smart(|| !self.is_active_fullscreen());574+ let activate = activate.map_smart(|| !self.is_active_pending_fullscreen());
575 575
576 // If the tile is pending fullscreen, open it in the scrolling layout where it can576 // If the tile is pending fullscreen, open it in the scrolling layout where it can
577 // go fullscreen.577 // go fullscreen.