Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ScrollEngine.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include "phosphorscrollengine_export.h"
7
19
20#include <QElapsedTimer>
21#include <QHash>
22#include <QJsonObject>
23#include <QList>
24#include <QObject>
25#include <QPointer>
26#include <QRect>
27#include <QSet>
28#include <QString>
29#include <QStringList>
30#include <QVariantMap>
31#include <QVector>
32
33#include <functional>
34#include <memory>
35#include <optional>
36
37namespace PhosphorEngine {
38class WindowRegistry;
40}
41
42namespace PhosphorScreens {
43class ScreenManager;
44}
45
47
48struct ScrollEvacueePark;
49
85class PHOSPHORSCROLLENGINE_EXPORT ScrollEngine : public PhosphorEngine::PlacementEngineBase
86{
87 Q_OBJECT
88
89public:
91 PhosphorScreens::ScreenManager* screenManager, QObject* parent = nullptr);
92 ~ScrollEngine() override;
93
94 void setWindowRegistry(QObject* registry) override;
95
96 // ═══════════════════════════════════════════════════════════════════════
97 // Screen ownership (derived from layout assignments, daemon-driven)
98 // ═══════════════════════════════════════════════════════════════════════
99
100 bool isActiveOnScreen(const QString& screenId) const override;
101 bool isEnabled() const noexcept override;
102 QSet<QString> activeScreens() const override
103 {
104 return m_scrollingScreens;
105 }
106
116 void setActiveScreens(const QSet<QString>& screens) override;
123 void setActiveScreenHint(const QString& screenId) override;
124
125 // ═══════════════════════════════════════════════════════════════════════
126 // Window lifecycle
127 // ═══════════════════════════════════════════════════════════════════════
128
129 using IPlacementEngine::windowOpened;
130 void windowOpened(const QString& windowId, const QString& screenId, int minWidth, int minHeight) override;
142 bool claimCrossScreenReopen(const QString& windowId, const QString& openingScreenId, int minWidth,
143 int minHeight) override;
144 QString heldScreenForWindow(const QString& windowId) const override;
145 std::optional<PhosphorEngine::PlacementStateKey> heldKeyForWindow(const QString& windowId) const override;
146 // Evacuee park (engine_evacueepark.cpp; IPlacementEngine's contract). Each context is parked as a strip stash
147 // the saves and the leave, aliveness and output sweeps skip; a desktop or activity prune drops it.
148 QStringList parkOutput(const QString& physicalScreenId) override;
149 bool readoptParked(const QString& windowId, const QString& parkedPhysicalId,
150 const QString& returnedPhysicalId) override;
151 void dropParked(const QString& windowId, const QString& physicalScreenId, int desktop,
152 const QString& activity) override;
153 bool hasParked(const QString& windowId, const QString& physicalScreenId) const override;
155 void forceReemit(const QString& screenId);
156 void beginArrivalBurst() override;
157 void endArrivalBurst() override;
158 void noteCrossScreenClaimsExhausted(const QString& windowId, bool exhausted) override;
159 void windowClosed(const QString& windowId) override;
160 void windowFocused(const QString& windowId, const QString& screenId) override;
161 void windowMinSizeUpdated(const QString& windowId, int minWidth, int minHeight) override;
167 QSize windowMinimumSize(const QString& windowId) const override;
168 void onWindowResized(const QString& rawWindowId, const QRect& oldFrame, const QRect& newFrame,
169 const QString& screenId) override;
170
171 // ═══════════════════════════════════════════════════════════════════════
172 // Float management
173 // ═══════════════════════════════════════════════════════════════════════
174
175 void toggleWindowFloat(const QString& windowId, const QString& screenId) override;
177 void setWindowFloat(const QString& windowId, bool shouldFloat, const QString& screenId = QString()) override;
179 bool isWindowFloatingInScroll(const QString& windowId) const;
180 QStringList allFloatingWindows() const;
181 bool isModeSpecificFloated(const QString& windowId) const override;
182 void markModeSpecificFloated(const QString& windowId) override;
183 void clearModeSpecificFloatMarker(const QString& windowId) override;
184
185 // ═══════════════════════════════════════════════════════════════════════
186 // Navigation (IPlacementEngine user intents)
187 // ═══════════════════════════════════════════════════════════════════════
188
189 void focusInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
190 void moveFocusedInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
191 void swapFocusedInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
192 void moveFocusedToPosition(int position, const PhosphorEngine::NavigationContext& ctx) override;
195 void spanFocusedInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
196 void rotateWindows(bool clockwise, const PhosphorEngine::NavigationContext& ctx) override;
199 void cycleFocus(bool forward, const PhosphorEngine::NavigationContext& ctx) override;
204 void switchFocusBetweenFloatingAndTiling(const QString& screenId) override;
205
206private:
209 void toggleFocusedFloatAs(const PhosphorEngine::NavigationContext& ctx, const QString& failureAction);
210
211public:
212 // ═══════════════════════════════════════════════════════════════════════
213 // Scroll-specific vocabulary (concrete type; daemon reaches these via a
214 // mode check + cast, per the IPlacementEngine extension policy)
215 // ═══════════════════════════════════════════════════════════════════════
216
217 void focusColumnFirst(const QString& screenId);
218 void focusColumnLast(const QString& screenId);
219 void moveColumnToFirst(const QString& screenId);
220 void moveColumnToLast(const QString& screenId);
221 void consumeWindowIntoColumn(const QString& screenId);
222 void expelWindowFromColumn(const QString& screenId);
224 void consumeOrExpelWindow(int delta, const QString& screenId);
225 void centerColumn(const QString& screenId);
226 void toggleColumnTabbed(const QString& screenId);
229 void toggleWindowedFullscreen(const QString& screenId);
240 bool setWindowFullscreenFloat(const QString& windowId, bool floating, const QString& screenId);
243 bool isFullscreenFloated(const QString& windowId) const;
250 void forgetClosedFullscreenHold(const QString& windowId);
252 void clearWindowedFullscreen(const QString& windowId);
255 void reapplyWindowGeometry(const QString& windowId);
301 void reportCommittedSize(const QString& windowId, const QSize& offered, const QSize& committed);
303 void cycleColumnPresetWidth(int delta, const QString& screenId);
305 void adjustColumnWidth(qreal deltaPercent, const QString& screenId);
311 bool toggleMaximizeColumn(const QString& screenId, const QString& windowId = QString());
319 bool toggleMaximizeToEdges(const QString& screenId, const QString& windowId = QString());
320 void expandColumnToAvailableWidth(const QString& screenId);
324 void equalizeVisibleColumnWidths(const QString& screenId);
330 void minimizeColumnWidth(const QString& screenId);
342 void resetStripToDefaults(const QString& screenId);
343 void cycleWindowPresetHeight(int delta, const QString& screenId);
344 void adjustWindowHeight(qreal deltaPercent, const QString& screenId);
349 void maximizeWindowHeight(const QString& screenId);
352 void minimizeWindowHeight(const QString& screenId);
357 void expandWindowToAvailableHeight(const QString& screenId);
360 void equalizeWindowHeights(const QString& screenId);
362 void centerVisibleColumns(const QString& screenId);
374 void scrollViewByPercent(qreal percent, const QString& screenId);
386 void scrollViewByPx(int px, const QString& screenId);
394 void focusColumnAtIndex(int index, const QString& screenId);
402 void moveColumnToIndex(int from, int to, const QString& screenId);
405 void focusWindowTop(const QString& screenId);
406 void focusWindowBottom(const QString& screenId);
410 void focusColumnPlain(int delta, const QString& screenId);
413 void focusColumnWrap(int delta, const QString& screenId);
420 void cycleTab(int delta, const QString& screenId);
427 void focusTab(int ordinal, const QString& screenId);
431 void moveFocusedToFloating(const QString& screenId);
432 void moveFocusedToTiling(const QString& screenId);
435 void setColumnWidth(const ColumnWidth& width, const QString& screenId);
436 void setWindowHeight(const WindowHeight& height, const QString& screenId);
437
451 StripAxis stripAxisForScreen(const QString& screenId) const;
452
464 void focusColumnByDelta(int delta, const QString& screenId);
465
466 // ═══════════════════════════════════════════════════════════════════════
467 // State access / ordering / tracking
468 // ═══════════════════════════════════════════════════════════════════════
469
470 PhosphorEngine::IPlacementState* stateForScreen(const QString& screenId) override;
471 const PhosphorEngine::IPlacementState* stateForScreen(const QString& screenId) const override;
474 enum class FocusedColumnRefusal : quint8 {
475 None,
476 NotScrolling,
477 NoColumn,
478 FloatFocused,
479 };
480
503 QStringList focusedColumnWindows(const QString& screenId, FocusedColumnRefusal* reason = nullptr) const;
533 bool stashColumnForDesktopMove(const QString& screenId, const QStringList& windowIds, int targetDesktop);
564 bool stashStripForOutputMove(const QString& sourceStripScreenId, const QString& targetStripScreenId, int desktop,
565 const QStringList& windowIds);
572 TabIndicatorParams tabIndicatorParamsForScreen(const QString& screenId) const;
573 bool isWindowTracked(const QString& windowId) const override;
574 bool isWindowTiled(const QString& windowId) const override;
575 bool isWindowManaged(const QString& windowId) const override;
576 QString screenForTrackedWindow(const QString& windowId) const override;
577 QRect lastManagedRect(const QString& rawWindowId) const override;
578 QStringList managedWindowOrder(const QString& screenId) const override;
617 QVector<VisibleTile> visibleTiles(const QString& screenId) const;
624 QVector<QRect> visibleTileRects(const QString& screenId) const;
632 int visibleTileNumberForWindow(const QString& screenId, const QString& windowId) const;
656 QVector<QRectF> visibleTileRectsRelative(const QString& screenId) const;
657
661
673 ScrollStripSnapshot stripSnapshot(const QString& screenId, const QString& excludeWindowId = QString()) const;
674
684 QVector<VisibleTileWithRect> visibleTilesWithRects(const QString& screenId) const;
685
697 ScrollStripModel stripModelForScreen(const QString& screenId) const;
698
699 void setInitialWindowOrder(const QString& screenId, const QStringList& windowIds) override;
700 QString managedFocusedWindow(const QString& screenId) const override;
703 int stickyPinnedDesktopForScreen(const QString& screenId) const override
704 {
705 return m_context.stickyPinnedDesktop(screenId);
706 }
707 void setInitialFocusedWindow(const QString& screenId, const QString& windowId) override;
708 int pruneStaleWindows(const QSet<QString>& aliveWindowIds) override;
709
710 // Layout capability (see IPlacementEngine's Layout capability section)
721 {
723 }
724
729 bool providesDragInsertSelector() const override
730 {
731 return true;
732 }
733
740 QList<qreal> effectivePresetColumnWidths(const QString& screenId) const;
741 QList<qreal> effectivePresetWindowHeights(const QString& screenId) const;
742
754
755 // ═══════════════════════════════════════════════════════════════════════
756 // Cross-engine handoff
757 // ═══════════════════════════════════════════════════════════════════════
758
759 QString engineId() const override
760 {
762 }
763 void handoffReceive(const HandoffContext& ctx) override;
764 void handoffRelease(const QString& windowId) override;
773 QString entryWindowForCrossing(const QString& screenId, const QString& direction) const;
777 int columnIndexForWindow(const QString& screenId, const QString& windowId) const;
802 QStringList windowsBeyondFocusScrollLimit(const QString& screenId, int maxScrollPercent) const;
803
804 // ═══════════════════════════════════════════════════════════════════════
805 // Drag-insert (trigger-held window drag re-inserts into the strip)
806 //
807 // DETACH-ONCE architecture, deliberately unlike autotile's live-
808 // restructure preview: begin detaches the window from the strip (one
809 // settle, neighbours close up), update only remembers the hit-tested
810 // drop target against the now-stable strip, and commit applies the
811 // structure once at drop. A strip cannot restructure per tick the way
812 // a fixed zone grid can — it slides the layout under the cursor (see
813 // drag_preview.cpp's header for the full rationale). Restoration state
814 // is captured in FloatRestore vocabulary (column + tile + stack anchor
815 // + width/display/height intents) — the strip has no raw-order index
816 // for cancel to restore by. All in drag_preview.cpp.
817 // ═══════════════════════════════════════════════════════════════════════
818
819 bool hasDragInsertPreview() const override
820 {
821 return m_dragInsertPreview.has_value();
822 }
823 QString dragInsertPreviewScreenId() const override
824 {
825 return m_dragInsertPreview ? m_dragInsertPreview->targetScreenId : QString();
826 }
827
830 QString dragInsertPreviewPriorScreenId() const override
831 {
832 return m_dragInsertPreview && m_dragInsertPreview->hadPriorState ? m_dragInsertPreview->priorKey.screenId
833 : QString();
834 }
835
838 {
839 return m_dragInsertPreview ? m_dragInsertPreview->windowId : QString();
840 }
841 bool beginDragInsertPreview(const QString& rawWindowId, const QString& screenId) override;
842 void commitDragInsertPreview() override;
845 void setDragInsertClientSize(const QSize& size) override;
850 void cancelDragInsertPreview(bool dragStillActive = false) override;
869 DragInsertTarget computeDragInsertTargetAtPoint(const QString& screenId, const QPoint& cursorPos) const override;
870 void updateDragInsertPreview(const DragInsertTarget& target) override;
876 bool dragAutoScrollTick(const QString& screenId, const QPoint& cursorPos, qreal dtSeconds) override;
877 bool dragAutoScrollActive() const override;
886 void cancelDragAutoScroll() override;
898 QRect dragInsertIndicatorRect(const QString& screenId) const override;
911 void setInteractiveDragWindow(const QString& windowId) override;
912
913 // ═══════════════════════════════════════════════════════════════════════
914 // Desktop / activity context
915 // ═══════════════════════════════════════════════════════════════════════
916
918 {
919 m_crossSurfaceResolver = resolver;
920 }
921 void setCurrentDesktop(int desktop) override;
922 void setCurrentDesktopForScreen(const QString& screenId, int desktop) override;
923 void clearCurrentDesktopForScreen(const QString& screenId) override;
924 void setCurrentActivity(const QString& activity) override;
941 reconcileDesktopMemberships(const QString& screenId, const PhosphorEngine::DesktopSpanQuery& spanOf) override;
943 reconcileWindowMemberships(const QString& windowId, const PhosphorEngine::DesktopSpanQuery& spanOf) override;
944 QSet<int> desktopsWithActiveState() const override;
945 void pruneStatesForDesktop(int removedDesktop) override;
946 void renumberDesktopsAfterRemoval(int removedDesktop) override;
947 void remapDesktops(const PhosphorEngine::DesktopRemap& remap) override; // engine_desktopremap.cpp
948 void pruneStatesForActivities(const QStringList& validActivities) override;
949 void pruneStatesForRemovedScreen(const QString& physicalScreenId) override;
951 void releaseWindowOffScreen(const QString& windowId, const QString& keepScreenId) override;
952
953 // ═══════════════════════════════════════════════════════════════════════
954 // Persistence + settings
955 // ═══════════════════════════════════════════════════════════════════════
956
957 void saveState() override;
958 void loadState() override;
959 void setPersistenceDelegate(std::function<void()> saveFn, std::function<void()> loadFn)
960 {
961 m_persistSaveFn = std::move(saveFn);
962 m_persistLoadFn = std::move(loadFn);
963 }
964
972 QJsonObject serializeStripState() const;
977 void restoreStripState(const QJsonObject& state);
998 {
999 m_fuzzyClaimGraceMs = graceMs;
1000 }
1001 std::optional<PhosphorEngine::WindowPlacement> capturePlacement(const QString& windowId) const override;
1003 void retile(const QString& screenId = QString()) override;
1004 void scheduleRetileForScreen(const QString& screenId) override;
1005
1014 using FloatPredicate = std::function<bool(const QString& windowId, const QString& screenId)>;
1016 {
1017 m_floatPredicate = std::move(predicate);
1018 }
1019
1027 using RestorePositionPredicate = std::function<bool(const QString& windowId)>;
1029 {
1030 m_restorePositionPredicate = std::move(predicate);
1031 }
1032
1039 using OpenParamsResolver = std::function<ScrollOpenParams(const QString& windowId, const QString& screenId)>;
1041 {
1042 m_openParamsResolver = std::move(resolver);
1043 }
1044
1051 using ModeResolver = std::function<bool(const QString& screenId, int desktop, const QString& activity)>;
1052
1058 {
1059 m_snappingModeResolver = std::move(resolver);
1060 }
1061
1068 {
1069 m_scrollingModeResolver = std::move(resolver);
1070 }
1071
1075 {
1076 m_autotileModeResolver = std::move(resolver);
1077 }
1078
1093 std::function<QVariantMap(const QString& screenId, int desktop, const QString& activity)>;
1102 void setScreenGeometryProviders(std::function<QRect(const QString&)> availableGeometry,
1103 std::function<QRect(const QString&)> screenGeometry)
1104 {
1105 m_availableGeometryProvider = std::move(availableGeometry);
1106 m_screenGeometryProvider = std::move(screenGeometry);
1107 }
1108
1112 void setAllScreenGeometriesProvider(std::function<QList<QRect>()> allScreenGeometries)
1113 {
1114 m_allScreenGeometriesProvider = std::move(allScreenGeometries);
1115 }
1116
1118 {
1119 m_contextGapProvider = std::move(provider);
1120 }
1121
1122 // Per-CONTEXT overrides layered over the config defaults, one map per
1123 // (screen, desktop, activity) — see the member for why the key is the
1124 // context rather than the screen. Three producer channels the daemon
1125 // merges (rules win): the
1126 // RULE channel (SetScrollDefaultColumnWidth / SetCenterFocusedColumn /
1127 // SetScrollDefaultColumnDisplay / SetScrollInsertPosition /
1128 // SetScrollDefaultWindowHeight / SetScrollStripAxis), the SETTINGS
1129 // channel (the per-monitor New-columns sizing trio pairs and the
1130 // per-monitor StripAxis — the axis SHARES its key across both channels,
1131 // so the daemon's rule-after-seed insert IS the precedence collapse),
1132 // and the TEMPLATE channel (from the
1133 // context's assigned ScrollingTemplate: the presetColumnWidths /
1134 // presetWindowHeights lists, replaced wholesale per list; the
1135 // TemplateColumns seed blueprint that engine_lifecycle consumes at column
1136 // creation; and the beyond-blueprint default width trio and display).
1137 // Key spellings live in ScrollPerScreenKeys (ScrollTypes.h) — the
1138 // accessor comments there are the authoritative key list.
1139 void applyPerScreenConfig(const QString& screenId, const QVariantMap& overrides) override;
1140 void clearPerScreenConfig(const QString& screenId) override;
1141 QVariantMap perScreenOverrides(const QString& screenId) const override
1142 {
1143 return overridesForScreen(screenId);
1144 }
1145
1146Q_SIGNALS:
1154 void windowsTiled(const QString& tileRequestsJson);
1157 void scrollingScreensChanged(const QStringList& screenIds, bool isDesktopSwitch);
1194 void stripContextChanged(const QString& screenId, const QString& epoch, const QString& debugLabel);
1195 void enabledChanged(bool enabled);
1215 void tabStripsChanged(const QString& screenId, const QString& stripsJson);
1216
1217private:
1218 // engine_core.cpp
1219 QString canonicalizeForLookup(const QString& rawWindowId) const;
1222 QString currentAppIdFor(const QString& anyWindowId) const;
1223 PhosphorEngine::PlacementStateKey currentKeyForScreen(const QString& screenId) const
1224 {
1225 return m_context.currentKeyForScreen(screenId);
1226 }
1234 QVariantMap overridesForScreen(const QString& screenId) const
1235 {
1236 return m_perScreenOverrides.value(currentKeyForScreen(screenId));
1237 }
1251 bool announceStripContextIfChanged(const QString& screenId);
1252 ScrollState* stateForKey(const PhosphorEngine::PlacementStateKey& key, bool createIfMissing);
1253 ScrollState* stateForWindow(const QString& canonicalId, PhosphorEngine::PlacementStateKey* outKey = nullptr) const;
1259 QString resolveOperationScreen(const QString& screenId) const;
1262 void clearTabStripsForScreen(const QString& screenId);
1263 // engine_context.cpp
1291 void releaseScreenState(const PhosphorEngine::PlacementStateKey& key, ScrollState* state,
1292 QStringList& releasedWindows);
1300 void forgetReleasedWindowMemories(const QString& windowId);
1304 void recordSurvivingPlacement(const QString& windowId);
1308 std::optional<PhosphorEngine::WindowPlacement>
1309 capturePlacementIn(const QString& windowId, const ScrollState* state,
1310 const PhosphorEngine::PlacementStateKey& key) const;
1317 void dropWindowBookkeeping(const PhosphorEngine::PlacementStateKey& key, const ScrollState* state);
1326 void consumePendingInitialOrder(const QString& screenId, const QString& windowId);
1330 void sweepStatelessScreenBookkeeping(const QSet<QString>& screenIds);
1342 void pruneContextKeyedScreenArms(const std::function<bool(const PhosphorEngine::PlacementStateKey&)>& contextDied);
1343
1362 bool migrateStateKey(const PhosphorEngine::PlacementStateKey& oldKey,
1363 const PhosphorEngine::PlacementStateKey& newKey, QStringList& displacedWindows,
1364 QSet<QString>& displacedScreens);
1365
1371 void finishDisplacedRelease(QStringList& displacedWindows, const QSet<QString>& displacedScreens);
1372 // engine_core.cpp
1390 void stashStripStructure(const PhosphorEngine::PlacementStateKey& key, const ScrollState* state,
1391 std::optional<PhosphorProtocol::ScrollAxis> preResolvedFallbackAxis = std::nullopt);
1399 bool restoreFromStripStash(ScrollState* state, const PhosphorEngine::PlacementStateKey& key,
1400 const QString& windowId, const ScrollLayoutParams& params, int minWidth, int minHeight);
1406 QVector<StashedTile> columnTilesWithHiddenMembers(const ScrollState* state, int columnIndex) const;
1410 StashedStrip& mergeMovedColumnsIntoStash(const PhosphorEngine::PlacementStateKey& destKey,
1411 const QVector<StashedColumn>& columns, bool* fresh);
1415 bool refuseUnderFloatFocus(const ScrollState* state, const QString& action, const QString& screenId);
1418 void sweepStripStash(const std::function<bool(const PhosphorEngine::PlacementStateKey&)>& stale);
1419 // engine_stashleave.cpp
1424 void forgetStashedWindowWhere(const QString& windowId,
1425 const std::function<bool(const PhosphorEngine::PlacementStateKey&)>& left,
1426 bool movedColumnsOnly = false);
1433 void forgetMovedColumnsElsewhere(const QString& windowId, const PhosphorEngine::PlacementStateKey& arrivalKey);
1435 void sweepStripStashForAliveness(const QSet<QString>& aliveWindowIds);
1436 // engine_desktopremap.cpp
1438 void applyDesktopRemap(const PhosphorEngine::DesktopRemap& remap);
1439 // engine_query.cpp
1457 ScrollLayoutParams layoutParamsForScreen(const QString& screenId, int columnCountOverride = -1) const;
1458
1481 enum class UnseenContextOverrides : quint8 {
1482 Defaults,
1483 ScreenCurrent,
1484 };
1485 ScrollLayoutParams layoutParamsForKey(const PhosphorEngine::PlacementStateKey& key, int columnCountOverride = -1,
1486 UnseenContextOverrides unseen = UnseenContextOverrides::Defaults) const;
1487
1491 StripAxis resolveStripAxis(const QRect& workArea) const;
1492
1499 QVector<VisibleTile> visibleTiles(const QString& screenId, const ScrollLayoutParams& params) const;
1500 // engine_apply.cpp
1504 void applyLayout(const QString& screenId, bool focusWindowAfter = false);
1505 // engine_lifecycle.cpp
1527 bool insertOpenedWindow(ScrollState* state, const QString& windowId, const QString& screenId, int minWidthIn,
1528 int minHeightIn, ScrollOpenParams* outOpenParams = nullptr, bool migration = false,
1529 QString* outDisplacedTab = nullptr, bool adoption = false);
1530 // engine_membership.cpp
1532 void installContextResolver();
1534 struct PendingMembership;
1535 void collectMembershipWork(const QString& windowId, const QString& screenId,
1536 const PhosphorEngine::PlacementStateKey& currentKey,
1537 const PhosphorEngine::DesktopSpan& span, bool adoptAllowed,
1538 QList<PendingMembership>& pending) const;
1539 PhosphorEngine::MembershipReconcileResult applyMembershipWork(const QString& screenId,
1540 const PhosphorEngine::PlacementStateKey& currentKey,
1541 const QList<PendingMembership>& pending);
1544 bool adoptIntoContext(const QString& windowId, const PhosphorEngine::PlacementStateKey& key);
1547 void releaseMembership(const QString& windowId, const PhosphorEngine::PlacementStateKey& key);
1552 void dropFromOtherContexts(const QString& windowId, const PhosphorEngine::PlacementStateKey& keepKey);
1556 void swapContextRectMemory(const QString& screenId, const PhosphorEngine::PlacementStateKey& oldKey,
1557 const PhosphorEngine::PlacementStateKey& newKey);
1560 void forgetContextMemo(const PhosphorEngine::PlacementStateKey& key, const QString& windowId);
1561 // engine_float_open.cpp
1563 void seedFloatRestoreForOpen(const QString& windowId, int minWidth, int minHeight);
1565 void finishFloatedOpen(ScrollState* state, const QString& windowId, const QString& screenId, int minWidth,
1566 int minHeight, bool migration, bool oversized, bool placedBefore,
1567 const PhosphorEngine::WindowPlacement* record);
1569 bool restoreFloatRecordForOpen(const QString& windowId, const QString& screenId, const QList<QSize>& managedSizes);
1570 bool emitGatedFloatGeometryRestore(const QString& windowId, const PhosphorEngine::WindowPlacement& record,
1571 const QString& screenId, const QList<QSize>& managedSizes);
1572 void restoreFreeSizeForFloatedOpen(const QString& windowId, const QString& screenId, bool placedBefore,
1573 const QList<QSize>& managedSizes);
1575 QList<QSize> managedSizesOnScreen(const QString& screenId) const;
1577 void consumeStripStashTileForFloat(ScrollState* state, const PhosphorEngine::PlacementStateKey& key,
1578 const QString& windowId);
1579 // engine_float.cpp
1581 enum class FloatAnnounce : quint8 {
1582 Active,
1583 Passive
1584 };
1585 void announceFloat(FloatAnnounce announce, const QString& windowId, bool floating, const QString& screenId);
1586 void setWindowFloatAnnounced(const QString& rawWindowId, bool shouldFloat, const QString& screenId,
1587 FloatAnnounce announce);
1589 void rememberReleasedFullscreenHold(const QString& windowId);
1590 void announceReleasedFullscreenHolds();
1597 void settleReannouncedFullscreenHold(const QString& windowId);
1600 void applyReturnedTile(const PhosphorEngine::PlacementStateKey& key);
1601 bool floatWindowInternal(ScrollState* state, const PhosphorEngine::PlacementStateKey& key, const QString& windowId,
1602 const QString& screenId, FloatAnnounce announce = FloatAnnounce::Active,
1603 bool fullscreenHold = false, bool applyAfter = true);
1604 bool unfloatWindowInternal(ScrollState* state, const QString& windowId, const QString& screenId,
1605 bool applyAfter = true, FloatAnnounce announce = FloatAnnounce::Active);
1606 // engine_navigation.cpp
1617 bool moveActiveWindowAcrossBoundary(ScrollState* state, const QString& screenId, const QString& direction,
1618 bool swap, QString* landingScreen = nullptr);
1621 void adoptAsFloatAfterRefusal(ScrollState* owner, const QString& windowId, const QSize& minSize,
1622 const QString& announceScreen);
1623
1629 bool focusAcrossBoundary(const QString& screenId, const QString& direction, const QString& focusedBefore);
1637 void focusInDirectionResolved(const QString& direction, const PhosphorEngine::NavigationContext& ctx,
1638 const QString& screen, ScrollState* state, const ScrollLayoutParams& params);
1641 void clearSourceFloatFocusAfterCrossing(const QString& sourceScreenId);
1642
1643 // engine_verbs.cpp
1651 void scrollViewResolved(int deltaPx, const QString& screen, ScrollState* state, const ScrollLayoutParams& params,
1652 bool announce);
1653
1654 PhosphorEngine::IWindowTrackingService* m_windowTracker = nullptr;
1655 PhosphorScreens::ScreenManager* m_screenManager = nullptr;
1660 std::function<QRect(const QString&)> m_availableGeometryProvider;
1661 std::function<QRect(const QString&)> m_screenGeometryProvider;
1662 std::function<QList<QRect>()> m_allScreenGeometriesProvider;
1667 QPointer<PhosphorEngine::WindowRegistry> m_windowRegistry;
1668 PhosphorEngine::ICrossSurfaceResolver* m_crossSurfaceResolver = nullptr;
1669
1670 PhosphorEngine::PerScreenStates<ScrollState> m_states;
1671 PhosphorEngine::ScreenContextTracker m_context;
1672 QSet<QString> m_scrollingScreens;
1673 QString m_activeScreen;
1679 QStringList m_pendingSelfActivations;
1680 // engine_apply.cpp
1684 void queueSelfActivation(const QString& windowId);
1686 static constexpr int kMaxPendingSelfActivations = 16;
1706 QHash<QString, qint64> m_pendingSelfActivationQueuedAt;
1707 QElapsedTimer m_selfActivationClock;
1708 static constexpr qint64 kSelfActivationEchoExpiryMs = 1000;
1736 QSet<QString> m_declinedOpenFocus;
1741 int m_arrivalBurstDepth = 0;
1742 QHash<PhosphorEngine::PlacementStateKey, bool> m_burstPendingApplies;
1744 QSet<QString> m_crossScreenClaimsExhausted;
1749 bool m_isDesktopContextSwitch = false;
1788 QSet<QString> m_forceEmitScreens;
1808 QSet<PhosphorEngine::PlacementStateKey> m_pendingFocusEmitContexts;
1815 QHash<QString, QString> m_announcedStripEpoch;
1816
1818 QList<qreal> m_presetColumnWidths{1.0 / 3.0, 0.5, 2.0 / 3.0, 0.75, 1.0};
1819 QList<qreal> m_presetWindowHeights{1.0 / 3.0, 0.5, 2.0 / 3.0, 0.75, 1.0};
1820 CenterFocusedColumn m_centerFocusedColumn = CenterFocusedColumn::Never;
1824 int m_stripAxis = 0;
1825 bool m_alwaysCenterSingleColumn = false;
1830 bool m_cropStraddlers = false;
1842 ColumnWidth m_defaultColumnWidth = ColumnWidth::makeProportion(0.5);
1847 bool m_defaultWidthClientDecides = false;
1848 ColumnDisplay m_defaultColumnDisplay = ColumnDisplay::Normal;
1851 TabIndicatorParams m_tabIndicator{};
1856 bool m_respectMinimumSize = true;
1857 bool m_centerShortColumns = false;
1866 bool m_smartGaps = false;
1868 WindowHeight m_defaultWindowHeight{};
1873 bool m_defaultHeightClientDecides = false;
1876 ScrollInsertPosition m_insertPosition = ScrollInsertPosition::RightOfActive;
1877
1889 QHash<QString, QRect> m_lastAppliedRect;
1901 QSet<QString> m_lastAppliedWindowedFs;
1910 QSet<QString> m_lastAppliedMaximizedToEdges;
1921 QHash<QString, QString> m_parkedScrollEdge;
1929 QHash<PhosphorEngine::PlacementStateKey, QHash<QString, QRect>> m_contextRectMemory;
1930 QHash<PhosphorEngine::PlacementStateKey, QHash<QString, QString>> m_contextParkedEdge;
1935 QHash<QString, FloatRestore> m_floatRestore;
1937 QStringList m_releasedFullscreenHolds;
1940 QSet<QString> m_closedFullscreenHolds;
1952 std::optional<DragInsertPreview> m_dragInsertPreview;
1956 QString m_interactiveDragWindow;
1957 // drag_preview.cpp
1960 static FloatRestore captureDragSlot(const ScrollStrip& strip, const QString& windowId);
1967 bool dragPreviewRestoreSlot(ScrollState* state, const QString& windowId, const FloatRestore& slot,
1968 const ScrollLayoutParams& params, const QString& screenId);
1974 static void restoreTabbedHeightOwner(ScrollStrip& strip, const QString& windowId, const FloatRestore& slot);
1983 std::optional<QSize> dragDropClientSize(const DragInsertPreview& preview) const;
1991 FloatRestore dragDropIntents(const DragInsertPreview& preview, const std::optional<QSize>& clientSize,
1992 const ScrollLayoutParams& params) const;
1997 void dropClosedWindowFromDragPreview(const QString& windowId);
1998 // drag_autoscroll.cpp
2008 bool writeDragAutoScrollTarget(const ScrollState& state, const ScrollLayoutParams& params, int direction,
2009 const QPoint& cursorPos);
2014 bool repairDragAutoScrollTarget(const QPoint& cursorPos);
2016 QSet<QString> m_scrollFloatedWindows;
2022 QHash<QString, QStringList> m_pendingInitialOrder;
2026 QHash<QString, QSet<QString>> m_consumedInitialOrder;
2034 QHash<QString, QString> m_pendingInitialFocus;
2035 // engine_core.cpp
2047 StashedStrip
2048 buildStashFromState(const ScrollState* state,
2049 std::optional<PhosphorProtocol::ScrollAxis> preResolvedFallbackAxis = std::nullopt) const;
2055 QHash<PhosphorEngine::PlacementStateKey, StashedStrip> m_stripStash;
2056 QHash<PhosphorEngine::PlacementStateKey, QSet<QString>> m_stripStashConsumed;
2062 qint64 m_fuzzyClaimGraceMs;
2064 quint64 m_stashSequence = 0;
2066 quint64 m_floatLeaveSequence = 0;
2068 QSet<QString> m_pendingRetiles;
2071 QSet<QString> m_screensWithTabStrips;
2075 QHash<QString, QString> m_lastTabStripPayload;
2076
2077 // engine_overrides.cpp
2084 CenterFocusedColumn effectiveCenterFocusedColumn(const QString& screenId) const;
2085 CenterFocusedColumn effectiveCenterFocusedColumn(const QVariantMap& overrides) const;
2099 bool effectiveAlwaysCenterSingleColumn(const QVariantMap& overrides) const;
2100 bool effectiveCenterShortColumns(const QVariantMap& overrides) const;
2101 bool effectiveRespectMinimumSize(const QVariantMap& overrides) const;
2102 bool effectiveSmartGaps(const QVariantMap& overrides) const;
2106 bool effectiveCropStraddlers(const QVariantMap& overrides) const;
2112 bool effectiveFocusNewWindows(const QString& screenId) const;
2113 // engine_grouping.cpp
2118 bool groupSameAppAsTabs() const;
2129 int tabGroupColumnIndex(const ScrollStrip& strip, const std::function<bool(const QString&)>& inGroup) const;
2139 struct GroupedOpenHost
2140 {
2141 int columnIdx = -1;
2142 bool named = false;
2143 };
2144 GroupedOpenHost groupedOpenHost(const ScrollStrip& strip, const QString& windowId, const QString& appId,
2145 const QString& screenId, const ScrollOpenParams& openParams) const;
2152 bool insertGroupedOpen(ScrollState* state, const QString& windowId, const QString& appId, const QString& screenId,
2153 const ScrollLayoutParams& params, int minWidth, int minHeight,
2154 const ScrollOpenParams& openParams, QString* outDisplacedTab, bool* outNamed);
2155 // engine_overrides.cpp
2156 PhosphorEngine::StickyWindowHandling effectiveStickyWindowHandling(const QString& screenId) const;
2157 PhosphorEngine::StickyWindowHandling effectiveStickyWindowHandling(const QVariantMap& overrides) const;
2162 static bool effectiveBoolOverride(const QVariantMap& overrides, const QString& key, bool fallback);
2163 ColumnWidth effectiveDefaultColumnWidth(const QString& screenId) const;
2164 ColumnWidth effectiveDefaultColumnWidth(const QVariantMap& overrides) const;
2171 ColumnWidth effectiveDefaultColumnWidth(const QVariantMap& overrides, const QList<qreal>& presetWidths) const;
2179 static std::optional<qreal> ruleColumnWidthFraction(const QVariantMap& overrides);
2187 bool effectiveWidthClientDecides(const QVariantMap& overrides) const;
2196 std::optional<ColumnWidth> resetDefaultColumnWidthFor(const QVariantMap& overrides,
2197 const ScrollLayoutParams& params) const;
2198 ColumnDisplay effectiveDefaultColumnDisplay(const QString& screenId) const;
2199 ColumnDisplay effectiveDefaultColumnDisplay(const QVariantMap& overrides) const;
2207 WindowHeight effectiveDefaultWindowHeight(const QString& screenId, const QRect& workArea, StripAxis axis) const;
2208 WindowHeight effectiveDefaultWindowHeight(const QVariantMap& overrides, const QRect& workArea,
2209 StripAxis axis) const;
2211 WindowHeight effectiveDefaultWindowHeight(const QVariantMap& overrides, const QRect& workArea, StripAxis axis,
2212 const QList<qreal>& presetHeights) const;
2219 static std::optional<qreal> ruleWindowHeightFraction(const QVariantMap& overrides);
2224 bool effectiveHeightClientDecides(const QVariantMap& overrides) const;
2249 bool commitClientDecidedHeight(ScrollStrip& strip, const QString& windowId, const QString& screenId,
2250 const QVariantMap& overrides, const ScrollLayoutParams& params,
2251 std::optional<QSize> clientSize = std::nullopt) const;
2262 static ColumnWidth clientDecidedColumnWidth(const QSize& clientSize, const ScrollLayoutParams& params,
2263 ColumnDisplay display);
2273 std::optional<QSize> clientSizeForDecidedWidth(const QString& windowId, const QString& screenId,
2274 const QVariantMap& overrides) const;
2280 std::optional<WindowHeight> resetDefaultWindowHeightFor(const QVariantMap& overrides) const;
2281 ScrollInsertPosition effectiveInsertPosition(const QString& screenId) const;
2282 ScrollInsertPosition effectiveInsertPosition(const QVariantMap& overrides) const;
2285 TabIndicatorParams effectiveTabIndicator(const QString& screenId) const;
2286 TabIndicatorParams effectiveTabIndicator(const QVariantMap& overrides) const;
2289 QList<qreal> effectivePresetColumnWidths(const QVariantMap& overrides) const;
2290 QList<qreal> effectivePresetWindowHeights(const QVariantMap& overrides) const;
2293 StripAxis effectiveStripAxis(const QVariantMap& overrides, const QRect& workArea) const;
2294
2316 QHash<PhosphorEngine::PlacementStateKey, QVariantMap> m_perScreenOverrides;
2317 std::function<void()> m_persistSaveFn;
2318 std::function<void()> m_persistLoadFn;
2319 FloatPredicate m_floatPredicate;
2320 RestorePositionPredicate m_restorePositionPredicate{};
2321 OpenParamsResolver m_openParamsResolver;
2322 ModeResolver m_snappingModeResolver;
2323 ModeResolver m_scrollingModeResolver;
2324 ModeResolver m_autotileModeResolver;
2325 ContextGapProvider m_contextGapProvider;
2326
2327 // engine_evacueepark.cpp
2329 bool isEvacueeParkedKey(const PhosphorEngine::PlacementStateKey& key) const;
2330 // Appended last (installed header). Created by the first parkOutput.
2331 std::unique_ptr<ScrollEvacueePark> m_evacueePark;
2332
2333 // engine_committed.cpp: the extents clients' own commits taught (reportCommittedSize).
2335 QSize committedFloorFor(const QString& windowId) const;
2338 int committedCrossFloorFor(const QString& windowId, const StripAxis& axis) const;
2341 int committedPeekPx(const QString& windowId, const StripAxis& axis) const;
2344 void forgetCommittedExtents(const QString& windowId);
2347 bool dropCommittedForUserResize(const QString& windowId, const StripAxis& axis);
2350 bool dropCommittedCrossForUserResize(const QString& windowId, const StripAxis& axis);
2355 void dropCommittedForLoweredMinimum(const QString& windowId, const QSize& oldMin, const QSize& newMin);
2369 bool settleCommittedFloors(ScrollState& state, const PhosphorEngine::PlacementStateKey& key,
2370 const ScrollLayoutParams& params);
2373 bool settleCommittedCrossFloor(const ScrollStrip& strip, const PhosphorEngine::PlacementStateKey& key,
2374 const ScrollLayoutParams& params, const QString& windowId,
2375 CommittedCrossExtent& cross) const;
2393 void endStalePeeks(const ScrollStrip& strip, const ResolvedStrip& resolved,
2394 const PhosphorEngine::PlacementStateKey& key, const ScrollLayoutParams& params,
2395 const QRect& screenRect, int parkTop);
2398 enum class OfferAxis : quint8 {
2399 Main,
2400 Cross
2401 };
2407 bool everyOtherColumnOffers(const QString& windowId, const PhosphorEngine::PlacementStateKey& key,
2408 const StripAxis& axis, const std::function<bool(int)>& accepts,
2409 OfferAxis offerAxis = OfferAxis::Main) const;
2413 static ScrollLayoutParams withoutCommittedFloorOf(const ScrollLayoutParams& params, const QString& windowId);
2420 bool outgrowsWorkArea(const ScrollState& state, const QString& windowId, const ScrollLayoutParams& params) const;
2425 bool floatIfOutgrowsWorkArea(ScrollState* state, const PhosphorEngine::PlacementStateKey& key,
2426 const QString& windowId, const char* reason, bool applyAfter = true);
2427
2440 QHash<QString, CommittedExtent> m_committedExtents;
2441};
2442
2443} // namespace PhosphorScrollEngine
How KWin's desktop positions moved in one change of its desktop list: for each 1-based position in th...
Definition DesktopRemap.h:29
Resolves the neighbouring surface — output or virtual desktop — in a direction, for cross-surface win...
Definition ICrossSurfaceResolver.h:21
LayoutSupport
How this engine relates to user-selectable layouts — the entries the layout picker,...
Definition IPlacementEngine.h:955
@ Templates
The engine consumes a first-class TEMPLATE object rather than a placement layout.
Definition IPlacementEngine.h:972
Per-screen placement state contract.
Definition IPlacementState.h:28
static constexpr int kDragScrollTriggerWidthDefault
Definition IScrollSettings.h:141
static constexpr int kDragScrollDelayMsDefault
Definition IScrollSettings.h:142
static constexpr int kDragScrollMaxSpeedDefault
Definition IScrollSettings.h:143
static constexpr bool kDragScrollEnabledDefault
Definition IScrollSettings.h:140
Definition IWindowTrackingService.h:35
Abstract base class for placement engines.
Definition PlacementEngineBase.h:36
Definition WindowRegistry.h:113
Centralized screen-topology service.
Definition Manager.h:86
void clearCurrentDesktopForScreen(const QString &screenId) override
Drop a screen's per-output desktop, reverting it to the global current.
void setInitialWindowOrder(const QString &screenId, const QStringList &windowIds) override
void setCurrentDesktop(int desktop) override
std::function< bool(const QString &windowId, const QString &screenId)> FloatPredicate
Predicate deciding whether an opening window should start FLOATING because a "Float this app" rule ma...
Definition ScrollEngine.h:1014
QVector< QRect > visibleTileRects(const QString &screenId) const
The rects of visibleTiles — the plain absolute-pixel projection, in the same order.
bool isWindowManaged(const QString &windowId) const override
Whether the engine considers the window "managed" (eligible for layout operations).
void pruneStatesForRemovedScreen(const QString &physicalScreenId) override
Prune per-(screen, desktop, activity) state for a PHYSICALLY REMOVED output (monitor hot-unplug),...
void setInteractiveDragWindow(const QString &windowId) override
While set, applyLayout never emits this window's rect, onWindowResized never reconciles its acks,...
QString managedFocusedWindow(const QString &screenId) const override
The window this engine considers focused on screenId, or empty.
QStringList managedWindowOrder(const QString &screenId) const override
void reportCommittedSize(const QString &windowId, const QSize &offered, const QSize &committed)
Compositor-driven: the size a client settled on when offered its tile rect, reported when it is not t...
void tabStripsChanged(const QString &screenId, const QString &stripsJson)
Tab-indicator model for screenId, emitted when the resolved model changes (a relayout that produces a...
QRect lastManagedRect(const QString &rawWindowId) const override
The exact rect this engine last APPLIED to windowId while managing it (its tile rect),...
QVector< VisibleTileWithRect > visibleTilesWithRects(const QString &screenId) const
visibleTiles and visibleTileRectsRelative in a single resolve.
void cycleColumnPresetWidth(int delta, const QString &screenId)
delta -1/+1 through the preset width list.
void setCurrentDesktopForScreen(const QString &screenId, int desktop) override
Set a single screen's current virtual desktop (Plasma 6.7 "switch desktopsindependently for each scre...
void reapplyWindowGeometry(const QString &windowId)
Compositor-driven repair: the compositor moved this window behind the engine's back (KWin's fullscree...
int columnIndexForWindow(const QString &screenId, const QString &windowId) const
The column index windowId's column holds on screenId (current context), or -1 — the landing-slot refe...
void reapplyLayout(const PhosphorEngine::NavigationContext &ctx) override
Re-apply the current layout to all managed windows.
void focusColumnWrap(int delta, const QString &screenId)
Adjacent-column focus that wraps to the far end at the strip edge (niri focus-column-left-or-last / r...
void centerColumn(const QString &screenId)
void resetStripToDefaults(const QString &screenId)
Every column on the screen back to the context's default width and display, every window back to the ...
void centerVisibleColumns(const QString &screenId)
Center the span of fully visible columns (niri center-visible-columns).
void forgetClosedFullscreenHold(const QString &windowId)
Drop the closed-mid-hold memory once the daemon's close capture has read it, or a live release left n...
void setWindowHeight(const WindowHeight &height, const QString &screenId)
int visibleTileNumberForWindow(const QString &screenId, const QString &windowId) const
windowId's zone number on screenId's current strip, or -1 when it is off-screen, a hidden tab,...
void setRestorePositionPredicate(RestorePositionPredicate predicate)
Definition ScrollEngine.h:1028
QRect dragInsertIndicatorRect(const QString &screenId) const override
The rect the dragged window would occupy if it were dropped at the currently remembered target — the ...
void consumeOrExpelWindow(int delta, const QString &screenId)
delta -1 = towards the strip's start, +1 = towards its end (niri consume-or-expel-window-left/right).
bool claimCrossScreenReopen(const QString &windowId, const QString &openingScreenId, int minWidth, int minHeight) override
The reopen claim (see IPlacementEngine for the contract): only a FIFO record on another virtual scree...
void scrollingScreensChanged(const QStringList &screenIds, bool isDesktopSwitch)
Scrolling twin of autotileScreensChanged, with the same identical-set re-emit contract on desktop/act...
void scrollViewByPercent(qreal percent, const QString &screenId)
Scroll the view along the strip by percent of the work area's MAIN extent WITHOUT changing focus (Kar...
void forceReemit(const QString &screenId)
Retile screenId with its next layout forced to emit: the daemon re-asserting a strip KWin moved.
void setDragInsertClientSize(const QSize &size) override
Stores size on the live preview for commit's "the client decides" sizing of a window dragged in off a...
bool hasParked(const QString &windowId, const QString &physicalScreenId) const override
Whether windowId has a context parked under physicalScreenId (any output when it is empty).
void releaseWindowOffScreen(const QString &windowId, const QString &keepScreenId) override
The base release, plus the stashed columns the window holds on any other screen (engine_stashleave....
void setOpenParamsResolver(OpenParamsResolver resolver)
Definition ScrollEngine.h:1040
std::function< ScrollOpenParams(const QString &windowId, const QString &screenId)> OpenParamsResolver
Resolver for the per-window open-behaviour rule overrides.
Definition ScrollEngine.h:1039
void setAutotileModeResolver(ModeResolver resolver)
INERT, kept for ABI: an autotile-mode resolver that fed the same removed defer gate.
Definition ScrollEngine.h:1074
void applyPerScreenConfig(const QString &screenId, const QVariantMap &overrides) override
void moveFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Move the focused window to the adjacent slot.
void setPersistenceDelegate(std::function< void()> saveFn, std::function< void()> loadFn)
Definition ScrollEngine.h:959
void windowFocused(const QString &windowId, const QString &screenId) override
A window gained focus (called when the compositor reports activation).
void remapDesktops(const PhosphorEngine::DesktopRemap &remap) override
OPTIONAL: KWin's desktop list changed (a removal, an insert or a reorder).
void moveColumnToLast(const QString &screenId)
void windowsTiled(const QString &tileRequestsJson)
Batch of absolute pixel rects for the KWin effect, same JSON contract as AutotileEngine::windowsTiled...
void clearModeSpecificFloatMarker(const QString &windowId) override
QJsonObject serializeStripState() const
Durable strip-structure snapshot: every LIVE strip (current states) plus the un-consumed mode-round-t...
void windowClosed(const QString &windowId) override
A window was closed.
std::function< bool(const QString &screenId, int desktop, const QString &activity)> ModeResolver
Context-mode resolver shape shared by the three injected closures below: invoked as (screenId,...
Definition ScrollEngine.h:1051
const PhosphorEngine::IPlacementState * stateForScreen(const QString &screenId) const override
void equalizeWindowHeights(const QString &screenId)
An equal share of the focused column for each of its windows (the height twin of equalizeVisibleColum...
void cancelDragInsertPreview(bool dragStillActive=false) override
dragStillActive carries the base-interface contract and is deliberately unused here (see the definiti...
void minimizeColumnWidth(const QString &screenId)
The focused column at the smallest preset (Karousel minimize-width).
void focusColumnLast(const QString &screenId)
std::optional< PhosphorEngine::PlacementStateKey > heldKeyForWindow(const QString &windowId) const override
The (screen, desktop, activity) key of the state that genuinely holds windowId, tiled or floating,...
DragInsertTarget computeDragInsertTargetAtPoint(const QString &screenId, const QPoint &cursorPos) const override
primary = column index; newSlot true opens a NEW column at primary; otherwise the window joins column...
void cycleTab(int delta, const QString &screenId)
Cycle the active column's tabs, wrapping at either end.
QStringList windowsBeyondFocusScrollLimit(const QString &screenId, int maxScrollPercent) const
The windows on screenId that focus-follows-mouse must REFUSE to focus under a cap of maxScrollPercent...
QVariantMap perScreenOverrides(const QString &screenId) const override
Definition ScrollEngine.h:1141
ScrollEngine(PhosphorEngine::IWindowTrackingService *windowTracker, PhosphorScreens::ScreenManager *screenManager, QObject *parent=nullptr)
void moveColumnToFirst(const QString &screenId)
QVector< QRectF > visibleTileRectsRelative(const QString &screenId) const
visibleTileRects normalized to the FULL screen geometry (0.0–1.0 per axis) — the shape zone previews ...
void setScrollingModeResolver(ModeResolver resolver)
Scrolling-mode resolver: whether a context runs Scrolling as the daemon resolves it (feature switch a...
Definition ScrollEngine.h:1067
QString screenForTrackedWindow(const QString &windowId) const override
Return the screen this engine considers the window to be on (any context), or empty if the window isn...
void restoreStripState(const QJsonObject &state)
Load a serializeStripState blob into the stash so the EXISTING arrival-restore path (restoreFromStrip...
void focusWindowTop(const QString &screenId)
First/last non-minimized tile of the active column (niri focus-window-top/bottom).
QString entryWindowForCrossing(const QString &screenId, const QString &direction) const
Cross-mode swap support (queried by the daemon when THIS engine is the swap target): the strip window...
QString engineId() const override
Stable engine identity for HandoffContext.fromEngineId.
Definition ScrollEngine.h:759
bool beginDragInsertPreview(const QString &rawWindowId, const QString &screenId) override
void pruneStatesForActivities(const QStringList &validActivities) override
PhosphorEngine::MembershipReconcileResult reconcileWindowMemberships(const QString &windowId, const PhosphorEngine::DesktopSpanQuery &spanOf) override
The same pass for ONE window, on the screen it is held on.
int pruneStaleWindows(const QSet< QString > &aliveWindowIds) override
Drop any per-engine bookkeeping for windows not in aliveWindowIds.
bool isWindowFloatingInScroll(const QString &windowId) const
Authoritative scroll float state (the scroll half of the per-engine float contract the WTS resolver r...
void markModeSpecificFloated(const QString &windowId) override
QStringList focusedColumnWindows(const QString &screenId, FocusedColumnRefusal *reason=nullptr) const
The focused column of screenId's current strip, in tile order, for a verb that relocates the column a...
void swapFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Swap the focused window with the adjacent window.
void windowOpened(const QString &windowId, const QString &screenId, int minWidth, int minHeight) override
A new window appeared on this engine's screen.
void scheduleRetileForScreen(const QString &screenId) override
void setFloatPredicate(FloatPredicate predicate)
Definition ScrollEngine.h:1015
bool stashColumnForDesktopMove(const QString &screenId, const QStringList &windowIds, int targetDesktop)
The column-preserving half of the move-column-to-workspace verb.
void spanFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Zone spanning has no strip analogue; reports a "not_supported" span OSD like AutotileEngine so the sh...
void setInitialFocusedWindow(const QString &screenId, const QString &windowId) override
Hand the incoming engine the focus captured from the outgoing one.
void setWindowRegistry(QObject *registry) override
Attach a window-class registry (QObject carrying WindowRegistry).
bool readoptParked(const QString &windowId, const QString &parkedPhysicalId, const QString &returnedPhysicalId) override
Re-seat windowId's contexts parked under parkedPhysicalId on returnedPhysicalId as a re-statement (no...
ScrollBlueprintProgress blueprintProgressForScreen(const QString &screenId) const
How far this screen's CURRENT context has worked through its template blueprint.
void setColumnWidth(const ColumnWidth &width, const QString &screenId)
Absolute width/height intents (niri set-column-width/set-window-height with an absolute value).
QList< qreal > effectivePresetColumnWidths(const QString &screenId) const
Effective preset vocabulary for a screen: the per-screen TEMPLATE override when the daemon pushed a u...
ScrollStripModel stripModelForScreen(const QString &screenId) const
The whole strip of screenId's current context as a strip MAP reads it (ScrollStripModel): every colum...
bool dragAutoScrollActive() const override
Whether edge auto-scroll currently owns the drop target.
PhosphorEngine::MembershipReconcileResult reconcileDesktopMemberships(const QString &screenId, const PhosphorEngine::DesktopSpanQuery &spanOf) override
Give a window present on several desktops a column in each of their strips, so it can be placed and s...
QVector< VisibleTile > visibleTiles(const QString &screenId) const
The visible tiles of screenId's current-context strip in zone- number order.
TabIndicatorParams tabIndicatorParamsForScreen(const QString &screenId) const
The tab-indicator geometry screenId resolves to: the configured values with any per-screen rule overr...
void moveFocusedToTiling(const QString &screenId)
void focusColumnByDelta(int delta, const QString &screenId)
Focus the previous/next column ALONG THE STRIP, for callers holding a strip-relative intent rather th...
void focusWindowBottom(const QString &screenId)
void renumberDesktopsAfterRemoval(int removedDesktop) override
Shift every per-(screen, desktop, activity) state ABOVE removedDesktop down by one,...
bool isEnabled() const noexcept override
std::optional< PhosphorEngine::WindowPlacement > capturePlacement(const QString &windowId) const override
Report windowId's CURRENT placement for persistence, or nullopt if this engine does not manage it.
void setActiveScreens(const QSet< QString > &screens) override
Set which screens use scrolling.
void moveColumnToIndex(int from, int to, const QString &screenId)
Move the column at strip index from to strip index to (ScrollStrip::moveColumnTo),...
void handoffRelease(const QString &windowId) override
Release ownership of a window WITHOUT modifying its geometry.
bool toggleMaximizeToEdges(const QString &screenId, const QString &windowId=QString())
Toggle a column's maximize-to-edges state (full raw work area on both axes, gap-free; niri maximize-w...
QString dragInsertPreviewScreenId() const override
Definition ScrollEngine.h:823
void clearWindowedFullscreen(const QString &windowId)
Compositor-driven reconciliation: the client left fullscreen on its own.
FocusedColumnRefusal
Why focusedColumnWindows answered empty, so the caller can tell the user which of the distinct situat...
Definition ScrollEngine.h:474
bool isWindowTiled(const QString &windowId) const override
Whether the window is actively tiled (engine-owned, non-floating).
void setCurrentActivity(const QString &activity) override
void scrollViewByPx(int px, const QString &screenId)
The pixel twin of scrollViewByPercent, for a caller that already holds a distance along the strip (th...
void updateStickyScreenPins(const PhosphorEngine::StickyPredicate &, PhosphorEngine::StickyPinPhase) override
Pin screens whose managed windows are ALL sticky to their current desktop, unpinning (and migrating t...
void remapRestoredStripStash(const PhosphorEngine::DesktopRemap &remap)
The start-up renumber when KWin's first desktop list lands after windows did (F1045): only the entrie...
void adjustWindowHeight(qreal deltaPercent, const QString &screenId)
ScrollStripSnapshot stripSnapshot(const QString &screenId, const QString &excludeWindowId=QString()) const
Column-aware strip snapshot for the daemon's strip-mode drag popup.
void retile(const QString &screenId=QString()) override
void moveFocusedToPosition(int position, const PhosphorEngine::NavigationContext &ctx) override
Move the focused window to the Nth position.
QString dragInsertPreviewPriorScreenId() const override
See the base declaration.
Definition ScrollEngine.h:830
void focusColumnPlain(int delta, const QString &screenId)
Plain adjacent-column focus that stops at the strip edge (niri focus-column-left/right).
void clearPerScreenConfig(const QString &screenId) override
std::function< QVariantMap(const QString &screenId, int desktop, const QString &activity)> ContextGapProvider
Per-context (window-rule) gap overrides, resolved daemon-side so this library stays settings-agnostic...
Definition ScrollEngine.h:1092
LayoutSupport layoutSupport() const override
The strip consumes layouts as sizing TEMPLATES, never as window placement: the screen's assigned Scro...
Definition ScrollEngine.h:720
void toggleColumnTabbed(const QString &screenId)
void refreshConfigFromSettings() override
Re-read all tuning values from the engine's settings interface.
void stripContextChanged(const QString &screenId, const QString &epoch, const QString &debugLabel)
The identity of the strip screenId is now showing has changed.
void setSnappingModeResolver(ModeResolver resolver)
INERT, kept for ABI: a snapping-mode resolver that fed windowOpened's cross-screen restore defer gate...
Definition ScrollEngine.h:1057
ScrollVisibleTileWithRect VisibleTileWithRect
A tile paired with its screen-normalized rect, from ONE strip walk.
Definition ScrollEngine.h:660
void rotateWindows(bool clockwise, const PhosphorEngine::NavigationContext &ctx) override
Rotate all managed windows on the screen.
QString dragInsertPreviewWindowId() const
The window id of the active drag-insert preview, or empty (test seam, mirroring AutotileEngine's acce...
Definition ScrollEngine.h:837
void setAllScreenGeometriesProvider(std::function< QList< QRect >()> allScreenGeometries)
The union half of the provider seam: every output's full rect, used only for the parking union's bott...
Definition ScrollEngine.h:1112
void focusColumnFirst(const QString &screenId)
void pushToEmptyZone(const PhosphorEngine::NavigationContext &ctx) override
Move the focused window to the first empty slot.
void minimizeWindowHeight(const QString &screenId)
The focused window at the shortest preset height (the height twin of minimizeColumnWidth).
void updateDragInsertPreview(const DragInsertTarget &target) override
Update the drop target for an active drag-insert preview.
bool isActiveOnScreen(const QString &screenId) const override
Whether this engine is active on the given screen.
void noteCrossScreenClaimsExhausted(const QString &windowId, bool exhausted) override
INERT, kept for ABI: fed the removed cross-screen defer gates.
void setWindowFloat(const QString &windowId, bool shouldFloat, const QString &screenId=QString()) override
Announces Passive (windowFloatingStateSynced, F557); the user float verbs announce Active (F578).
QSize windowMinimumSize(const QString &windowId) const override
The window's declared minimum as a FRAME size (Tile::minWidth), from its strip tile,...
void beginArrivalBurst() override
Bracket a BURST of windowOpened calls delivered together (the adaptor's three dispatch loops: windows...
void focusColumnAtIndex(int index, const QString &screenId)
Focus the column at strip index index (ScrollStrip::focusColumn), re-anchoring the view under the sam...
bool dragAutoScrollTick(const QString &screenId, const QPoint &cursorPos, qreal dtSeconds) override
Edge auto-scroll (drag_autoscroll.cpp).
StripAxis stripAxisForScreen(const QString &screenId) const
Which way screenId's strip runs, resolved live.
void cycleWindowPresetHeight(int delta, const QString &screenId)
bool stashStripForOutputMove(const QString &sourceStripScreenId, const QString &targetStripScreenId, int desktop, const QStringList &windowIds)
The column-preserving half of the move-workspace-to-monitor verb.
void equalizeVisibleColumnWidths(const QString &screenId)
Equal shares of the viewport for every column intersecting it, clipped ones included (Karousel equali...
void moveFocusedToFloating(const QString &screenId)
Explicit float / re-tile of the focused window (niri move-window-to-floating / move-window-to-tiling)...
void expandColumnToAvailableWidth(const QString &screenId)
void consumeWindowIntoColumn(const QString &screenId)
void snapAllWindows(const PhosphorEngine::NavigationContext &ctx) override
Bring every unmanaged window on the screen back under this engine's placement (zones for snap,...
std::function< bool(const QString &windowId)> RestorePositionPredicate
Predicate gating the float-POSITION restore on the floating-reopen branch: the window is marked float...
Definition ScrollEngine.h:1027
void handoffReceive(const HandoffContext &ctx) override
Receive ownership of a window from another engine.
void setActiveScreenHint(const QString &screenId) override
NOTE: activeScreen() is deliberately NOT overridden.
bool providesDragInsertSelector() const override
The strip renders in the daemon's drag popup as column cards speaking the drag-insert vocabulary (new...
Definition ScrollEngine.h:729
void toggleWindowedFullscreen(const QString &screenId)
Windowed fullscreen (niri toggle-windowed-fullscreen) on the active window: layout-neutral per-tile f...
bool toggleMaximizeColumn(const QString &screenId, const QString &windowId=QString())
Toggle the maximized state of a column on screenId.
QStringList parkOutput(const QString &physicalScreenId) override
Copy every context of physicalScreenId (each of its virtual screens) into the park,...
QList< qreal > effectivePresetWindowHeights(const QString &screenId) const
void setScreenGeometryProviders(std::function< QRect(const QString &)> availableGeometry, std::function< QRect(const QString &)> screenGeometry)
Embedder/test seam: inject screen geometry when NO ScreenManager is wired (headless hosts).
Definition ScrollEngine.h:1102
ScrollVisibleTile VisibleTile
The zone-number unit.
Definition ScrollEngine.h:584
int stickyPinnedDesktopForScreen(const QString &screenId) const override
The desktop this engine has pinned this screen to, or 0.
Definition ScrollEngine.h:703
void cancelDragAutoScroll() override
The ONE disarm: hands the drop target back to the ordinary hit-test and restarts the start delay.
QString heldScreenForWindow(const QString &windowId) const override
OPTIONAL: the screen this engine genuinely HOLDS the window on IN THE SCREEN'S CURRENT CONTEXT — a ME...
void expandWindowToAvailableHeight(const QString &screenId)
Grow the focused window into the empty space left in its column (the height twin of expandColumnToAva...
bool isModeSpecificFloated(const QString &windowId) const override
bool hasDragInsertPreview() const override
Definition ScrollEngine.h:819
void pruneStatesForDesktop(int removedDesktop) override
void expelWindowFromColumn(const QString &screenId)
void toggleFocusedFloat(const PhosphorEngine::NavigationContext &ctx) override
Toggle the focused window between managed and floating.
bool setWindowFullscreenFloat(const QString &windowId, bool floating, const QString &screenId)
Compositor-driven: hold a strip tile out for its OWN fullscreen or return it, with a user float's slo...
PhosphorEngine::IPlacementState * stateForScreen(const QString &screenId) override
Per-screen state object for the given screen.
QSet< QString > activeScreens() const override
Definition ScrollEngine.h:102
bool isFullscreenFloated(const QString &windowId) const
True while the slot carries the compositor's hold, and for a window that CLOSED mid-hold until Window...
void maximizeWindowHeight(const QString &screenId)
Toggle the focused window between filling its column and the even split (the height twin of toggleMax...
QStringList allFloatingWindows() const
void toggleWindowFloat(const QString &windowId, const QString &screenId) override
Toggle between managed and floating.
bool isWindowTracked(const QString &windowId) const override
void onWindowResized(const QString &rawWindowId, const QRect &oldFrame, const QRect &newFrame, const QString &screenId) override
Notify the engine that a tracked window finished an interactive resize.
void dropParked(const QString &windowId, const QString &physicalScreenId, int desktop, const QString &activity) override
Forget windowId's parked contexts; an empty physicalScreenId, a desktop of 0 or an empty activity mat...
void setContextGapProvider(ContextGapProvider provider)
Definition ScrollEngine.h:1117
void setCrossSurfaceResolver(PhosphorEngine::ICrossSurfaceResolver *resolver) override
Inject the cross-surface resolver used to find a neighbouring output / desktop when directional navig...
Definition ScrollEngine.h:917
void focusTab(int ordinal, const QString &screenId)
Focus the active column's ordinal'th tab, 1-based, counting the column's non-minimized tiles — which ...
void adjustColumnWidth(qreal deltaPercent, const QString &screenId)
deltaPercent of the work area's MAIN extent (e.g. +10 / -10).
void setFuzzyClaimGraceMsForTesting(qint64 graceMs)
TEST SEAM: shorten (or lengthen) the cross-session fuzzy-claim grace window — the period after a stas...
Definition ScrollEngine.h:997
void switchFocusBetweenFloatingAndTiling(const QString &screenId) override
niri switch-focus-between-floating-and-tiling (IPlacementEngine override).
void windowMinSizeUpdated(const QString &windowId, int minWidth, int minHeight) override
Update a window's minimum size after the initial windowOpened.
void cycleFocus(bool forward, const PhosphorEngine::NavigationContext &ctx) override
Cycle keyboard focus through managed windows.
QSet< int > desktopsWithActiveState() const override
void focusInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Move keyboard focus to the adjacent window.
void restoreFocusedWindow(const PhosphorEngine::NavigationContext &ctx) override
Restore the focused window out of its managed state.
Coordinate mapping for one strip orientation: a pure value type, trivially copyable,...
Definition StripAxis.h:35
Definition DesktopRemap.h:12
StickyWindowHandling
Definition EngineTypes.h:238
@ TreatAsNormal
Definition EngineTypes.h:239
StickyPinPhase
Which half of the sticky-screen pin pass to run.
Definition EngineTypes.h:323
std::function< bool(const QString &)> StickyPredicate
Answers whether a window is on all desktops.
Definition EngineTypes.h:247
std::function< DesktopSpan(const QString &)> DesktopSpanQuery
Answers a window's DesktopSpan.
Definition EngineTypes.h:292
Definition IWindowTrackingService.h:28
Definition ScrollEngine.h:46
CenterFocusedColumn
Persistent view-centering policy for the focused column (niri's center-focused-column).
Definition ScrollTypes.h:234
ScrollInsertPosition
Where a fresh-opened window's new column enters the strip (config default; the openColumnPlacement wi...
Definition ScrollTypes.h:513
ColumnDisplay
How a column presents its tiles (niri's column display).
Definition ScrollTypes.h:246
Where a drag-insert preview should place the dragged window, in the TARGET ENGINE's slot vocabulary.
Definition IPlacementEngine.h:538
Context for a cross-engine window handoff.
Definition IPlacementEngine.h:863
What a membership pass did, so the caller can drive the bookkeeping the engines cannot reach: the pla...
Definition EngineTypes.h:299
Target window + screen for a navigation or lifecycle operation.
Definition NavigationContext.h:18
Identity of a per-screen placement state: a window's placement is scoped to the (screen,...
Definition EngineTypes.h:25
static QLatin1String scrollingEngineId()
Definition WindowPlacement.h:275
Column width INTENT — the source of truth the strip stores.
Definition ScrollTypes.h:528
How far a screen has worked through its context template's seed blueprint.
Definition ScrollTypes.h:274
Per-window open-behaviour overrides resolved from window rules (openColumnWidth / openTabbed / openCo...
Definition ScrollEngineTypes.h:38
The whole strip of one screen as a renderer of a strip MAP needs it: every column with its strip posi...
Definition ScrollEngineTypes.h:272
A column-aware strip snapshot for drag-popup renderers.
Definition ScrollEngineTypes.h:212
A tile paired with its screen-normalized rect, from ONE strip walk (see ScrollEngine::visibleTilesWit...
Definition ScrollEngineTypes.h:141
One visible tile of a strip: the unit of the scroll "zone number" space.
Definition ScrollEngineTypes.h:89
The tab indicator's GEOMETRY inputs — the subset of the Scrolling.TabIndicator family that changes re...
Definition ScrollTypes.h:310
Tile height INTENT within a column (its extent ACROSS the strip).
Definition ScrollTypes.h:596