Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
SnapEngine.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 "phosphorsnapengine_export.h"
20#include <QObject>
21#include <QPointer>
22#include <QRect>
23#include <QSet>
24#include <QString>
25#include <QStringList>
26#include <functional>
27#include <optional>
28#include <memory>
29
30namespace PhosphorZones {
31class IZoneDetector;
32class LayoutRegistry;
33}
34
35namespace PhosphorEngine {
36class IWindowRegistry;
37}
38
39// PhosphorRules::RuleEvaluator is included as a member type of
40// std::optional below (needs a complete type at declaration); RuleSet
41// is referenced only by pointer / reference, so a forward declaration would
42// suffice — but including RuleEvaluator.h pulls in RuleSet.h
43// transitively anyway, so leave the explicit forward decls out and let
44// RuleEvaluator.h provide both.
45
46namespace PhosphorSnapEngine {
47
51struct SnapEvacueePark;
52struct SnapPendingCarries;
53
67class PHOSPHORSNAPENGINE_EXPORT SnapEngine : public PhosphorEngine::PlacementEngineBase
68{
69 Q_OBJECT
70
71public:
75 QObject* parent = nullptr);
76 ~SnapEngine() override;
77
96 int currentVirtualDesktopForScreen(const QString& screenId) const;
97 QString currentActivity() const;
98
106 bool isSnapModeScreen(const QString& screenId) const;
107
114 std::pair<QString, QRect> resolveCrossDesktopZone(const QString& currentZoneId, const QString& screenId,
115 int targetDesktop) const;
116
121 QString entryZoneForCrossing(const QString& direction, const QString& neighbourScreen) const;
122 QString entryZoneForCrossing(const QString& direction, const QString& neighbourScreen, int desktop) const;
123
128 QString windowInZoneOnScreen(const QString& zoneId, const QString& screenId) const;
129
130 // ═══════════════════════════════════════════════════════════════════════════
131 // IPlacementEngine — lifecycle
132 // ═══════════════════════════════════════════════════════════════════════════
133
134 bool isActiveOnScreen(const QString& screenId) const override;
140 bool isEnabled() const noexcept override;
142 void windowOpened(const QString& windowId, const QString& screenId, int minWidth, int minHeight) override;
143
159 using ShouldRestorePredicate = std::function<bool(const QString& screenId, int desktop)>;
160
168 {
169 m_shouldRestorePredicate = std::move(predicate);
170 }
171
189 using RestorePositionPredicate = std::function<bool(const QString& windowId)>;
190
194 {
195 m_restorePositionPredicate = std::move(predicate);
196 }
197
221 using ManagedRestorePredicate = std::function<bool(const QString& windowId)>;
222
226 {
227 m_managedRestorePredicate = std::move(predicate);
228 }
229
234 using LiveModeResolver = std::function<PhosphorZones::AssignmentEntry::Mode(const QString& screenId)>;
236 {
237 m_liveModeResolver = std::move(resolver);
238 }
239
244 std::function<PhosphorZones::AssignmentEntry::Mode(const QString&, int, const QString&)>;
246 {
247 m_contextModeResolver = std::move(resolver);
248 }
249
253 std::function<bool(PhosphorZones::AssignmentEntry::Mode mode, const QString& screenId)>;
255 {
256 m_tilingEngineLiveResolver = std::move(resolver);
257 }
258
270 using FloatPredicate = std::function<bool(const QString& windowId, const QString& screenId)>;
271
273 {
274 m_floatPredicate = std::move(predicate);
275 }
276
292 using UnfloatFallbackPredicate = std::function<bool(const QString& windowId, const QString& screenId)>;
293
295 {
296 m_unfloatFallbackPredicate = std::move(predicate);
297 }
298
325 using PlacementZonesResolver = std::function<PlacementDirective(const QString& windowId, const QString& screenId)>;
326
328 {
329 m_placementZonesResolver = std::move(resolver);
330 }
331
334 void windowClosed(const QString& windowId) override;
335
342 std::optional<PhosphorEngine::PlacementStateKey> heldKeyForWindow(const QString& windowId) const override;
343
347 void releaseWindowOffScreen(const QString& windowId, const QString& keepScreenId) override;
348
364 PhosphorEngine::MembershipReconcileResult releaseWindowOutsideSpan(const QString& windowId, const QString& screenId,
365 const PhosphorEngine::DesktopSpan& span);
366
367 // Evacuee park (src/evacueepark.cpp; the contract is IPlacementEngine's).
368 QStringList parkOutput(const QString& physicalScreenId) override;
369 bool readoptParked(const QString& windowId, const QString& parkedPhysicalId,
370 const QString& returnedPhysicalId) override;
371 void dropParked(const QString& windowId, const QString& physicalScreenId, int desktop,
372 const QString& activity) override;
373 bool hasParked(const QString& windowId, const QString& physicalScreenId) const override;
374
375 void windowFocused(const QString& windowId, const QString& screenId) override;
376 void toggleWindowFloat(const QString& windowId, const QString& screenId) override;
377 void setWindowFloat(const QString& windowId, bool shouldFloat, const QString& screenId = QString()) override;
378 void saveState() override;
379 void loadState() override;
380
381 // Layout capability (see IPlacementEngine's Layout capability section)
384 {
386 }
387
388 // Cross-engine handoff
389 QString engineId() const override
390 {
391 return QStringLiteral("snap");
392 }
393 void handoffReceive(const HandoffContext& ctx) override;
396 void handoffRelease(const QString& windowId) override;
397 QString screenForTrackedWindow(const QString& windowId) const override;
403 bool isWindowTracked(const QString& windowId) const override;
404
407 enum class ResnapFeedback {
408 Report,
409 Silent
410 };
411
419
422 void resnapCurrentAssignments(const QString& screenFilter = QString(), const QSet<QString>& onlyWindows = {});
423 void resnapCurrentAssignments(const QString& screenFilter, const QSet<QString>& onlyWindows,
424 ResnapFeedback feedback);
425
429 void resnapFromAutotileOrder(const QStringList& autotileWindowOrder, const QString& screenId);
430
444 QVector<PhosphorEngine::ZoneAssignmentEntry>
445 calculateResnapEntriesFromAutotileOrder(const QStringList& autotileWindowOrder, const QString& screenId,
446 const QStringList& preClaimedZoneIds = {});
447
454 PhosphorProtocol::SnapAllResultList calculateSnapAllWindows(const QStringList& windowIds, const QString& screenId);
455
465 void emitBatchedResnap(const QVector<PhosphorEngine::ZoneAssignmentEntry>& entries);
466
471 void snapAllWindows(const QString& screenId);
472
473 // ═══════════════════════════════════════════════════════════════════════════
474 // Window restore (auto-snap on window open)
475 // ═══════════════════════════════════════════════════════════════════════════
476
498 resolveWindowRestore(const QString& windowId, const QString& screenId, bool sticky,
501
502 // ═══════════════════════════════════════════════════════════════════════════
503 // Autotile engine reference (for isActiveOnScreen routing)
504 // ═══════════════════════════════════════════════════════════════════════════
505
516
524 void setWindowRegistry(QObject* registry) override;
525
526 // ═══════════════════════════════════════════════════════════════════════════
527 // Per-screen state resolution
528 //
529 // The engine owns one SnapState per (screen, desktop, activity)
530 // PlacementStateKey (via PerScreenStates) plus a single global-scalar holder
531 // (m_globals, keyed under the empty-screen sentinel). Each per-key store now
532 // tracks its OWN last-used zone; m_globals keeps the user-snapped classes (a
533 // per-app preference, not a placement) and the single representative last-used
534 // restored from disk. A window is placed under the key derived from its
535 // screen on first snap/float; a window present on several desktops holds
536 // a membership, and its own zone, in one store per desktop (the
537 // membership map is authoritative). Its screen is a per-window value; a
538 // pinned write naming another screen re-homes it (stateForWindowOnScreen).
539 // ═══════════════════════════════════════════════════════════════════════════
540
548 SnapState* stateForWindow(const QString& windowId);
549 const SnapState* stateForWindow(const QString& windowId) const;
550
554 {
555 return m_globals;
556 }
557
561 {
562 return m_globals;
563 }
564
567 QList<SnapState*> allSnapStates() const;
568
580 SnapState* stateForWindowOnScreen(const QString& windowId, const QString& screenId, int desktop = 0);
581
584 void forgetWindow(const QString& windowId);
587 bool holdsWindowInState(const QString& windowId, const SnapState* state) const;
589 std::optional<PhosphorEngine::PlacementStateKey> keyForState(const SnapState* state) const;
592 QString navigationScreenFor(const QString& windowId, const QString& preferredScreen) const;
593
599 bool migrateWindowToScreen(const QString& windowId, const QString& newScreenId);
604 void rekeyMembershipsToRecordedScreens(const QString& physicalScreenId);
608 void renameScreen(const QString& oldPhysicalId, const QString& newPhysicalId);
609
610 // ═══════════════════════════════════════════════════════════════════════════
611 // Current-context feed (ScreenContextTracker)
612 //
613 // The daemon pushes the current virtual desktop / per-output desktop (#648) /
614 // activity here so currentKeyForScreen resolves a window's owning
615 // (screen, desktop, activity) key, mirroring the pushes it already makes into
616 // AutotileEngine. Snap keys are per-monitor first (the load-bearing #724 fix);
617 // the desktop/activity dimensions match autotile's per-context semantics.
618 // ═══════════════════════════════════════════════════════════════════════════
619
620 void setCurrentDesktop(int desktop) override;
621 void setCurrentDesktopForScreen(const QString& screenId, int desktop) override;
626 reconcileDesktopMemberships(const QString& screenId, const PhosphorEngine::DesktopSpanQuery& spanOf) override;
628 reconcileWindowMemberships(const QString& windowId, const PhosphorEngine::DesktopSpanQuery& spanOf) override;
635 void setFloatingWithResidence(const QString& windowId, const QString& screenId);
639 void seedPersistedDesktopZones(const QString& windowId, const PhosphorEngine::EngineSlot& slot,
640 const QString& screenId, int restoreDesktop, const QString& activity);
641 void setCurrentActivity(const QString& activity) override;
642
643 // Reclaim per-(screen,desktop,activity) stores whose context no longer exists,
644 // and move the live ones through a change of KWin's desktop list. Without these
645 // the stores accumulate across desktop/activity/output removal (the global holder
646 // has an empty screenId, so it is never a target). The daemon prunes from its
647 // desktop-count / activities-changed / screenRemoved handlers; the desktop moves
648 // are remapDesktops (src/desktopremap.cpp), of which the renumber is one removal.
649 QSet<int> desktopsWithActiveState() const override;
650 void pruneStatesForDesktop(int removedDesktop) override;
651 void renumberDesktopsAfterRemoval(int removedDesktop) override;
652 void remapDesktops(const PhosphorEngine::DesktopRemap& remap) override;
653 void pruneStatesForActivities(const QStringList& validActivities) override;
654 void pruneStatesForRemovedScreen(const QString& physicalScreenId) override;
655
656 // Float facade over the per-screen stores (the daemon's float resolver/writer/lister route here).
657 bool isFloating(const QString& windowId) const;
658 void setFloating(const QString& windowId, bool floating);
659 QStringList floatingWindows() const;
660
668 void applyNoMatchFloatDefault(const QString& windowId, const QString& screenId,
669 PhosphorEngine::RestoreReason reason, bool placedBefore);
670
673 bool wasPlacedByPreviousLineage(const QString& windowId) const;
674
678 QString zoneForWindow(const QString& windowId) const;
679
680 // ═══════════════════════════════════════════════════════════════════════════
681 // Zone adjacency resolver (for daemon-driven navigation)
682 // ═══════════════════════════════════════════════════════════════════════════
683
694
699
700 // ═══════════════════════════════════════════════════════════════════════════
701 // Navigation state provider
702 // ═══════════════════════════════════════════════════════════════════════════
703
717
718 // Navigation: every verb takes the daemon's NavigationContext except
719 // switchFocusBetweenFloatingAndTiling(screenId) and rotateWindowsInLayout(clockwise,
720 // screenId); an empty ctx.windowId falls back to m_navState's last-active window.
721
722 // ═══════════════════════════════════════════════════════════════════════════
723 // IPlacementEngine — navigation overrides
724 // ═══════════════════════════════════════════════════════════════════════════
725
729 void focusInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
730
735 void moveFocusedInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
736
741 void spanFocusedInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
742
746 void swapFocusedInDirection(const QString& direction, const PhosphorEngine::NavigationContext& ctx) override;
747
750 void moveFocusedToPosition(int zoneNumber, const PhosphorEngine::NavigationContext& ctx) override;
751
754 void rotateWindows(bool clockwise, const PhosphorEngine::NavigationContext& ctx) override;
755
759
765
768 std::optional<PhosphorEngine::WindowPlacement> capturePlacement(const QString& windowId) const override;
769
780 std::optional<PhosphorEngine::WindowPlacement> capturePlacementAtDesktop(const QString& windowId,
781 int gateDesktop) const;
782
787
790
793
796
808 void switchFocusBetweenFloatingAndTiling(const QString& screenId) override;
809
812 void cycleFocus(bool forward, const PhosphorEngine::NavigationContext& ctx) override;
813
814 // ═══════════════════════════════════════════════════════════════════════════
815 // Snap commit orchestration
816 //
817 // Full snap lifecycle: clear floating, assign to zone, update tracking,
818 // emit state-changed signals. Owns the orchestration that was previously
819 // on WindowTrackingService.
820 // ═══════════════════════════════════════════════════════════════════════════
821
828 void commitSnap(const QString& windowId, const QString& zoneId, const QString& screenId,
830 int virtualDesktop = 0);
831
832 void commitMultiZoneSnap(const QString& windowId, const QStringList& zoneIds, const QString& screenId,
834 int virtualDesktop = 0);
835
836 void uncommitSnap(const QString& windowId);
837
844 void recordFreeFrameBeforeUserSnap(const QString& windowId, const QString& screenId);
849 void commitUserSnap(const QString& windowId, const QStringList& zoneIds, const QString& screenId,
850 const QRect& geometry, const QString& captureScreen, int virtualDesktop = 0);
851
853 PhosphorEngine::UnfloatResult resolveUnfloatGeometry(const QString& windowId, const QString& fallbackScreen) const;
859 PhosphorEngine::UnfloatResult resolveUnfloatGeometry(const QString& windowId, const QString& fallbackScreen,
860 bool confineToFallbackScreen) const;
861
874 const QString& fallbackScreen) const;
875
877 applyBatchAssignments(const QVector<PhosphorEngine::ZoneAssignmentEntry>& entries,
879 std::function<QString()> fallbackScreenResolver = {});
880
881 // ═══════════════════════════════════════════════════════════════════════════
882 // Auto-snap calculations (moved from WTS)
883 // ═══════════════════════════════════════════════════════════════════════════
884
886 PhosphorEngine::SnapResult calculateSnapToPlacementRule(const QString& windowId, const QString& screenId,
887 bool isSticky) const;
888 PhosphorEngine::SnapResult calculateSnapToPlacementRule(const QString& windowId, const QString& screenId,
889 bool isSticky, const PlacementDirective& directive) const;
890 PhosphorEngine::SnapResult calculateSnapToLastZone(const QString& windowId, const QString& windowScreenId,
891 bool isSticky) const;
892 PhosphorEngine::SnapResult calculateSnapToEmptyZone(const QString& windowId, const QString& windowScreenId,
893 bool isSticky) const;
894
895 // ═══════════════════════════════════════════════════════════════════════════
896 // Resnap / rotation calculations (moved from WTS)
897 // ═══════════════════════════════════════════════════════════════════════════
898
899 QVector<PhosphorEngine::ZoneAssignmentEntry> calculateResnapFromPreviousLayout();
900 QVector<PhosphorEngine::ZoneAssignmentEntry>
901 calculateResnapFromCurrentAssignments(const QString& screenFilter = QString(),
902 const QSet<QString>& onlyWindows = {}) const;
903 QVector<PhosphorEngine::ZoneAssignmentEntry>
904 calculateResnapFromAutotileOrder(const QStringList& autotileWindowOrder, const QString& screenId,
905 const QStringList& preClaimedZoneIds = {}) const;
906 QVector<PhosphorEngine::ZoneAssignmentEntry> calculateSnapAllWindowEntries(const QStringList& windowIds,
907 const QString& screenId) const;
908 QVector<PhosphorEngine::ZoneAssignmentEntry> calculateRotation(bool clockwise,
909 const QString& screenFilter = QString()) const;
910
913 int pruneStaleWindows(const QSet<QString>& aliveWindowIds) override;
914
915 // ═══════════════════════════════════════════════════════════════════════════
916 // IPlacementEngine — state access
917 //
918 // Resolves the per-(screen,desktop,activity) SnapState for a screen via the
919 // shared ScreenContextTracker + PerScreenStates. The non-const overload lazily
920 // creates the store; an empty screenId resolves to the global-scalar holder.
921 // ═══════════════════════════════════════════════════════════════════════════
922
923 PhosphorEngine::IPlacementState* stateForScreen(const QString& screenId) override;
924 const PhosphorEngine::IPlacementState* stateForScreen(const QString& screenId) const override;
925
926 // ═══════════════════════════════════════════════════════════════════════════
927 // Internal navigation helpers (concrete SnapEngine methods that the
928 // IPlacementEngine overrides delegate to)
929 // ═══════════════════════════════════════════════════════════════════════════
930
934
936 void rotateWindowsInLayout(bool clockwise, const QString& screenId);
937
938 // ═══════════════════════════════════════════════════════════════════════════
939 // Persistence delegate
940 // ═══════════════════════════════════════════════════════════════════════════
941
952 void setPersistenceDelegate(std::function<void()> saveFn, std::function<void()> loadFn)
953 {
954 m_saveFn = std::move(saveFn);
955 m_loadFn = std::move(loadFn);
956 }
957
962 QString lastActiveScreenId() const
963 {
964 return m_lastActiveScreenId;
965 }
966
975
987 std::function<std::optional<PhosphorRules::WindowQuery>(const QString& windowId, const QString& screenHint)>;
988
993 {
994 m_exclusionQueryProvider = std::move(provider);
995 }
996
1000 std::function<std::function<bool(const PhosphorRules::Rule&)>(const PhosphorRules::WindowQuery&)>;
1002 {
1003 m_exclusionAdmission = std::move(admission);
1004 }
1005
1012 bool isAppIdExcluded(const QString& appId) const;
1013
1023 bool isWindowExcluded(const QString& windowId, const QString& screenHint = QString()) const;
1028 bool isWindowExcludedByRule(const QString& windowId, const QString& screenHint = QString()) const;
1029
1030Q_SIGNALS:
1031 // ── Signals (relayed to the effect by SnapAdaptor and the WTA) ──
1032
1034 void windowSnapStateChanged(const QString& windowId, const PhosphorProtocol::WindowStateEntry& entry);
1035
1037 void windowFloatingClearedForSnap(const QString& windowId, const QString& screenId);
1038
1040 void applyGeometryRequested(const QString& windowId, int x, int y, int width, int height, const QString& zoneId,
1041 const QString& screenId, bool sizeOnly);
1042
1044 void resnapToNewLayoutRequested(const QString& resnapData);
1045
1047 void snapAllWindowsRequested(const QString& screenId);
1048
1052 void applyGeometriesBatch(const PhosphorProtocol::WindowGeometryList& geometries, const QString& action);
1054 void restatementGeometryRequested(const QString& windowId, int x, int y, int width, int height,
1055 const QString& zoneId, const QString& screenId);
1056 void fullscreenHandBackRequested(const QString& windowId);
1057
1058private:
1059 PhosphorEngine::ISnapSettings* snapSettings() const;
1060
1062 void restoreFreeSizeForUnplaced(const QString& windowId, const QString& screenId, int desktop,
1063 PhosphorEngine::RestoreReason reason, bool placedBefore);
1065 QList<QSize> managedSizesOnScreen(const QString& screenId, int desktop) const;
1070 int routedOpenDesktop(const QString& windowId, const QString& screenId) const;
1071
1076 QString canonicalWindowId(const QString& rawWindowId) const;
1077
1081 PhosphorEngine::PlacementStateKey currentKeyForScreen(const QString& screenId) const
1082 {
1083 return m_context.currentKeyForScreen(screenId);
1084 }
1085
1089 SnapState* ensureStateForKey(const PhosphorEngine::PlacementStateKey& key);
1090
1099 void forEachSnapAssignment(
1100 const std::function<void(const QString& windowId, const QStringList& zoneIds, const QString& screenId,
1101 int desktop, int storeDesktop, const QString& storeActivity)>& fn) const;
1102
1104 bool snappingSwitchedOff() const;
1106 bool snapsInContext(const PhosphorEngine::PlacementStateKey& key) const;
1109 int restoreDesktopFor(const QString& windowId, const PhosphorEngine::WindowPlacement& rec,
1110 const QString& restoreScreen) const;
1111
1113 struct PendingMembership;
1114 void collectMembershipWork(const QString& windowId, const QString& screenId,
1115 const PhosphorEngine::PlacementStateKey& currentKey,
1116 const PhosphorEngine::DesktopSpan& span, QList<PendingMembership>& pending) const;
1123 PhosphorEngine::MembershipReconcileResult applyMembershipWork(const QString& screenId,
1124 const PhosphorEngine::PlacementStateKey& currentKey,
1125 const QList<PendingMembership>& pending,
1126 const QString& onlyWindow,
1127 const PhosphorEngine::DesktopSpanQuery& spanOf);
1128
1131 bool migrateWindowToKey(const QString& windowId, const PhosphorEngine::PlacementStateKey& newKey);
1134 void applyDesktopRemap(const PhosphorEngine::DesktopRemap& remap);
1136 void dropPreFloatHome(SnapState* state, const QString& windowId);
1140 bool releaseMembership(const QString& windowId, const PhosphorEngine::PlacementStateKey& key, QStringList& removed);
1143 bool clearGlobalLastUsedIfRemoved(const QStringList& removed);
1144
1150 const SnapState* lastUsedStateForScreen(const QString& screenId) const;
1151
1152 void commitSnapImpl(const QString& windowId, const QStringList& zoneIds, const QString& screenId,
1153 PhosphorEngine::SnapIntent intent, int virtualDesktop = 0, bool userVerb = false);
1154
1159 QString resolveUnfloatScreen(const QString& primaryScreen, const QString& fallbackScreen) const;
1160
1161 PhosphorZones::LayoutRegistry* m_layoutManager = nullptr;
1162 PhosphorEngine::IWindowTrackingService* m_windowTracker = nullptr;
1163 // Per-(screen,desktop,activity) snap stores + the current-context tracker that
1164 // resolves a screen to its owning key. The daemon feeds the tracker the current
1165 // desktop / per-output desktop (#648) / activity, so each screen resolves to a
1166 // real {screenId, desktop, activity} key and gets its own SnapState (created
1167 // lazily on first placement). m_globals holds the global user-snapped classes
1168 // (and the representative last-used restored from disk, plus any screenless
1169 // float) under the empty-screen key so whole-store iterations pick it up
1170 // transparently; live last-used now lives in each per-screen store.
1173 SnapState* m_globals = nullptr;
1174 PhosphorEngine::IWindowRegistry* m_windowRegistry = nullptr;
1175 // Stored and never read: zone lookups go through m_windowTracker and the
1176 // adjacency resolver. Kept because the constructor parameter and this
1177 // member are part of the installed class's ABI.
1178 PhosphorZones::IZoneDetector* m_zoneDetector = nullptr;
1179 PhosphorEngine::IVirtualDesktopManager* m_virtualDesktopManager = nullptr;
1180 QPointer<QObject> m_autotileEngineObj;
1181 PhosphorEngine::IPlacementEngine* m_autotileEngineTyped = nullptr;
1182 IZoneAdjacencyResolver* m_zoneAdjacencyResolver = nullptr;
1183 // QObject identity of m_zoneAdjacencyResolver, kept so a replacement can
1184 // disconnect the previous resolver's destroyed guard (a stale guard firing
1185 // later would null the LIVE replacement). Mirrors m_autotileEngineObj.
1186 QPointer<QObject> m_zoneAdjacencyResolverObj;
1187 PhosphorEngine::ICrossSurfaceResolver* m_crossSurfaceResolver = nullptr;
1188 // Typed navigation-state provider — replaces the opaque QObject* m_wta
1189 // back-reference. Provides read-only access to compositor-layer shadows
1190 // (last-active window, last-active screen, last-cursor screen, frame
1191 // geometry). Not owned; nulled by a QObject provider's destroyed signal.
1192 INavigationStateProvider* m_navState = nullptr;
1193 // QObject identity of m_navState — same stale-destroyed-guard rationale
1194 // as m_zoneAdjacencyResolverObj.
1195 QPointer<QObject> m_navStateObj;
1196 // Snap-mode navigation target resolver, built on the first navigation call.
1197 std::unique_ptr<SnapNavigationTargetResolver> m_targetResolver;
1198
1199 // ═══════════════════════════════════════════════════════════════════════════
1200 // Float helpers (src/float.cpp)
1201 //
1202 // Every snap commit routes through commitSnapImpl. The writes that put a zone
1203 // straight into a store as memory are seedPersistedDesktopZones, the adoption's
1204 // restore and a carry onto a hidden desktop (membership.cpp), and readoptParked.
1205 // ═══════════════════════════════════════════════════════════════════════════
1206
1209 enum class UnfloatCause {
1214 UserToggle,
1217 Suspension,
1218 };
1219 bool unfloatToZone(const QString& windowId, const QString& screenId, UnfloatCause cause);
1220 bool applyGeometryForFloat(const QString& windowId, const QString& screenId);
1225 void applyFloatGeometryUnlessMinimized(const QString& windowId, const QString& screenId);
1226
1230 SnapNavigationTargetResolver* ensureTargetResolver(const QString& action = QString());
1231
1239 bool tryCrossDesktopMove(const QString& windowId, const QString& direction, const QString& screenId);
1240
1244 bool tryCrossModeOutput(const QString& windowId, const QString& direction, const QString& screenId, bool swap);
1246 bool isTilingOutput(const QString& screenId) const;
1248 bool tryCrossModeFocus(const QString& direction, const QString& screenId);
1251 void moveUnsnapped(const QString& windowId, const QString& fromScreen, const QString& toScreen, int toDesktop,
1252 const QString& direction);
1253
1258 bool tryCrossDesktopFocus(const QString& focusedWindowId, const QString& direction, const QString& screenId);
1259
1263 bool isWindowExcludedForAction(const QString& windowId, const QString& action, const QString& screenId);
1265 bool isWindowExcludedAt(const QString& windowId, const QString& screenHint, int desktop) const;
1269 PhosphorRules::WindowQuery exclusionQueryFor(const QString& windowId, const QString& screenHint, int desktop) const;
1272 QStringList windowsInZoneInView(const QString& zoneId, const QString& screenId,
1273 const QString& excludeWindowId) const;
1274
1278 bool evaluateExcludeRules(const PhosphorRules::WindowQuery& query) const;
1279
1293 const PhosphorRules::RuleSet* m_excludeRuleSet = nullptr;
1302 mutable std::optional<PhosphorRules::RuleEvaluator> m_excludeEvaluator;
1303
1307 ExclusionQueryProvider m_exclusionQueryProvider{};
1308
1309 // Persistence delegates (the config backend stays in the adaptor layer)
1310 std::function<void()> m_saveFn;
1311 std::function<void()> m_loadFn;
1312
1313 // Last-focused screen (updated by windowFocused)
1314 QString m_lastActiveScreenId;
1315
1316 // Disabled-context placement gate. Empty until the daemon wires it; while empty
1317 // the engine treats every screen as active — preserving the
1318 // historical default that unit tests rely on. (See the
1319 // ShouldRestorePredicate doc above and discussion #461 item 7.)
1320 ShouldRestorePredicate m_shouldRestorePredicate{};
1321
1322 // The gates and resolvers below are empty until the daemon wires them,
1323 // and each type's doc above says what an empty one means.
1324 RestorePositionPredicate m_restorePositionPredicate{};
1325 ManagedRestorePredicate m_managedRestorePredicate{};
1326 LiveModeResolver m_liveModeResolver{};
1327 TilingEngineLiveResolver m_tilingEngineLiveResolver{};
1328 FloatPredicate m_floatPredicate{};
1329 UnfloatFallbackPredicate m_unfloatFallbackPredicate{};
1330 PlacementZonesResolver m_placementZonesResolver{};
1331
1332 // Appended last (installed header). Created by the first parkOutput.
1333 std::unique_ptr<SnapEvacueePark> m_evacueePark;
1334 ExclusionAdmission m_exclusionAdmission{};
1335 std::unique_ptr<SnapPendingCarries> m_pendingCarries; // created by the first carry left for a hidden context
1336 ContextModeResolver m_contextModeResolver{};
1337 // Every activity setCurrentActivity has put this engine in, less the ones
1338 // pruneStatesForActivities removed: the only activities another engine can
1339 // have placed a window on every activity in while the daemon ran. The
1340 // membership re-apply asks them whether such a window was shown in
1341 // another mode's context.
1342 QSet<QString> m_enteredActivities;
1343};
1344
1345} // namespace PhosphorSnapEngine
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
Unified placement engine interface, implemented by all three engines (snap zone layouts,...
Definition IPlacementEngine.h:44
LayoutSupport
How this engine relates to user-selectable layouts — the entries the layout picker,...
Definition IPlacementEngine.h:955
@ Placement
Layouts drive window placement (snap zone layouts, autotile algorithm cards): the classic picker sema...
Definition IPlacementEngine.h:962
Per-screen placement state contract.
Definition IPlacementState.h:28
Definition ISnapSettings.h:12
Definition IVirtualDesktopManager.h:13
Definition IWindowRegistry.h:49
Definition IWindowTrackingService.h:35
Exported because this is a header-only template used from every engine library, so the category has t...
Definition PerScreenStates.h:45
Abstract base class for placement engines.
Definition PlacementEngineBase.h:36
Tracks the "current context" of each screen for a placement engine: the global current virtual deskto...
Definition ScreenContextTracker.h:49
An ordered collection of Rules — the persistent rule store.
Definition RuleSet.h:33
Narrow read-only interface for compositor-layer state queries.
Definition INavigationStateProvider.h:32
Narrow interface for zone-adjacency queries used by snap navigation.
Definition IZoneAdjacencyResolver.h:32
void setWindowFloat(const QString &windowId, bool shouldFloat, const QString &screenId=QString()) override
Set floating state explicitly (directional, not toggle).
void windowSnapStateChanged(const QString &windowId, const PhosphorProtocol::WindowStateEntry &entry)
Snap state changed (commit / uncommit). WTA relays to D-Bus windowStateChanged.
void snapAllWindowsRequested(const QString &screenId)
Request KWin effect to collect unsnapped windows and snap them all.
ResnapFeedback
Whether a resnap that finds nothing says so (no_windows_to_resnap): a user verb does,...
Definition SnapEngine.h:407
void focusInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Walk to the adjacent window in direction and transfer keyboard focus; at the layout edge,...
QString entryZoneForCrossing(const QString &direction, const QString &neighbourScreen) const
The zone a window ENTERS crossing onto neighbourScreen in direction: the edge zone facing back toward...
void rekeyMembershipsToRecordedScreens(const QString &physicalScreenId)
After a split or un-split of physicalScreenId rewrote the stores' screen values, re-file each members...
std::function< std::optional< PhosphorRules::WindowQuery >(const QString &windowId, const QString &screenHint)> ExclusionQueryProvider
Provider that builds the full WindowQuery for a live windowId.
Definition SnapEngine.h:986
void renumberDesktopsAfterRemoval(int removedDesktop) override
Shift every per-(screen, desktop, activity) state ABOVE removedDesktop down by one,...
void setPersistenceDelegate(std::function< void()> saveFn, std::function< void()> loadFn)
Set persistence callbacks for save/load.
Definition SnapEngine.h:952
std::function< bool(const QString &windowId)> ManagedRestorePredicate
Predicate consulted in resolveWindowRestore to decide whether a window that was SNAPPED at logout sho...
Definition SnapEngine.h:221
std::function< bool(const QString &screenId, int desktop)> ShouldRestorePredicate
Predicate deciding whether snapping may place a window on (screenId, desktop), so nothing is placed i...
Definition SnapEngine.h:159
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateRotation(bool clockwise, const QString &screenFilter=QString()) const
PhosphorEngine::SnapResult resolveWindowRestore(const QString &windowId, const QString &screenId, bool sticky, PhosphorEngine::WindowKind kind=PhosphorEngine::WindowKind::Unknown, PhosphorEngine::RestoreReason reason=PhosphorEngine::RestoreReason::Open)
Resolve auto-snap for a newly opened window.
void setRestorePositionPredicate(RestorePositionPredicate predicate)
Inject the unsnapped-position-restore gate (see RestorePositionPredicate).
Definition SnapEngine.h:193
void resnapCurrentAssignments(const QString &screenFilter=QString(), const QSet< QString > &onlyWindows={})
Re-apply the zones windows hold, on screenFilter (all when empty), only onlyWindows when it is not em...
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 setExclusionQueryProvider(ExclusionQueryProvider provider)
Inject the exclusion query provider.
Definition SnapEngine.h:992
bool isFloating(const QString &windowId) const
void setManagedRestorePredicate(ManagedRestorePredicate predicate)
Inject the managed (snapped-to-zone) restore gate (see ManagedRestorePredicate).
Definition SnapEngine.h:225
void emitBatchedResnap(const QVector< PhosphorEngine::ZoneAssignmentEntry > &entries)
Emit a single batched resnapToNewLayoutRequested signal.
void setUnfloatFallbackPredicate(UnfloatFallbackPredicate predicate)
Definition SnapEngine.h:294
void setCurrentDesktop(int desktop) override
QSet< int > desktopsWithActiveState() const override
PhosphorEngine::SnapResult calculateSnapToLastZone(const QString &windowId, const QString &windowScreenId, bool isSticky) const
int pruneStaleWindows(const QSet< QString > &aliveWindowIds) override
Drops the state-index membership of every window not in the (canonical) alive set.
bool isAppIdExcluded(const QString &appId) const
True if appId matches an enabled rule of the borrowed exclusion set (Exclude or ExcludePlacement) on ...
PhosphorEngine::MembershipReconcileResult reconcileWindowMemberships(const QString &windowId, const PhosphorEngine::DesktopSpanQuery &spanOf) override
The same pass for ONE window, on the screen it is held on.
void installContextResolver()
Point the container's primary resolution at currentKeyForScreen.
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 reapplyManagedWindowAppearance() override
Re-emit the zone geometry of every non-floating window snapped in view (the shown desktop's store on ...
void rotateWindowsInLayout(bool clockwise, const QString &screenId)
Rotate snapped windows through the layout's zone order on screenId.
void toggleFocusedFloat(const PhosphorEngine::NavigationContext &ctx) override
Toggle the focused window between snapped and floating.
PhosphorEngine::SnapResult calculateSnapToPlacementRule(const QString &windowId, const QString &screenId, bool isSticky) const
The SnapToZone placement of a matched rule on screenId; the four-argument form takes a resolved direc...
std::function< std::function< bool(const PhosphorRules::Rule &)>(const PhosphorRules::WindowQuery &)> ExclusionAdmission
Builds the rule admission for an exclusion query: a rule naming a field the query left unstamped is s...
Definition SnapEngine.h:999
void setExcludeRuleSet(const PhosphorRules::RuleSet *ruleSet)
Wire the daemon's filtered placement-exclusion rule set (rules carrying an Exclude or ExcludePlacemen...
SnapState * snapState() const
The global-scalar holder (alias of globalState), for callers that only need the last-used-zone / user...
Definition SnapEngine.h:560
std::optional< PhosphorEngine::WindowPlacement > capturePlacementAtDesktop(const QString &windowId, int gateDesktop) const
capturePlacement with the mode gate resolved at an EXPLICIT desktop.
PhosphorEngine::SnapResult calculateSnapToEmptyZone(const QString &windowId, const QString &windowScreenId, bool isSticky) const
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 setLiveModeResolver(LiveModeResolver resolver)
Definition SnapEngine.h:235
void setPlacementZonesResolver(PlacementZonesResolver resolver)
Definition SnapEngine.h:327
bool isWindowExcluded(const QString &windowId, const QString &screenHint=QString()) const
Resolve exclusion for a live windowId using the FULL window attributes when the exclusion query provi...
bool wasPlacedByPreviousLineage(const QString &windowId) const
That snapshot, taken before anything can re-bind a slot-bearing record under this uuid.
void reapplyLayout(const PhosphorEngine::NavigationContext &ctx) override
Re-apply the zones the windows on ctx.screenId hold in the context in view.
void setContextModeResolver(ContextModeResolver resolver)
Definition SnapEngine.h:245
bool isActiveOnScreen(const QString &screenId) const override
Whether this engine is active on the given screen.
void pushToEmptyZone(const PhosphorEngine::NavigationContext &ctx) override
Move the focused window to the first empty zone on the screen it acts on.
void restoreFocusedWindow(const PhosphorEngine::NavigationContext &ctx) override
Restore the focused window in a zone to its float-back on its screen and float it; one in no zone is ...
std::function< bool(const QString &windowId, const QString &screenId)> UnfloatFallbackPredicate
Predicate deciding whether an unfloat with NO remembered pre-float zone falls back to a zone anyway (...
Definition SnapEngine.h:292
void recordFreeFrameBeforeUserSnap(const QString &windowId, const QString &screenId)
Record a window's live frame as its float-back, ahead of a user snap the DAEMON drives (keys,...
void windowFloatingClearedForSnap(const QString &windowId, const QString &screenId)
Floating state cleared as part of a commit. WTA relays as windowFloatingChanged(id,...
LayoutSupport layoutSupport() const override
Snap placement is driven by user-selectable zone layouts.
Definition SnapEngine.h:383
void resnapFromAutotileOrder(const QStringList &autotileWindowOrder, const QString &screenId)
No in-tree caller (the SnapAdaptor slot of this name calls calculateResnapEntriesFromAutotileOrder an...
PhosphorEngine::IPlacementState * stateForScreen(const QString &screenId) override
Per-screen state object for the given screen.
PhosphorEngine::MembershipReconcileResult reconcileDesktopMemberships(const QString &screenId, const PhosphorEngine::DesktopSpanQuery &spanOf) override
A window on several desktops holds its own zone on each.
std::pair< QString, QRect > resolveCrossDesktopZone(const QString &currentZoneId, const QString &screenId, int targetDesktop) const
Resolve the zone on screenId's targetDesktop layout that is positionally equivalent to currentZoneId ...
void handoffReceive(const HandoffContext &ctx) override
Receive ownership of a window from another engine.
void setFloating(const QString &windowId, bool floating)
void setExclusionAdmission(ExclusionAdmission admission)
Definition SnapEngine.h:1001
void setCurrentActivity(const QString &activity) override
void commitUserSnap(const QString &windowId, const QStringList &zoneIds, const QString &screenId, const QRect &geometry, const QString &captureScreen, int virtualDesktop=0)
The tail of every user snap the daemon drives: record the free frame the window leaves (on captureScr...
void snapAllWindows(const QString &screenId)
Request the KWin effect to collect and snap all unsnapped windows.
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapFromCurrentAssignments(const QString &screenFilter=QString(), const QSet< QString > &onlyWindows={}) const
void switchFocusBetweenFloatingAndTiling(const QString &screenId) override
Jump focus between the float layer and the snapped layout (niri's switch-focus-between-floating-and-t...
PhosphorEngine::UnfloatResult resolveFallbackUnfloatGeometry(const QString &windowId, const QString &fallbackScreen) const
Fallback unfloat target for a window with NO pre-float zone (a never-snapped window that defaulted to...
void setFloatPredicate(FloatPredicate predicate)
Definition SnapEngine.h:272
void setFloatingWithResidence(const QString &windowId, const QString &screenId)
Float windowId in its primary store.
void moveFocusedToPosition(int zoneNumber, const PhosphorEngine::NavigationContext &ctx) override
Move the focused window to the layout zone with zoneNumber (1-based) on the screen the verb acts on (...
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapFromPreviousLayout()
int currentVirtualDesktopForScreen(const QString &screenId) const
This screen's current virtual desktop (Plasma 6.7 per-output virtual desktops, #648).
void handoffRelease(const QString &windowId) override
Per context: keeps a membership on another desktop still in snapping mode (the window stays snapped t...
void moveFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Move the focused window into the adjacent zone in direction (it stacks with an occupant; swap exchang...
int currentVirtualDesktop() const
Current virtual desktop (1-based; 0 when no virtual-desktop manager is wired) and activity,...
std::function< PlacementDirective(const QString &windowId, const QString &screenId)> PlacementZonesResolver
Resolver yielding the open-placement directive — SnapToZone ordinals and/or zone names,...
Definition SnapEngine.h:325
bool isEnabled() const noexcept override
True when snapping is globally enabled.
std::function< bool(const QString &windowId)> RestorePositionPredicate
Predicate consulted in resolveWindowRestore to decide whether a FLOATED window should have its previo...
Definition SnapEngine.h:189
QString windowInZoneOnScreen(const QString &zoneId, const QString &screenId) const
The window snapped to zoneId on screenId in the context the screen shows, or empty if the zone is uno...
QString engineId() const override
Stable engine identity for HandoffContext.fromEngineId.
Definition SnapEngine.h:389
void windowOpened(const QString &windowId, const QString &screenId, int minWidth, int minHeight) override
A new window appeared on this engine's screen.
SnapState * stateForWindow(const QString &windowId)
The SnapState that owns windowId (via the reverse map), or the global holder when the window is untra...
void spanFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Grow the focused window's zone span into the adjacent zone(s) in direction, or retract the opposite e...
PhosphorEngine::UnfloatResult resolveUnfloatGeometry(const QString &windowId, const QString &fallbackScreen) const
The ABI-stable signature exported before the confinement parameter.
void applyGeometriesBatch(const PhosphorProtocol::WindowGeometryList &geometries, const QString &action)
Window geometries the effect applies in one go; the engine itself emits only action="rotate".
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...
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 restatementGeometryRequested(const QString &windowId, int x, int y, int width, int height, const QString &zoneId, const QString &screenId)
Re-states a placement the window already has (relayed as PlacementPurpose::Restatement).
PhosphorEngine::MembershipReconcileResult releaseWindowOutsideSpan(const QString &windowId, const QString &screenId, const PhosphorEngine::DesktopSpan &span)
Silently release every membership windowId holds outside where it actually is: one off screenId (in a...
void fullscreenHandBackRequested(const QString &windowId)
a user verb with no apply: end its fullscreen
void pruneStatesForActivities(const QStringList &validActivities) override
void setWindowRegistry(QObject *registry) override
Attach the daemon's shared window registry.
void resnapToNewLayoutRequested(const QString &resnapData)
Batched resnap data, committed by SnapAdaptor's applyEngineResnap relay.
void renameScreen(const QString &oldPhysicalId, const QString &newPhysicalId)
Re-file every membership keyed on monitor oldPhysicalId (its virtual screens too) under the same key ...
std::optional< PhosphorEngine::PlacementStateKey > heldKeyForWindow(const QString &windowId) const override
The key of the store that genuinely holds windowId, in ANY context: membership-grade,...
std::optional< PhosphorEngine::WindowPlacement > capturePlacement(const QString &windowId) const override
Unified placement model — report this window's current snap state (snapped or floated) for persistenc...
void remapDesktops(const PhosphorEngine::DesktopRemap &remap) override
OPTIONAL: KWin's desktop list changed (a removal, an insert or a reorder).
bool isSnapModeScreen(const QString &screenId) const
Whether screenId resolves to SNAPPING mode in its current (desktop, activity) context — the same verd...
void pushFocusedToEmptyZone(const PhosphorEngine::NavigationContext &ctx)
Move the focused window to the first empty zone on the screen it acts on.
void applyNoMatchFloatDefault(const QString &windowId, const QString &screenId, PhosphorEngine::RestoreReason reason, bool placedBefore)
The no-match float-default terminal of resolveWindowRestore for a caller outside it.
std::optional< PhosphorEngine::PlacementStateKey > keyForState(const SnapState *state) const
The key state is filed under; nullopt for the global holder or a foreign store.
void commitMultiZoneSnap(const QString &windowId, const QStringList &zoneIds, const QString &screenId, PhosphorEngine::SnapIntent intent=PhosphorEngine::SnapIntent::UserInitiated, int virtualDesktop=0)
void setTilingEngineLiveResolver(TilingEngineLiveResolver resolver)
Definition SnapEngine.h:254
std::function< PhosphorZones::AssignmentEntry::Mode(const QString &screenId)> LiveModeResolver
The daemon's live mode resolver (its ScreenModeRouter, an unclaimed tiling mode downgraded to Snappin...
Definition SnapEngine.h:234
void resnapCurrentAssignments(const QString &screenFilter, const QSet< QString > &onlyWindows, ResnapFeedback feedback)
PhosphorEngine::UnfloatResult resolveUnfloatGeometry(const QString &windowId, const QString &fallbackScreen, bool confineToFallbackScreen) const
Not-found when the RECORDED (raw) home screen names a different physical monitor than fallbackScreen,...
void setShouldRestorePredicate(ShouldRestorePredicate predicate)
Inject the disabled-context placement gate.
Definition SnapEngine.h:167
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateSnapAllWindowEntries(const QStringList &windowIds, const QString &screenId) const
void windowClosed(const QString &windowId) override
A no-op: snap's close is WindowTrackingService-driven (WTS::windowClosed clears the window's SnapStat...
bool isWindowExcludedByRule(const QString &windowId, const QString &screenHint=QString()) const
isWindowExcluded without the minimum-window-size floor: the Exclude rule set alone,...
void snapAllWindows(const PhosphorEngine::NavigationContext &ctx) override
Snap every unmanaged window on the screen.
QStringList parkOutput(const QString &physicalScreenId) override
Copy every context of physicalScreenId (each of its virtual screens) into the park,...
bool migrateWindowToScreen(const QString &windowId, const QString &newScreenId)
Re-home a tracked window onto the store for newScreenId's current context.
void seedPersistedDesktopZones(const QString &windowId, const PhosphorEngine::EngineSlot &slot, const QString &screenId, int restoreDesktop, const QString &activity)
Re-seed a restored record's other desktops' zones into their stores under activity,...
void rotateWindows(bool clockwise, const PhosphorEngine::NavigationContext &ctx) override
Rotate snapped windows through the layout's zone order, dispatched via IPlacementEngine.
void resnapToNewLayout(ResnapFeedback feedback)
const PhosphorEngine::IPlacementState * stateForScreen(const QString &screenId) const override
void applyGeometryRequested(const QString &windowId, int x, int y, int width, int height, const QString &zoneId, const QString &screenId, bool sizeOnly)
Places the window a user verb is about (relayed as PlacementPurpose::UserVerb).
QString lastActiveScreenId() const
Last screen the engine saw via windowFocused (each activation and each focused-screen report).
Definition SnapEngine.h:962
bool holdsWindowInState(const QString &windowId, const SnapState *state) const
Whether state holds a MEMBERSHIP for windowId, not a leftover from before a re-key (the WTS facade's ...
void releaseWindowOffScreen(const QString &windowId, const QString &keepScreenId) override
Silently release every membership off keepScreenId (every one when it is empty): zone with the last-u...
QStringList floatingWindows() const
void resnapToNewLayout()
Resnap a switch's populated buffer into the new layouts: a window back in the layout it was snapped i...
QString navigationScreenFor(const QString &windowId, const QString &preferredScreen) const
The screen a navigation verb on windowId acts on: its stored screen when snapped, else preferredScree...
bool isWindowTracked(const QString &windowId) const override
Whether some store of this engine holds the window, in any context: snapped, snap-floated,...
void windowFocused(const QString &windowId, const QString &screenId) override
A window gained focus (called when the compositor reports activation).
PhosphorProtocol::SnapAllResultList calculateSnapAllWindows(const QStringList &windowIds, const QString &screenId)
Calculate snap-all-windows assignments without applying them.
SnapState * stateForWindowOnScreen(const QString &windowId, const QString &screenId, int desktop=0)
Resolve-or-register the state windowId's data belongs in for a write on screenId, and return it.
void cycleFocus(bool forward, const PhosphorEngine::NavigationContext &ctx) override
Cycle keyboard focus forward/backward through the windows stacked in the focused window's zone on its...
void uncommitSnap(const QString &windowId)
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapEntriesFromAutotileOrder(const QStringList &autotileWindowOrder, const QString &screenId, const QStringList &preClaimedZoneIds={})
Calculate resnap entries from autotile order WITHOUT emitting signal.
void commitSnap(const QString &windowId, const QString &zoneId, const QString &screenId, PhosphorEngine::SnapIntent intent=PhosphorEngine::SnapIntent::UserInitiated, int virtualDesktop=0)
virtualDesktop pins the assignment to a specific 1-based desktop; 0 (default) records it on screenId'...
QString zoneForWindow(const QString &windowId) const
The zone of windowId's PRIMARY membership (the store in view when it is a member there,...
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 SnapEngine.h:270
SnapState * globalState() const
The global-scalar holder (last-used-zone + user-snapped classes).
Definition SnapEngine.h:553
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapFromAutotileOrder(const QStringList &autotileWindowOrder, const QString &screenId, const QStringList &preClaimedZoneIds={}) const
void toggleWindowFloat(const QString &windowId, const QString &screenId) override
Toggle between managed and floating.
void pruneStatesForDesktop(int removedDesktop) override
void setAutotileEngine(PhosphorEngine::IPlacementEngine *engine)
Set the autotile engine for screen ownership checks.
std::function< bool(PhosphorZones::AssignmentEntry::Mode mode, const QString &screenId)> TilingEngineLiveResolver
INERT, kept for ABI: nothing reads it since snap no longer defers an open to another engine's reclaim...
Definition SnapEngine.h:252
PhosphorProtocol::WindowGeometryList applyBatchAssignments(const QVector< PhosphorEngine::ZoneAssignmentEntry > &entries, PhosphorEngine::SnapIntent intent=PhosphorEngine::SnapIntent::UserInitiated, std::function< QString()> fallbackScreenResolver={})
void setNavigationStateProvider(INavigationStateProvider *provider)
Wire the typed navigation-state provider.
QString entryZoneForCrossing(const QString &direction, const QString &neighbourScreen, int desktop) const
QList< SnapState * > allSnapStates() const
Every SnapState the engine owns, including the global holder, for whole-store enumerations (occupied ...
PhosphorEngine::SnapResult calculateSnapToPlacementRule(const QString &windowId, const QString &screenId, bool isSticky, const PlacementDirective &directive) const
void forgetWindow(const QString &windowId)
Drop every membership windowId holds AND its data in each member store (closed / removed): a window o...
void pruneStatesForRemovedScreen(const QString &physicalScreenId) override
Prune per-(screen, desktop, activity) state for a PHYSICALLY REMOVED output (monitor hot-unplug),...
void setZoneAdjacencyResolver(IZoneAdjacencyResolver *resolver)
Set typed zone-adjacency resolver for directional navigation.
const SnapState * stateForWindow(const QString &windowId) const
void setCrossSurfaceResolver(PhosphorEngine::ICrossSurfaceResolver *resolver) override
Inject the cross-surface resolver (neighbour output / desktop lookup), threaded into the navigation t...
void swapFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Swap the focused window with the window in the adjacent zone in direction, exchanging whole zone sets...
std::function< PhosphorZones::AssignmentEntry::Mode(const QString &, int, const QString &)> ContextModeResolver
The mode the daemon resolves for a (screenId, desktop, activity) context, in view or hidden: readoptP...
Definition SnapEngine.h:243
SnapEngine(PhosphorZones::LayoutRegistry *layoutManager, PhosphorEngine::IWindowTrackingService *windowTracker, PhosphorZones::IZoneDetector *zoneDetector, PhosphorEngine::IVirtualDesktopManager *vdm, QObject *parent=nullptr)
Pure snap-mode navigation target resolver.
Definition snapnavigationtargets.h:118
Per-screen snap placement state.
Definition SnapState.h:36
Abstract interface for zone detection + highlight lifecycle.
Definition IZoneDetector.h:84
Manual zone-layout registry + per-context assignment store.
Definition LayoutRegistry.h:87
Definition DesktopRemap.h:12
SnapIntent
Definition EngineTypes.h:62
@ UserInitiated
Definition EngineTypes.h:63
RestoreReason
Why a snap restore is being resolved.
Definition EngineTypes.h:119
@ Open
a window OPEN: session restore, deferred-routing flush
Definition EngineTypes.h:120
WindowKind
Coarse structural classification of a window, carried on the open and close wire calls and on the pla...
Definition EngineTypes.h:77
@ Unknown
Definition EngineTypes.h:78
std::function< DesktopSpan(const QString &)> DesktopSpanQuery
Answers a window's DesktopSpan.
Definition EngineTypes.h:292
QList< SnapAllResultEntry > SnapAllResultList
Definition NavigationTypes.h:38
QList< WindowGeometryEntry > WindowGeometryList
Definition WindowTypes.h:102
Definition SnapStateResolver.h:16
Definition IWindowTrackingService.h:24
The contexts a window occupies, as the per-desktop membership pass reads them: which desktops (x11 nu...
Definition EngineTypes.h:258
One engine's view of a window: which managed slot it occupies (or that it is floating / unmanaged) in...
Definition WindowPlacement.h:41
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
Definition EngineTypes.h:176
Definition EngineTypes.h:210
One window's single, authoritative placement record — the unit of the unified, engine-agnostic restor...
Definition WindowPlacement.h:96
D-Bus struct for window state: (sssbsasb).
Definition WindowTypes.h:134
The evaluation input — an attribute bag matched against a MatchExpression.
Definition WindowQuery.h:37
What a matched open-placement rule directs for an opening window.
Definition PlacementDirective.h:47
Mode
Per-context engine selection.
Definition AssignmentEntry.h:213