(windows, x, y0, targetWidth, targetHeights, time)
| 559 | } |
| 560 | |
| 561 | layoutColumnSimple(windows, x, y0, targetWidth, targetHeights, time) { |
| 562 | let space = this; |
| 563 | let y = y0; |
| 564 | |
| 565 | let widthChanged = false; |
| 566 | let heightChanged = false; |
| 567 | |
| 568 | for (let i = 0; i < windows.length; i++) { |
| 569 | let mw = windows[i]; |
| 570 | let targetHeight = targetHeights[i]; |
| 571 | |
| 572 | let f = mw.get_frame_rect(); |
| 573 | |
| 574 | let resizable = !mw.fullscreen && !isMaximized(mw); |
| 575 | |
| 576 | if (mw.preferredWidth) { |
| 577 | let prop = mw.preferredWidth; |
| 578 | if (prop.value <= 0) { |
| 579 | console.warn("invalid preferredWidth value"); |
| 580 | } |
| 581 | else if (prop.unit === 'px') { |
| 582 | targetWidth = prop.value; |
| 583 | } |
| 584 | else if (prop.unit === '%') { |
| 585 | let availableWidth = space.workArea().width - Settings.prefs.horizontal_margin * 2 - Settings.prefs.window_gap; |
| 586 | targetWidth = Math.floor(availableWidth * Math.min(prop.value / 100.0, 1.0)); |
| 587 | } |
| 588 | else { |
| 589 | console.warn("invalid preferredWidth unit:", `'${prop.unit}'`, "(should be 'px' or '%')"); |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | if (resizable) { |
| 594 | const hasNewTarget = mw._targetWidth !== targetWidth || mw._targetHeight !== targetHeight; |
| 595 | const targetReached = f.width === targetWidth && f.height === targetHeight; |
| 596 | |
| 597 | // Update targets (NB: must happen before resize request) |
| 598 | mw._targetWidth = targetWidth; |
| 599 | mw._targetHeight = targetHeight; |
| 600 | |
| 601 | if (!targetReached && hasNewTarget) { |
| 602 | // Explanation for `hasNewTarget` check in commit message |
| 603 | mw.move_resize_frame(true, f.x, f.y, targetWidth, targetHeight); |
| 604 | } |
| 605 | } else { |
| 606 | mw.move_frame(true, space.monitor.x, space.monitor.y); |
| 607 | targetWidth = f.width; |
| 608 | targetHeight = f.height; |
| 609 | } |
| 610 | if (mw.maximized_vertically) { |
| 611 | // NOTE: This should really be f.y - monitor.y, but eg. firefox |
| 612 | // on wayland reports the wrong y coordinates at this point. |
| 613 | y -= Settings.prefs.vertical_margin; |
| 614 | } |
| 615 | |
| 616 | // When resize is synchronous, ie. for X11 windows |
| 617 | let nf = mw.get_frame_rect(); |
| 618 | if (nf.width !== targetWidth && nf.width !== f.width) { |
no test coverage detected