Conversation
A layout can set "aspectRatio" to limit itself to screens with that shape,
written as a ratio ("16:9", "16/9", "16x9" or a number), a comparison
(">16:9", "<=4:3") or an array of either. Screens rarely hit a ratio exactly,
so a match allows 5% either way, adjustable per layout with
"aspectRatioTolerance".
Hidden layouts are skipped when cycling, left out of the zone selector, and
their Activate layout shortcut reports that they are not available. When the
active layout is hidden after moving to another screen, the first available
layout takes over. Layouts without the key show up everywhere, and if no
layout matches the current screen they all stay available.
Screens can also change shape while nothing else is going on, so connect to
screensChanged, screenOrderChanged and virtualScreenSizeChanged on the
workspace, plus geometryChanged and currentModeChanged on every screen. The
client area used to be re-read only at the start of a window drag, which left
the layout list stale after a resolution change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Layouts can now declare which screens they belong on, so a setup with monitors of different shapes does not have to cycle past layouts that make no sense on the current one.
Usage
A layout with an
aspectRatioonly shows up on screens with that shape:[ { "name": "Ultrawide Thirds", "aspectRatio": "21:9", "zones": [] }, { "name": "Wide Enough", "aspectRatio": ">16:9", "zones": [] }, { "name": "Desktop or Laptop", "aspectRatio": ["16:9", "16:10"], "zones": [] } ]The value can be a ratio (
"16:9","16/9","16x9"or a number like1.778), a comparison (">16:9",">=21:9","<16:9","<=4:3"), or an array of either, in which case one match is enough.Screens rarely hit a ratio exactly, so a match allows 5% either way. That covers the usual 21:9 panels (2560x1080 is 2.370, 3440x1440 is 2.389) while still telling 16:9 and 16:10 apart.
aspectRatioToleranceon the layout widens or tightens that.Behaviour
Activate layout Non a hidden layout reports that it is not available on this screen instead of switching to it.aspectRatioshow up everywhere, and if no layout matches the current screen they all stay available, so the selector is never empty.Screens can change shape while nothing else is going on, so the script now listens for that:
screensChanged,screenOrderChangedandvirtualScreenSizeChangedon the workspace, plusgeometryChangedandcurrentModeChangedon every screen, with the per screen signals reconnected whenever the set of screens changes. Until now the client area was only re-read at the start of a window drag, so the layout list stayed stale after a resolution change.Notes
The matching lives in
src/contents/code/aspect.mjsand is free of QML, so it can be exercised on its own. A layout without the new key behaves exactly as before. README andexamples/advanced.jsonare updated, and the QML isqmlformatclean.Verified so far: the matcher against real and simulated screen sizes (exact ratios, comparisons, arrays, numeric values, custom tolerance, unreadable values, cycle order with hidden layouts, and the no-match fallback), both standalone and running inside KWin's QML engine, plus the screen signals connecting on load. Wider testing on a real multi monitor setup is welcome.