MCPcopy
hub / github.com/paperwm/PaperWM / layout

Method layout

tiling.js:649–814  ·  view source on GitHub ↗
(animate = true, options = {})

Source from the content-addressed store, hash-verified

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 }

Callers 15

initMethod · 0.95
queueLayoutMethod · 0.95
removeWindowMethod · 0.95
swapMethod · 0.95
setSettingsMethod · 0.95
setMonitorMethod · 0.95
endMethod · 0.45
marginsGapChangedFunction · 0.45
monitorsChangedMethod · 0.45
resizeHandlerFunction · 0.45
insertWindowFunction · 0.45
focus_handlerFunction · 0.45

Calls 11

startAnimateMethod · 0.95
selectedIndexMethod · 0.95
workAreaMethod · 0.95
layoutGrabColumnMethod · 0.95
layoutColumnSimpleMethod · 0.95
moveDoneMethod · 0.95
getWindowsMethod · 0.95
ensureViewportFunction · 0.85
centerWindowFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected