layout/scrolling: Take unfullscreen view offset unconditionally
Browse files at this commit83ec36953611ab11dd36c3c3632db7bd3fea9b82Parent: 97dfd2b2 changed files +84 -13
- src/layout/scrolling.rs +21 -13
- src/layout/tests.rs +63 -0
src/layout/scrolling.rsmodified+21 -13
| @@ -1291,20 +1291,28 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 1291 | self.view_offset.offset(offset); | 1291 | self.view_offset.offset(offset); |
| 1292 | } | 1292 | } |
| 1293 | 1293 | ||
| 1294 | - if self.interactive_resize.is_none() && !self.view_offset.is_gesture() { | 1294 | + // Upon unfullscreening, restore the view offset. |
| 1295 | - // We might need to move the view to ensure the resized window is still visible. | 1295 | + // |
| 1296 | + // In tabbed display mode, there can be multiple tiles in a fullscreen column. They | ||
| 1297 | + // will unfullscreen one by one, and the column width will shrink only when the | ||
| 1298 | + // last tile unfullscreens. This is when we want to restore the view offset, | ||
| 1299 | + // otherwise it will immediately reset back by the animate_view_offset below. | ||
| 1300 | + let is_fullscreen = self.columns[col_idx].tiles.iter().any(Tile::is_fullscreen); | ||
| 1301 | + let unfullscreen_offset = if was_fullscreen && !is_fullscreen { | ||
| 1302 | + // Take the value unconditionally, even if the view is currently frozen by | ||
| 1303 | + // a view gesture. It shouldn't linger around because it's only valid for this | ||
| 1304 | + // particular unfullscreen. | ||
| 1305 | + self.view_offset_before_fullscreen.take() | ||
| 1306 | + } else { | ||
| 1307 | + None | ||
| 1308 | + }; | ||
| 1296 | 1309 | ||
| 1297 | - // Upon unfullscreening, restore the view offset. | 1310 | + // We might need to move the view to ensure the resized window is still visible. But |
| 1298 | - // | 1311 | + // only do it when the view isn't frozen by an interactive resize or a view gesture. |
| 1299 | - // In tabbed display mode, there can be multiple tiles in a fullscreen column. They | 1312 | + if self.interactive_resize.is_none() && !self.view_offset.is_gesture() { |
| 1300 | - // will unfullscreen one by one, and the column width will shrink only when the | 1313 | + // Restore the view offset upon unfullscreening if needed. |
| 1301 | - // last tile unfullscreens. This is when we want to restore the view offset, | 1314 | + if let Some(prev_offset) = unfullscreen_offset { |
| 1302 | - // otherwise it will immediately reset back by the animate_view_offset below. | 1315 | + self.animate_view_offset(col_idx, prev_offset); |
| 1303 | - let is_fullscreen = self.columns[col_idx].tiles.iter().any(Tile::is_fullscreen); | ||
| 1304 | - if was_fullscreen && !is_fullscreen { | ||
| 1305 | - if let Some(prev_offset) = self.view_offset_before_fullscreen.take() { | ||
| 1306 | - self.animate_view_offset(col_idx, prev_offset); | ||
| 1307 | - } | ||
| 1308 | } | 1316 | } |
| 1309 | 1317 | ||
| 1310 | // Synchronize the horizontal view movement with the resize so that it looks nice. | 1318 | // Synchronize the horizontal view movement with the resize so that it looks nice. |
src/layout/tests.rsmodified+63 -0
| @@ -3471,6 +3471,69 @@ fn interactive_move_unfullscreen_to_floating_stops_dnd_scroll() { | |||
| 3471 | check_ops(&ops); | 3471 | check_ops(&ops); |
| 3472 | } | 3472 | } |
| 3473 | 3473 | ||
| 3474 | +#[test] | ||
| 3475 | +fn unfullscreen_view_offset_not_reset_during_dnd_gesture() { | ||
| 3476 | + let ops = [ | ||
| 3477 | + Op::AddOutput(1), | ||
| 3478 | + Op::AddWindow { | ||
| 3479 | + params: TestWindowParams::new(3), | ||
| 3480 | + }, | ||
| 3481 | + Op::FullscreenWindow(3), | ||
| 3482 | + Op::Communicate(3), | ||
| 3483 | + Op::DndUpdate { | ||
| 3484 | + output_idx: 1, | ||
| 3485 | + px: 0.0, | ||
| 3486 | + py: 0.0, | ||
| 3487 | + }, | ||
| 3488 | + Op::FullscreenWindow(3), | ||
| 3489 | + Op::Communicate(3), | ||
| 3490 | + ]; | ||
| 3491 | + | ||
| 3492 | + check_ops(&ops); | ||
| 3493 | +} | ||
| 3494 | + | ||
| 3495 | +#[test] | ||
| 3496 | +fn unfullscreen_view_offset_not_reset_during_gesture() { | ||
| 3497 | + let ops = [ | ||
| 3498 | + Op::AddOutput(1), | ||
| 3499 | + Op::AddWindow { | ||
| 3500 | + params: TestWindowParams::new(3), | ||
| 3501 | + }, | ||
| 3502 | + Op::FullscreenWindow(3), | ||
| 3503 | + Op::Communicate(3), | ||
| 3504 | + Op::ViewOffsetGestureBegin { | ||
| 3505 | + output_idx: 1, | ||
| 3506 | + workspace_idx: None, | ||
| 3507 | + is_touchpad: false, | ||
| 3508 | + }, | ||
| 3509 | + Op::FullscreenWindow(3), | ||
| 3510 | + Op::Communicate(3), | ||
| 3511 | + ]; | ||
| 3512 | + | ||
| 3513 | + check_ops(&ops); | ||
| 3514 | +} | ||
| 3515 | + | ||
| 3516 | +#[test] | ||
| 3517 | +fn unfullscreen_view_offset_not_reset_during_ongoing_gesture() { | ||
| 3518 | + let ops = [ | ||
| 3519 | + Op::AddOutput(1), | ||
| 3520 | + Op::AddWindow { | ||
| 3521 | + params: TestWindowParams::new(3), | ||
| 3522 | + }, | ||
| 3523 | + Op::ViewOffsetGestureBegin { | ||
| 3524 | + output_idx: 1, | ||
| 3525 | + workspace_idx: None, | ||
| 3526 | + is_touchpad: false, | ||
| 3527 | + }, | ||
| 3528 | + Op::FullscreenWindow(3), | ||
| 3529 | + Op::Communicate(3), | ||
| 3530 | + Op::FullscreenWindow(3), | ||
| 3531 | + Op::Communicate(3), | ||
| 3532 | + ]; | ||
| 3533 | + | ||
| 3534 | + check_ops(&ops); | ||
| 3535 | +} | ||
| 3536 | + | ||
| 3474 | fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool { | 3537 | fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool { |
| 3475 | if parent_id == id { | 3538 | if parent_id == id { |
| 3476 | return true; | 3539 | return true; |