layout/tile: Animate un/fullscreen resize
Browse files at this commita0d002c318b79b09a9ba4b4cbeea772fa3b7de33Parent: d0e98d62 changed files +207 -94
- src/layout/scrolling.rs +4 -19
- src/layout/tile.rs +203 -75
src/layout/scrolling.rsmodified+4 -19
| @@ -2778,11 +2778,10 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2778 | } | 2778 | } |
| 2779 | 2779 | ||
| 2780 | pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) -> bool { | 2780 | pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) -> bool { |
| 2781 | - let (mut col_idx, tile_idx) = self | 2781 | + let mut col_idx = self |
| 2782 | .columns | 2782 | .columns |
| 2783 | .iter() | 2783 | .iter() |
| 2784 | - .enumerate() | 2784 | + .position(|col| col.contains(window)) |
| 2785 | - .find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx))) | ||
| 2786 | .unwrap(); | 2785 | .unwrap(); |
| 2787 | 2786 | ||
| 2788 | if is_fullscreen == self.columns[col_idx].is_pending_fullscreen { | 2787 | if is_fullscreen == self.columns[col_idx].is_pending_fullscreen { |
| @@ -2796,21 +2795,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2796 | 2795 | ||
| 2797 | if is_fullscreen && (col.tiles.len() > 1 && !is_tabbed) { | 2796 | if is_fullscreen && (col.tiles.len() > 1 && !is_tabbed) { |
| 2798 | // This wasn't the only window in its column; extract it into a separate column. | 2797 | // This wasn't the only window in its column; extract it into a separate column. |
| 2799 | - let activate = self.active_column_idx == col_idx && col.active_tile_idx == tile_idx; | 2798 | + self.consume_or_expel_window_right(Some(window)); |
| 2800 | - | ||
| 2801 | - let removed = self.remove_tile_by_idx(col_idx, tile_idx, Transaction::new(), None); | ||
| 2802 | - // Create a column manually to disable the resize animation. | ||
| 2803 | - let column = Column::new_with_tile( | ||
| 2804 | - removed.tile, | ||
| 2805 | - self.view_size, | ||
| 2806 | - self.working_area, | ||
| 2807 | - self.scale, | ||
| 2808 | - removed.width, | ||
| 2809 | - removed.is_full_width, | ||
| 2810 | - false, | ||
| 2811 | - ); | ||
| 2812 | - self.add_column(Some(col_idx + 1), column, activate, None); | ||
| 2813 | - | ||
| 2814 | col_idx += 1; | 2799 | col_idx += 1; |
| 2815 | col = &mut self.columns[col_idx]; | 2800 | col = &mut self.columns[col_idx]; |
| 2816 | } | 2801 | } |
| @@ -4881,7 +4866,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 4881 | } | 4866 | } |
| 4882 | 4867 | ||
| 4883 | self.is_pending_fullscreen = is_fullscreen; | 4868 | self.is_pending_fullscreen = is_fullscreen; |
| 4884 | - self.update_tile_sizes(false); | 4869 | + self.update_tile_sizes(true); |
| 4885 | } | 4870 | } |
| 4886 | 4871 | ||
| 4887 | fn set_column_display(&mut self, display: ColumnDisplay) { | 4872 | fn set_column_display(&mut self, display: ColumnDisplay) { |
src/layout/tile.rsmodified+203 -75
| @@ -138,6 +138,13 @@ struct ResizeAnimation { | |||
| 138 | size_from: Size<f64, Logical>, | 138 | size_from: Size<f64, Logical>, |
| 139 | snapshot: LayoutElementRenderSnapshot, | 139 | snapshot: LayoutElementRenderSnapshot, |
| 140 | offscreen: OffscreenBuffer, | 140 | offscreen: OffscreenBuffer, |
| 141 | + tile_size_from: Size<f64, Logical>, | ||
| 142 | + // If the resize involved the fullscreen state at some point, this is the progress toward the | ||
| 143 | + // fullscreen state. Used for things like fullscreen backdrop alpha. | ||
| 144 | + // | ||
| 145 | + // Note that this can be set even if this specific resize is between two non-fullscreen states, | ||
| 146 | + // for example when issuing a new resize during an unfullscreen resize. | ||
| 147 | + fullscreen_progress: Option<Animation>, | ||
| 141 | } | 148 | } |
| 142 | 149 | ||
| 143 | #[derive(Debug)] | 150 | #[derive(Debug)] |
| @@ -178,7 +185,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 178 | focus_ring: FocusRing::new(focus_ring_config.into()), | 185 | focus_ring: FocusRing::new(focus_ring_config.into()), |
| 179 | shadow: Shadow::new(shadow_config), | 186 | shadow: Shadow::new(shadow_config), |
| 180 | is_fullscreen, | 187 | is_fullscreen, |
| 181 | - fullscreen_backdrop: SolidColorBuffer::new(view_size, [0., 0., 0., 1.]), | 188 | + fullscreen_backdrop: SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.]), |
| 182 | unfullscreen_to_floating: false, | 189 | unfullscreen_to_floating: false, |
| 183 | floating_window_size: None, | 190 | floating_window_size: None, |
| 184 | floating_pos: None, | 191 | floating_pos: None, |
| @@ -229,8 +236,6 @@ impl<W: LayoutElement> Tile<W> { | |||
| 229 | 236 | ||
| 230 | let shadow_config = rules.shadow.resolve_against(self.options.shadow); | 237 | let shadow_config = rules.shadow.resolve_against(self.options.shadow); |
| 231 | self.shadow.update_config(shadow_config); | 238 | self.shadow.update_config(shadow_config); |
| 232 | - | ||
| 233 | - self.fullscreen_backdrop.resize(view_size); | ||
| 234 | } | 239 | } |
| 235 | 240 | ||
| 236 | pub fn update_shaders(&mut self) { | 241 | pub fn update_shaders(&mut self) { |
| @@ -240,28 +245,67 @@ impl<W: LayoutElement> Tile<W> { | |||
| 240 | } | 245 | } |
| 241 | 246 | ||
| 242 | pub fn update_window(&mut self) { | 247 | pub fn update_window(&mut self) { |
| 248 | + let was_fullscreen = self.is_fullscreen; | ||
| 243 | self.is_fullscreen = self.window.is_fullscreen(); | 249 | self.is_fullscreen = self.window.is_fullscreen(); |
| 244 | 250 | ||
| 245 | if let Some(animate_from) = self.window.take_animation_snapshot() { | 251 | if let Some(animate_from) = self.window.take_animation_snapshot() { |
| 246 | - let (size_from, offscreen) = if let Some(resize) = self.resize_animation.take() { | 252 | + let params = if let Some(resize) = self.resize_animation.take() { |
| 247 | // Compute like in animated_window_size(), but using the snapshot geometry (since | 253 | // Compute like in animated_window_size(), but using the snapshot geometry (since |
| 248 | // the current one is already overwritten). | 254 | // the current one is already overwritten). |
| 249 | let mut size = animate_from.size; | 255 | let mut size = animate_from.size; |
| 250 | 256 | ||
| 251 | let val = resize.anim.value(); | 257 | let val = resize.anim.value(); |
| 252 | let size_from = resize.size_from; | 258 | let size_from = resize.size_from; |
| 259 | + let tile_size_from = resize.tile_size_from; | ||
| 253 | 260 | ||
| 254 | size.w = size_from.w + (size.w - size_from.w) * val; | 261 | size.w = size_from.w + (size.w - size_from.w) * val; |
| 255 | size.h = size_from.h + (size.h - size_from.h) * val; | 262 | size.h = size_from.h + (size.h - size_from.h) * val; |
| 256 | 263 | ||
| 264 | + let mut tile_size = animate_from.size; | ||
| 265 | + if was_fullscreen { | ||
| 266 | + tile_size.w = f64::max(tile_size.w, self.view_size.w); | ||
| 267 | + tile_size.h = f64::max(tile_size.h, self.view_size.h); | ||
| 268 | + } else if !self.border.is_off() { | ||
| 269 | + let width = self.border.width(); | ||
| 270 | + tile_size.w += width * 2.; | ||
| 271 | + tile_size.h += width * 2.; | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + tile_size.w = tile_size_from.w + (tile_size.w - tile_size_from.w) * val; | ||
| 275 | + tile_size.h = tile_size_from.h + (tile_size.h - tile_size_from.h) * val; | ||
| 276 | + | ||
| 277 | + let fullscreen_from = resize | ||
| 278 | + .fullscreen_progress | ||
| 279 | + .map(|anim| anim.clamped_value().clamp(0., 1.)) | ||
| 280 | + .unwrap_or(if was_fullscreen { 1. } else { 0. }); | ||
| 281 | + | ||
| 257 | // Also try to reuse the existing offscreen buffer if we have one. | 282 | // Also try to reuse the existing offscreen buffer if we have one. |
| 258 | - (size, resize.offscreen) | 283 | + (size, tile_size, fullscreen_from, resize.offscreen) |
| 259 | } else { | 284 | } else { |
| 260 | - (animate_from.size, OffscreenBuffer::default()) | 285 | + let size = animate_from.size; |
| 286 | + | ||
| 287 | + // Compute like in tile_size(). | ||
| 288 | + let mut tile_size = size; | ||
| 289 | + if was_fullscreen { | ||
| 290 | + tile_size.w = f64::max(tile_size.w, self.view_size.w); | ||
| 291 | + tile_size.h = f64::max(tile_size.h, self.view_size.h); | ||
| 292 | + } else if !self.border.is_off() { | ||
| 293 | + let width = self.border.width(); | ||
| 294 | + tile_size.w += width * 2.; | ||
| 295 | + tile_size.h += width * 2.; | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + let fullscreen_from = if was_fullscreen { 1. } else { 0. }; | ||
| 299 | + | ||
| 300 | + (size, tile_size, fullscreen_from, OffscreenBuffer::default()) | ||
| 261 | }; | 301 | }; |
| 302 | + let (size_from, tile_size_from, fullscreen_from, offscreen) = params; | ||
| 262 | 303 | ||
| 263 | let change = self.window.size().to_f64().to_point() - size_from.to_point(); | 304 | let change = self.window.size().to_f64().to_point() - size_from.to_point(); |
| 264 | let change = f64::max(change.x.abs(), change.y.abs()); | 305 | let change = f64::max(change.x.abs(), change.y.abs()); |
| 306 | + let tile_change = self.tile_size().to_f64().to_point() - tile_size_from.to_point(); | ||
| 307 | + let tile_change = f64::max(tile_change.x.abs(), tile_change.y.abs()); | ||
| 308 | + let change = f64::max(change, tile_change); | ||
| 265 | if change > RESIZE_ANIMATION_THRESHOLD { | 309 | if change > RESIZE_ANIMATION_THRESHOLD { |
| 266 | let anim = Animation::new( | 310 | let anim = Animation::new( |
| 267 | self.clock.clone(), | 311 | self.clock.clone(), |
| @@ -270,11 +314,18 @@ impl<W: LayoutElement> Tile<W> { | |||
| 270 | 0., | 314 | 0., |
| 271 | self.options.animations.window_resize.anim, | 315 | self.options.animations.window_resize.anim, |
| 272 | ); | 316 | ); |
| 317 | + | ||
| 318 | + let fullscreen_to = if self.is_fullscreen { 1. } else { 0. }; | ||
| 319 | + let fullscreen_progress = (fullscreen_from != fullscreen_to) | ||
| 320 | + .then(|| anim.restarted(fullscreen_from, fullscreen_to, 0.)); | ||
| 321 | + | ||
| 273 | self.resize_animation = Some(ResizeAnimation { | 322 | self.resize_animation = Some(ResizeAnimation { |
| 274 | anim, | 323 | anim, |
| 275 | size_from, | 324 | size_from, |
| 276 | snapshot: animate_from, | 325 | snapshot: animate_from, |
| 277 | offscreen, | 326 | offscreen, |
| 327 | + tile_size_from, | ||
| 328 | + fullscreen_progress, | ||
| 278 | }); | 329 | }); |
| 279 | } else { | 330 | } else { |
| 280 | self.resize_animation = None; | 331 | self.resize_animation = None; |
| @@ -349,24 +400,30 @@ impl<W: LayoutElement> Tile<W> { | |||
| 349 | 400 | ||
| 350 | pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { | 401 | pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { |
| 351 | let rules = self.window.rules(); | 402 | let rules = self.window.rules(); |
| 352 | - let animated_window_size = self.animated_window_size(); | ||
| 353 | let animated_tile_size = self.animated_tile_size(); | 403 | let animated_tile_size = self.animated_tile_size(); |
| 404 | + let fullscreen_progress = self.fullscreen_progress(); | ||
| 354 | 405 | ||
| 355 | let draw_border_with_background = rules | 406 | let draw_border_with_background = rules |
| 356 | .draw_border_with_background | 407 | .draw_border_with_background |
| 357 | - .unwrap_or_else(|| !self.window.has_ssd()); | 408 | + .unwrap_or_else(|| !self.window.has_ssd()) |
| 358 | - let border_width = self.effective_border_width().unwrap_or(0.); | 409 | + && fullscreen_progress < 1.; |
| 359 | - let radius = if self.is_fullscreen { | 410 | + let border_width = self.visual_border_width().unwrap_or(0.); |
| 360 | - CornerRadius::default() | 411 | + |
| 361 | - } else { | 412 | + // Do the inverse of tile_size() in order to handle the unfullscreen animation for windows |
| 362 | - rules | 413 | + // that were smaller than the fullscreen size, and therefore their animated_window_size() is |
| 363 | - .geometry_corner_radius | 414 | + // currently much smaller than the tile size. |
| 364 | - .map_or(CornerRadius::default(), |radius| { | 415 | + let mut border_window_size = animated_tile_size; |
| 365 | - radius.expanded_by(border_width as f32) | 416 | + border_window_size.w -= border_width * 2.; |
| 366 | - }) | 417 | + border_window_size.h -= border_width * 2.; |
| 367 | - }; | 418 | + |
| 419 | + let radius = rules | ||
| 420 | + .geometry_corner_radius | ||
| 421 | + .map_or(CornerRadius::default(), |radius| { | ||
| 422 | + radius.expanded_by(border_width as f32) | ||
| 423 | + }) | ||
| 424 | + .scaled_by(1. - fullscreen_progress as f32); | ||
| 368 | self.border.update_render_elements( | 425 | self.border.update_render_elements( |
| 369 | - animated_window_size, | 426 | + border_window_size, |
| 370 | is_active, | 427 | is_active, |
| 371 | !draw_border_with_background, | 428 | !draw_border_with_background, |
| 372 | self.window.is_urgent(), | 429 | self.window.is_urgent(), |
| @@ -379,24 +436,25 @@ impl<W: LayoutElement> Tile<W> { | |||
| 379 | 1., | 436 | 1., |
| 380 | ); | 437 | ); |
| 381 | 438 | ||
| 382 | - let radius = if self.is_fullscreen { | 439 | + let radius = if self.visual_border_width().is_some() { |
| 383 | - CornerRadius::default() | ||
| 384 | - } else if self.effective_border_width().is_some() { | ||
| 385 | radius | 440 | radius |
| 386 | } else { | 441 | } else { |
| 387 | - rules.geometry_corner_radius.unwrap_or_default() | 442 | + rules |
| 443 | + .geometry_corner_radius | ||
| 444 | + .unwrap_or_default() | ||
| 445 | + .scaled_by(1. - fullscreen_progress as f32) | ||
| 388 | }; | 446 | }; |
| 389 | self.shadow | 447 | self.shadow |
| 390 | .update_render_elements(animated_tile_size, is_active, radius, self.scale, 1.); | 448 | .update_render_elements(animated_tile_size, is_active, radius, self.scale, 1.); |
| 391 | 449 | ||
| 392 | - let draw_focus_ring_with_background = if self.effective_border_width().is_some() { | 450 | + let draw_focus_ring_with_background = if self.border.is_off() && fullscreen_progress < 1. { |
| 393 | - false | ||
| 394 | - } else { | ||
| 395 | draw_border_with_background | 451 | draw_border_with_background |
| 452 | + } else { | ||
| 453 | + false | ||
| 396 | }; | 454 | }; |
| 397 | let radius = radius.expanded_by(self.focus_ring.width() as f32); | 455 | let radius = radius.expanded_by(self.focus_ring.width() as f32); |
| 398 | self.focus_ring.update_render_elements( | 456 | self.focus_ring.update_render_elements( |
| 399 | - self.animated_tile_size(), | 457 | + animated_tile_size, |
| 400 | is_active, | 458 | is_active, |
| 401 | !draw_focus_ring_with_background, | 459 | !draw_focus_ring_with_background, |
| 402 | self.window.is_urgent(), | 460 | self.window.is_urgent(), |
| @@ -405,6 +463,8 @@ impl<W: LayoutElement> Tile<W> { | |||
| 405 | self.scale, | 463 | self.scale, |
| 406 | 1., | 464 | 1., |
| 407 | ); | 465 | ); |
| 466 | + | ||
| 467 | + self.fullscreen_backdrop.resize(animated_tile_size); | ||
| 408 | } | 468 | } |
| 409 | 469 | ||
| 410 | pub fn scale(&self) -> f64 { | 470 | pub fn scale(&self) -> f64 { |
| @@ -544,6 +604,20 @@ impl<W: LayoutElement> Tile<W> { | |||
| 544 | self.is_fullscreen | 604 | self.is_fullscreen |
| 545 | } | 605 | } |
| 546 | 606 | ||
| 607 | + fn fullscreen_progress(&self) -> f64 { | ||
| 608 | + if let Some(resize) = &self.resize_animation { | ||
| 609 | + if let Some(anim) = &resize.fullscreen_progress { | ||
| 610 | + return anim.clamped_value().clamp(0., 1.); | ||
| 611 | + } | ||
| 612 | + } | ||
| 613 | + | ||
| 614 | + if self.is_fullscreen { | ||
| 615 | + 1. | ||
| 616 | + } else { | ||
| 617 | + 0. | ||
| 618 | + } | ||
| 619 | + } | ||
| 620 | + | ||
| 547 | /// Returns `None` if the border is hidden and `Some(width)` if it should be shown. | 621 | /// Returns `None` if the border is hidden and `Some(width)` if it should be shown. |
| 548 | pub fn effective_border_width(&self) -> Option<f64> { | 622 | pub fn effective_border_width(&self) -> Option<f64> { |
| 549 | if self.is_fullscreen { | 623 | if self.is_fullscreen { |
| @@ -557,33 +631,47 @@ impl<W: LayoutElement> Tile<W> { | |||
| 557 | Some(self.border.width()) | 631 | Some(self.border.width()) |
| 558 | } | 632 | } |
| 559 | 633 | ||
| 634 | + fn visual_border_width(&self) -> Option<f64> { | ||
| 635 | + if self.border.is_off() { | ||
| 636 | + return None; | ||
| 637 | + } | ||
| 638 | + | ||
| 639 | + let fullscreen_progress = self.fullscreen_progress(); | ||
| 640 | + | ||
| 641 | + // Only hide the border when fully fullscreen to avoid jarring border appearance. | ||
| 642 | + if fullscreen_progress == 1. { | ||
| 643 | + return None; | ||
| 644 | + } | ||
| 645 | + | ||
| 646 | + // FIXME: would be cool to, like, gradually resize the border from full width to 0 during | ||
| 647 | + // fullscreening, but the rest of the code isn't quite ready for that yet. It needs to | ||
| 648 | + // handle things like computing intermediate tile size when an animated resize starts during | ||
| 649 | + // an animated unfullscreen resize. | ||
| 650 | + Some(self.border.width()) | ||
| 651 | + } | ||
| 652 | + | ||
| 560 | /// Returns the location of the window's visual geometry within this Tile. | 653 | /// Returns the location of the window's visual geometry within this Tile. |
| 561 | pub fn window_loc(&self) -> Point<f64, Logical> { | 654 | pub fn window_loc(&self) -> Point<f64, Logical> { |
| 562 | let mut loc = Point::from((0., 0.)); | 655 | let mut loc = Point::from((0., 0.)); |
| 563 | 656 | ||
| 564 | - // In fullscreen, center the window in the given size. | 657 | + let window_size = self.animated_window_size(); |
| 565 | - if self.is_fullscreen { | 658 | + let target_size = self.animated_tile_size(); |
| 566 | - let window_size = self.window_size(); | ||
| 567 | - let target_size = self.view_size; | ||
| 568 | - | ||
| 569 | - // Windows aren't supposed to be larger than the fullscreen size, but in case we get | ||
| 570 | - // one, leave it at the top-left as usual. | ||
| 571 | - if window_size.w < target_size.w { | ||
| 572 | - loc.x += (target_size.w - window_size.w) / 2.; | ||
| 573 | - } | ||
| 574 | - if window_size.h < target_size.h { | ||
| 575 | - loc.y += (target_size.h - window_size.h) / 2.; | ||
| 576 | - } | ||
| 577 | - | ||
| 578 | - // Round to physical pixels. | ||
| 579 | - loc = loc | ||
| 580 | - .to_physical_precise_round(self.scale) | ||
| 581 | - .to_logical(self.scale); | ||
| 582 | - } | ||
| 583 | 659 | ||
| 584 | - if let Some(width) = self.effective_border_width() { | 660 | + // Center the window within its tile. |
| 585 | - loc += (width, width).into(); | 661 | + // |
| 586 | - } | 662 | + // - Without borders, the sizes match, so this difference is zero. |
| 663 | + // - Borders always match from all sides, so this difference is pre-rounded to physical. | ||
| 664 | + // - In fullscreen, if the window is smaller than the tile, then it gets centered, otherwise | ||
| 665 | + // the tile size matches the window. | ||
| 666 | + // - During animations, the window remains centered within the tile; this is important for | ||
| 667 | + // the to/from fullscreen animation. | ||
| 668 | + loc.x += (target_size.w - window_size.w) / 2.; | ||
| 669 | + loc.y += (target_size.h - window_size.h) / 2.; | ||
| 670 | + | ||
| 671 | + // Round to physical pixels. | ||
| 672 | + loc = loc | ||
| 673 | + .to_physical_precise_round(self.scale) | ||
| 674 | + .to_logical(self.scale); | ||
| 587 | 675 | ||
| 588 | loc | 676 | loc |
| 589 | } | 677 | } |
| @@ -661,19 +749,17 @@ impl<W: LayoutElement> Tile<W> { | |||
| 661 | } | 749 | } |
| 662 | 750 | ||
| 663 | pub fn animated_tile_size(&self) -> Size<f64, Logical> { | 751 | pub fn animated_tile_size(&self) -> Size<f64, Logical> { |
| 664 | - let mut size = self.animated_window_size(); | 752 | + let mut size = self.tile_size(); |
| 665 | 753 | ||
| 666 | - if self.is_fullscreen { | 754 | + if let Some(resize) = &self.resize_animation { |
| 667 | - // Normally we'd just return the fullscreen size here, but this makes things a bit | 755 | + let val = resize.anim.value(); |
| 668 | - // nicer if a fullscreen window is bigger than the fullscreen size for some reason. | 756 | + let size_from = resize.tile_size_from.to_f64(); |
| 669 | - size.w = f64::max(size.w, self.view_size.w); | ||
| 670 | - size.h = f64::max(size.h, self.view_size.h); | ||
| 671 | - return size; | ||
| 672 | - } | ||
| 673 | 757 | ||
| 674 | - if let Some(width) = self.effective_border_width() { | 758 | + size.w = f64::max(1., size_from.w + (size.w - size_from.w) * val); |
| 675 | - size.w += width * 2.; | 759 | + size.h = f64::max(1., size_from.h + (size.h - size_from.h) * val); |
| 676 | - size.h += width * 2.; | 760 | + size = size |
| 761 | + .to_physical_precise_round(self.scale) | ||
| 762 | + .to_logical(self.scale); | ||
| 677 | } | 763 | } |
| 678 | 764 | ||
| 679 | size | 765 | size |
| @@ -837,11 +923,16 @@ impl<W: LayoutElement> Tile<W> { | |||
| 837 | let _span = tracy_client::span!("Tile::render_inner"); | 923 | let _span = tracy_client::span!("Tile::render_inner"); |
| 838 | 924 | ||
| 839 | let scale = Scale::from(self.scale); | 925 | let scale = Scale::from(self.scale); |
| 926 | + let fullscreen_progress = self.fullscreen_progress(); | ||
| 840 | 927 | ||
| 841 | - let win_alpha = if self.is_fullscreen || self.window.is_ignoring_opacity_window_rule() { | 928 | + let win_alpha = if self.window.is_ignoring_opacity_window_rule() { |
| 842 | 1. | 929 | 1. |
| 843 | } else { | 930 | } else { |
| 844 | - self.window.rules().opacity.unwrap_or(1.).clamp(0., 1.) | 931 | + let alpha = self.window.rules().opacity.unwrap_or(1.).clamp(0., 1.); |
| 932 | + | ||
| 933 | + // Interpolate towards alpha = 1. at fullscreen. | ||
| 934 | + let p = fullscreen_progress as f32; | ||
| 935 | + alpha * (1. - p) + 1. * p | ||
| 845 | }; | 936 | }; |
| 846 | 937 | ||
| 847 | // This is here rather than in render_offset() because render_offset() is currently assumed | 938 | // This is here rather than in render_offset() because render_offset() is currently assumed |
| @@ -861,8 +952,14 @@ impl<W: LayoutElement> Tile<W> { | |||
| 861 | let area = Rectangle::new(window_render_loc, animated_window_size); | 952 | let area = Rectangle::new(window_render_loc, animated_window_size); |
| 862 | 953 | ||
| 863 | let rules = self.window.rules(); | 954 | let rules = self.window.rules(); |
| 864 | - let clip_to_geometry = !self.is_fullscreen && rules.clip_to_geometry == Some(true); | 955 | + |
| 865 | - let radius = rules.geometry_corner_radius.unwrap_or_default(); | 956 | + // Clip to geometry including during the fullscreen animation to help with buggy clients |
| 957 | + // that submit a full-sized buffer before acking the fullscreen state (Firefox). | ||
| 958 | + let clip_to_geometry = fullscreen_progress < 1. && rules.clip_to_geometry == Some(true); | ||
| 959 | + let radius = rules | ||
| 960 | + .geometry_corner_radius | ||
| 961 | + .unwrap_or_default() | ||
| 962 | + .scaled_by(1. - fullscreen_progress as f32); | ||
| 866 | 963 | ||
| 867 | // If we're resizing, try to render a shader, or a fallback. | 964 | // If we're resizing, try to render a shader, or a fallback. |
| 868 | let mut resize_shader = None; | 965 | let mut resize_shader = None; |
| @@ -956,6 +1053,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 956 | let mut window_surface = None; | 1053 | let mut window_surface = None; |
| 957 | let mut window_popups = None; | 1054 | let mut window_popups = None; |
| 958 | let mut rounded_corner_damage = None; | 1055 | let mut rounded_corner_damage = None; |
| 1056 | + let has_border_shader = BorderRenderElement::has_shader(renderer); | ||
| 959 | if resize_shader.is_none() && resize_fallback.is_none() { | 1057 | if resize_shader.is_none() && resize_fallback.is_none() { |
| 960 | let window = self | 1058 | let window = self |
| 961 | .window | 1059 | .window |
| @@ -965,7 +1063,6 @@ impl<W: LayoutElement> Tile<W> { | |||
| 965 | let radius = radius.fit_to(window_size.w as f32, window_size.h as f32); | 1063 | let radius = radius.fit_to(window_size.w as f32, window_size.h as f32); |
| 966 | 1064 | ||
| 967 | let clip_shader = ClippedSurfaceRenderElement::shader(renderer).cloned(); | 1065 | let clip_shader = ClippedSurfaceRenderElement::shader(renderer).cloned(); |
| 968 | - let has_border_shader = BorderRenderElement::has_shader(renderer); | ||
| 969 | 1066 | ||
| 970 | if clip_to_geometry && clip_shader.is_some() { | 1067 | if clip_to_geometry && clip_shader.is_some() { |
| 971 | let damage = self.rounded_corner_damage.element(); | 1068 | let damage = self.rounded_corner_damage.element(); |
| @@ -1035,18 +1132,50 @@ impl<W: LayoutElement> Tile<W> { | |||
| 1035 | .chain(rounded_corner_damage) | 1132 | .chain(rounded_corner_damage) |
| 1036 | .chain(window_surface.into_iter().flatten()); | 1133 | .chain(window_surface.into_iter().flatten()); |
| 1037 | 1134 | ||
| 1038 | - let elem = self.is_fullscreen.then(|| { | 1135 | + let elem = (fullscreen_progress > 0.).then(|| { |
| 1039 | - SolidColorRenderElement::from_buffer( | 1136 | + let alpha = fullscreen_progress as f32; |
| 1040 | - &self.fullscreen_backdrop, | 1137 | + |
| 1041 | - location, | 1138 | + // During the un/fullscreen animation, render a border element in order to use the |
| 1042 | - 1., | 1139 | + // animated corner radius. |
| 1043 | - Kind::Unspecified, | 1140 | + if fullscreen_progress < 1. && has_border_shader { |
| 1044 | - ) | 1141 | + let border_width = self.visual_border_width().unwrap_or(0.); |
| 1045 | - .into() | 1142 | + let radius = rules |
| 1143 | + .geometry_corner_radius | ||
| 1144 | + .map_or(CornerRadius::default(), |radius| { | ||
| 1145 | + radius.expanded_by(border_width as f32) | ||
| 1146 | + }) | ||
| 1147 | + .scaled_by(1. - fullscreen_progress as f32); | ||
| 1148 | + | ||
| 1149 | + let size = self.fullscreen_backdrop.size(); | ||
| 1150 | + let color = self.fullscreen_backdrop.color(); | ||
| 1151 | + BorderRenderElement::new( | ||
| 1152 | + size, | ||
| 1153 | + Rectangle::from_size(size), | ||
| 1154 | + GradientInterpolation::default(), | ||
| 1155 | + Color::from_color32f(color), | ||
| 1156 | + Color::from_color32f(color), | ||
| 1157 | + 0., | ||
| 1158 | + Rectangle::from_size(size), | ||
| 1159 | + 0., | ||
| 1160 | + radius, | ||
| 1161 | + scale.x as f32, | ||
| 1162 | + alpha, | ||
| 1163 | + ) | ||
| 1164 | + .with_location(location) | ||
| 1165 | + .into() | ||
| 1166 | + } else { | ||
| 1167 | + SolidColorRenderElement::from_buffer( | ||
| 1168 | + &self.fullscreen_backdrop, | ||
| 1169 | + location, | ||
| 1170 | + alpha, | ||
| 1171 | + Kind::Unspecified, | ||
| 1172 | + ) | ||
| 1173 | + .into() | ||
| 1174 | + } | ||
| 1046 | }); | 1175 | }); |
| 1047 | let rv = rv.chain(elem); | 1176 | let rv = rv.chain(elem); |
| 1048 | 1177 | ||
| 1049 | - let elem = self.effective_border_width().map(|width| { | 1178 | + let elem = self.visual_border_width().map(|width| { |
| 1050 | self.border | 1179 | self.border |
| 1051 | .render(renderer, location + Point::from((width, width))) | 1180 | .render(renderer, location + Point::from((width, width))) |
| 1052 | .map(Into::into) | 1181 | .map(Into::into) |
| @@ -1186,7 +1315,6 @@ impl<W: LayoutElement> Tile<W> { | |||
| 1186 | use approx::assert_abs_diff_eq; | 1315 | use approx::assert_abs_diff_eq; |
| 1187 | 1316 | ||
| 1188 | assert_eq!(self.is_fullscreen, self.window.is_fullscreen()); | 1317 | assert_eq!(self.is_fullscreen, self.window.is_fullscreen()); |
| 1189 | - assert_eq!(self.fullscreen_backdrop.size(), self.view_size); | ||
| 1190 | 1318 | ||
| 1191 | let scale = self.scale; | 1319 | let scale = self.scale; |
| 1192 | let size = self.tile_size(); | 1320 | let size = self.tile_size(); |