layout/scrolling: Preserve gesture anim in dnd_scroll_gesture_end()
Browse files at this commitdf3f3979e936ed6800b4fbd55843bb0fe2554f15Parent: 6215b5f2 changed files +68 -1
src/layout/scrolling.rsmodified+9 -1
| @@ -3492,7 +3492,15 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 3492 | if gesture.dnd_last_event_time.is_some() && gesture.tracker.pos() == 0. { | 3492 | if gesture.dnd_last_event_time.is_some() && gesture.tracker.pos() == 0. { |
| 3493 | // DnD didn't scroll anything, so preserve the current view position (rather than | 3493 | // DnD didn't scroll anything, so preserve the current view position (rather than |
| 3494 | // snapping the window). | 3494 | // snapping the window). |
| 3495 | - self.view_offset = ViewOffset::Static(gesture.delta_from_tracker); | 3495 | + |
| 3496 | + // If there's an ongoing animation within the gesture (e.g. from a window being removed | ||
| 3497 | + // during DnD), preserve it. | ||
| 3498 | + if let Some(mut anim) = gesture.animation.take() { | ||
| 3499 | + anim.offset(gesture.current_view_offset); | ||
| 3500 | + self.view_offset = ViewOffset::Animation(anim); | ||
| 3501 | + } else { | ||
| 3502 | + self.view_offset = ViewOffset::Static(gesture.delta_from_tracker); | ||
| 3503 | + } | ||
| 3496 | 3504 | ||
| 3497 | if !self.columns.is_empty() { | 3505 | if !self.columns.is_empty() { |
| 3498 | // Just in case, make sure the active window remains on screen. | 3506 | // Just in case, make sure the active window remains on screen. |
src/layout/tests/fullscreen.rsmodified+59 -0
| @@ -338,6 +338,65 @@ fn interactive_move_unfullscreen_to_floating_stops_dnd_scroll() { | |||
| 338 | check_ops(ops); | 338 | check_ops(ops); |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | +#[test] | ||
| 342 | +fn interactive_move_restore_to_floating_animates_view_offset() { | ||
| 343 | + let ops = [ | ||
| 344 | + Op::AddOutput(1), | ||
| 345 | + Op::AddWindow { | ||
| 346 | + params: TestWindowParams::new(1), | ||
| 347 | + }, | ||
| 348 | + Op::AddWindow { | ||
| 349 | + params: TestWindowParams::new(2), | ||
| 350 | + }, | ||
| 351 | + // Toggle window 1 to floating. | ||
| 352 | + Op::FocusWindow(1), | ||
| 353 | + Op::ToggleWindowFloating { id: None }, | ||
| 354 | + // Fullscreen window 1 - it moves to scrolling with restore_to_floating = true. | ||
| 355 | + Op::FullscreenWindow(1), | ||
| 356 | + Op::Communicate(1), | ||
| 357 | + Op::CompleteAnimations, | ||
| 358 | + ]; | ||
| 359 | + | ||
| 360 | + let mut layout = check_ops(ops); | ||
| 361 | + | ||
| 362 | + // Verify window 1 is in scrolling and has restore_to_floating = true. | ||
| 363 | + let scrolling = layout.active_workspace().unwrap().scrolling(); | ||
| 364 | + let tile1 = scrolling.tiles().find(|t| *t.window().id() == 1).unwrap(); | ||
| 365 | + assert!( | ||
| 366 | + tile1.restore_to_floating, | ||
| 367 | + "window 1 should have restore_to_floating = true" | ||
| 368 | + ); | ||
| 369 | + | ||
| 370 | + let ops = [ | ||
| 371 | + // Start interactive move on window 1. | ||
| 372 | + Op::InteractiveMoveBegin { | ||
| 373 | + window: 1, | ||
| 374 | + output_idx: 1, | ||
| 375 | + px: 100., | ||
| 376 | + py: 100., | ||
| 377 | + }, | ||
| 378 | + // Update with a large delta to trigger the unmaximize. | ||
| 379 | + Op::InteractiveMoveUpdate { | ||
| 380 | + window: 1, | ||
| 381 | + dx: 1000., | ||
| 382 | + dy: 1000., | ||
| 383 | + output_idx: 1, | ||
| 384 | + px: 0., | ||
| 385 | + py: 0., | ||
| 386 | + }, | ||
| 387 | + ]; | ||
| 388 | + check_ops_on_layout(&mut layout, ops); | ||
| 389 | + | ||
| 390 | + // Window 1 should now be removed from the workspace (in the interactive move state). | ||
| 391 | + // Window 2 should be the only window in the scrolling space. | ||
| 392 | + let scrolling = layout.active_workspace().unwrap().scrolling(); | ||
| 393 | + assert_eq!(scrolling.tiles().count(), 1); | ||
| 394 | + assert!(scrolling.tiles().next().unwrap().window().id() == &2); | ||
| 395 | + | ||
| 396 | + // The view offset should be animating to show window 2. | ||
| 397 | + assert!(scrolling.view_offset().is_animation_ongoing()); | ||
| 398 | +} | ||
| 399 | + | ||
| 341 | #[test] | 400 | #[test] |
| 342 | fn unfullscreen_view_offset_not_reset_during_dnd_gesture() { | 401 | fn unfullscreen_view_offset_not_reset_during_dnd_gesture() { |
| 343 | let ops = [ | 402 | let ops = [ |