(animate = true, options = {})
| 647 | } |
| 648 | |
| 649 | layout(animate = true, options = {}) { |
| 650 | // Guard against recursively calling layout |
| 651 | if (!this._populated) |
| 652 | return; |
| 653 | if (this._inLayout) |
| 654 | return; |
| 655 | |
| 656 | // option properties |
| 657 | const ensure = options?.ensure ?? true; |
| 658 | const allocators = options?.customAllocators; |
| 659 | const centerIfOne = options?.centerIfOne ?? true; |
| 660 | const callback = options?.callback; |
| 661 | |
| 662 | this._inLayout = true; |
| 663 | this.startAnimate(); |
| 664 | |
| 665 | let time = Settings.prefs.animation_time; |
| 666 | let gap = Settings.prefs.window_gap; |
| 667 | let x = gap; // init (ensures autostart apps in particular start properly gapped) |
| 668 | let selectedIndex = this.selectedIndex(); |
| 669 | let workArea = this.workArea(); |
| 670 | |
| 671 | // Happens on monitors-changed |
| 672 | if (workArea.width === 0) { |
| 673 | this._inLayout = false; |
| 674 | return; |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * If current window is fullscreened, then treat workarea as fullscreen (y = 0). |
| 679 | * This a "flash of topbar spacing") before consecutive layout call resolves. |
| 680 | */ |
| 681 | const panelBoxHeight = Topbar.panelBox.height; |
| 682 | const primaryMonitor = Main.layoutManager.primaryMonitor; |
| 683 | switch (true) { |
| 684 | case this.selectedWindow?.fullscreen: |
| 685 | workArea.y = 0; |
| 686 | this.setSpaceTopbarElementsVisible(false); |
| 687 | break; |
| 688 | case this.monitor === primaryMonitor: { |
| 689 | if (!this.showTopBar) { |
| 690 | // remove panelbox height |
| 691 | workArea.y -= panelBoxHeight; |
| 692 | workArea.height += panelBoxHeight; |
| 693 | |
| 694 | if (this.showPositionBar) { |
| 695 | // add panelbox height if need to show window position bar |
| 696 | workArea.y += panelBoxHeight; |
| 697 | workArea.height -= panelBoxHeight; |
| 698 | } |
| 699 | } |
| 700 | break; |
| 701 | } |
| 702 | default: |
| 703 | if (this.showPositionBar) { |
| 704 | workArea.y += panelBoxHeight; |
| 705 | workArea.height -= panelBoxHeight; |
| 706 | } |
no test coverage detected