6#include <phosphorsnapengine_export.h>
16#include <PhosphorWindowRules/RuleEvaluator.h>
41class INavigationStateProvider;
42class IZoneAdjacencyResolver;
43class SnapNavigationTargetResolver;
68 QObject* parent =
nullptr);
94 int targetDesktop)
const;
120 using IPlacementEngine::windowOpened;
121 void windowOpened(const QString& windowId, const QString& screenId,
int minWidth,
int minHeight) override;
159 m_shouldRestorePredicate = std::move(predicate);
202 m_restorePositionPredicate = std::move(predicate);
232 m_managedRestorePredicate = std::move(predicate);
248 m_floatPredicate = std::move(predicate);
271 m_placementZonesResolver = std::move(resolver);
275 void windowFocused(
const QString& windowId,
const QString& screenId)
override;
284 return QStringLiteral(
"snap");
333 QVector<PhosphorEngine::ZoneAssignmentEntry>
335 const QStringList& preClaimedZoneIds = {});
497 std::optional<PhosphorEngine::WindowPlacement>
capturePlacement(
const QString& windowId)
const override;
530 void commitSnap(
const QString& windowId,
const QString& zoneId,
const QString& screenId,
532 int virtualDesktop = 0);
536 int virtualDesktop = 0);
549 const QString& fallbackScreen)
const;
554 std::function<QString()> fallbackScreenResolver = {});
561 bool isSticky)
const;
563 bool isSticky)
const;
565 bool isSticky)
const;
572 QVector<PhosphorEngine::ZoneAssignmentEntry>
574 QVector<PhosphorEngine::ZoneAssignmentEntry>
576 const QStringList& preClaimedZoneIds = {})
const;
578 const QString& screenId)
const;
580 const QString& screenFilter = QString())
const;
589 return m_effectReportedWindows;
634 m_saveFn = std::move(saveFn);
635 m_loadFn = std::move(loadFn);
644 return m_lastActiveScreenId;
680 std::function<std::optional<PhosphorWindowRules::WindowQuery>(
const QString& windowId)>;
687 m_exclusionQueryProvider = std::move(provider);
724 const QString& screenId,
bool sizeOnly);
755 void commitSnapImpl(
const QString& windowId,
const QStringList& zoneIds,
const QString& screenId,
763 QString resolveUnfloatScreen(
const QString& primaryScreen,
const QString& fallbackScreen)
const;
770 QPointer<QObject> m_autotileEngineObj;
784 std::unique_ptr<SnapNavigationTargetResolver> m_targetResolver;
785 QSet<QString> m_effectReportedWindows;
794 bool unfloatToZone(
const QString& windowId,
const QString& screenId);
795 bool applyGeometryForFloat(
const QString& windowId,
const QString& screenId);
818 bool tryCrossDesktopMove(
const QString& windowId,
const QString& direction,
const QString& screenId);
827 bool tryCrossModeOutput(
const QString& windowId,
const QString& direction,
const QString& screenId,
bool swap);
836 bool tryCrossDesktopFocus(
const QString& focusedWindowId,
const QString& direction,
const QString& screenId);
843 bool isWindowExcludedForAction(
const QString& windowId,
const QString& action,
const QString& screenId);
852 bool evaluateExcludeRules(
const PhosphorWindowRules::WindowQuery& query)
const;
866 const PhosphorWindowRules::WindowRuleSet* m_excludeRuleSet =
nullptr;
875 mutable std::optional<PhosphorWindowRules::RuleEvaluator> m_excludeEvaluator;
880 ExclusionQueryProvider m_exclusionQueryProvider{};
883 std::function<void()> m_saveFn;
884 std::function<void()> m_loadFn;
887 QString m_lastActiveScreenId;
896 ShouldRestorePredicate m_shouldRestorePredicate{};
902 RestorePositionPredicate m_restorePositionPredicate{};
907 ManagedRestorePredicate m_managedRestorePredicate{};
911 FloatPredicate m_floatPredicate{};
916 PlacementZonesResolver m_placementZonesResolver{};
Resolves the neighbouring surface — output or virtual desktop — in a direction, for cross-surface win...
Definition ICrossSurfaceResolver.h:21
Unified placement engine interface.
Definition IPlacementEngine.h:61
Per-screen placement state contract.
Definition IPlacementState.h:26
Definition ISnapSettings.h:12
Definition IVirtualDesktopManager.h:13
Definition IWindowTrackingService.h:34
Abstract base class for placement engines.
Definition PlacementEngineBase.h:30
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:28
Engine for manual zone-based window snapping.
Definition SnapEngine.h:61
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.
void focusInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Walk to the adjacent window in direction and transfer keyboard focus.
QString entryZoneForCrossing(const QString &direction, const QString &neighbourScreen) const
The zone a window ENTERS when it crosses onto neighbourScreen moving in direction: the first zone on ...
PhosphorEngine::SnapResult calculateSnapToPlacementRule(const QString &windowId, const QString &windowScreenName, bool isSticky) const
void markWindowReported(const QString &windowId)
void setPersistenceDelegate(std::function< void()> saveFn, std::function< void()> loadFn)
Set persistence callbacks for save/load.
Definition SnapEngine.h:632
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:222
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateRotation(bool clockwise, const QString &screenFilter=QString()) const
void setRestorePositionPredicate(RestorePositionPredicate predicate)
Inject the unsnapped-position-restore gate.
Definition SnapEngine.h:200
void setExclusionQueryProvider(ExclusionQueryProvider provider)
Inject the exclusion query provider.
Definition SnapEngine.h:685
void setManagedRestorePredicate(ManagedRestorePredicate predicate)
Inject the managed (snapped-to-zone) restore gate.
Definition SnapEngine.h:230
void emitBatchedResnap(const QVector< PhosphorEngine::ZoneAssignmentEntry > &entries)
Emit a single batched resnapToNewLayoutRequested signal.
void setWindowFloat(const QString &windowId, bool shouldFloat) override
Set floating state explicitly (directional, not toggle).
const QSet< QString > & effectReportedWindows() const
Definition SnapEngine.h:587
PhosphorEngine::SnapResult calculateSnapToLastZone(const QString &windowId, const QString &windowScreenId, bool isSticky) const
int pruneStaleWindows(const QSet< QString > &aliveWindowIds) override
Drop any per-engine bookkeeping for windows not in aliveWindowIds.
bool isAppIdExcluded(const QString &appId) const
True if appId matches an enabled Exclude-action WindowRule resolved against an appId-ONLY WindowQuery...
void reapplyManagedWindowAppearance() override
Re-emit the snap geometry for every currently-snapped (non-floating) window so the compositor re-appl...
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.
SnapState * snapState() const
Definition SnapEngine.h:407
std::function< bool(const QString &windowId)> FloatPredicate
Predicate deciding whether an opening window should start FLOATING because a "Float this app" window ...
Definition SnapEngine.h:244
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, or empty if the window isn't tracked by ...
void setPlacementZonesResolver(PlacementZonesResolver resolver)
Definition SnapEngine.h:269
void reapplyLayout(const PhosphorEngine::NavigationContext &ctx) override
Re-apply the current layout to all managed windows.
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 ctx.screenId.
void restoreFocusedWindow(const PhosphorEngine::NavigationContext &ctx) override
Restore the focused window to its captured pre-snap size and unsnap.
std::function< bool(const QString &screenId)> ShouldRestorePredicate
Predicate consulted on the auto-snap entry path to suppress zone restores onto a context the user dis...
Definition SnapEngine.h:148
void windowFloatingClearedForSnap(const QString &windowId, const QString &screenId)
Floating state cleared as part of a commit. WTA relays as windowFloatingChanged(id,...
void resnapFromAutotileOrder(const QStringList &autotileWindowOrder, const QString &screenId)
Resnap windows using autotile window order as assignment source.
PhosphorEngine::IPlacementState * stateForScreen(const QString &screenId) override
Per-screen state object for the given screen.
std::pair< QString, QRect > resolveCrossDesktopZone(const QString ¤tZoneId, 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 snapAllWindows(const QString &screenId)
Request the KWin effect to collect and snap all unsnapped windows.
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 saveState() override
void setFloatPredicate(FloatPredicate predicate)
Definition SnapEngine.h:246
void moveFocusedToPosition(int zoneNumber, const PhosphorEngine::NavigationContext &ctx) override
Move the focused window to the layout zone with zoneNumber (1-based) on ctx.screenId.
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
Release ownership of a window WITHOUT modifying its geometry.
void moveFocusedInDirection(const QString &direction, const PhosphorEngine::NavigationContext &ctx) override
Move the focused window into the adjacent zone in direction (displacing or filling the target).
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 plus an optional RouteToScreen t...
Definition SnapEngine.h:267
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:192
QString windowInZoneOnScreen(const QString &zoneId, const QString &screenId) const
The window snapped to zoneId on screenId (the daemon's stored assignment pins it to that output),...
QString engineId() const override
Stable engine identity for HandoffContext.fromEngineId.
Definition SnapEngine.h:282
PhosphorEngine::UnfloatResult resolveUnfloatGeometry(const QString &windowId, const QString &fallbackScreen) const
void applyGeometriesBatch(const PhosphorProtocol::WindowGeometryList &geometries, const QString &action)
Batch of window-geometry updates, applied by the KWin effect in a single operation.
std::function< std::optional< PhosphorWindowRules::WindowQuery >(const QString &windowId)> ExclusionQueryProvider
Provider that builds the full WindowQuery (window class / title / role / frame size / flags) for a li...
Definition SnapEngine.h:680
void resnapToNewLayoutRequested(const QString &resnapData)
Batched resnap data (routed through WTA::handleBatchedResnap for bookkeeping)
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...
bool isWindowExcluded(const QString &windowId) const
Resolve exclusion for a live windowId using the FULL window attributes when the exclusion query provi...
void pushFocusedToEmptyZone(const PhosphorEngine::NavigationContext &ctx)
Move the focused window to the first empty zone on ctx.screenId.
void commitMultiZoneSnap(const QString &windowId, const QStringList &zoneIds, const QString &screenId, PhosphorEngine::SnapIntent intent=PhosphorEngine::SnapIntent::UserInitiated, int virtualDesktop=0)
void setExcludeRuleSet(const PhosphorWindowRules::WindowRuleSet *ruleSet)
Wire the daemon's filtered Exclude rule set into the snap engine.
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateSnapAllWindowEntries(const QStringList &windowIds, const QString &screenId) const
void windowClosed(const QString &windowId) override
A window was closed.
void snapAllWindows(const PhosphorEngine::NavigationContext &ctx) override
Snap every unmanaged window on the screen.
void rotateWindows(bool clockwise, const PhosphorEngine::NavigationContext &ctx) override
Rotate snapped windows through the layout's zone order, dispatched via IPlacementEngine.
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapFromCurrentAssignments(const QString &screenFilter=QString()) const
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)
Daemon-driven geometry application (used by autotile float restore)
QString lastActiveScreenId() const
Last screen the engine saw via windowFocused.
Definition SnapEngine.h:642
void resnapToNewLayout()
Resnap windows from previous layout to current layout after layout switch.
bool isWindowTracked(const QString &windowId) const override
Whether this engine considers the window owned (snapped, snap-floated, or otherwise carried in SnapSt...
void windowFocused(const QString &windowId, const QString &screenId) override
A window gained focus (called when the compositor reports activation).
void loadState() override
PhosphorProtocol::SnapAllResultList calculateSnapAllWindows(const QStringList &windowIds, const QString &screenId)
Calculate snap-all-windows assignments without applying them.
void cycleFocus(bool forward, const PhosphorEngine::NavigationContext &ctx) override
Cycle keyboard focus forward/backward through managed windows in the active zone (or the layout cycle...
void uncommitSnap(const QString &windowId)
PhosphorEngine::SnapResult resolveWindowRestore(const QString &windowId, const QString &screenId, bool sticky, PhosphorEngine::WindowKind kind=PhosphorEngine::WindowKind::Unknown)
Resolve auto-snap for a newly opened window.
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 the windo...
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 setAutotileEngine(PhosphorEngine::IPlacementEngine *engine)
Set the autotile engine for screen ownership checks.
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 currentActivity() const
void setZoneAdjacencyResolver(IZoneAdjacencyResolver *resolver)
Set typed zone-adjacency resolver for directional navigation.
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 whatever's in the adjacent zone in direction.
void resnapCurrentAssignments(const QString &screenFilter=QString())
Resnap windows to their current zone assignments (re-apply geometries)
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:79
Per-screen snap placement state.
Definition SnapState.h:33
Abstract interface for zone detection + highlight lifecycle.
Definition IZoneDetector.h:84
Manual zone-layout registry + per-context assignment store.
Definition LayoutRegistry.h:78
Represents a collection of zones that form a layout.
Definition Layout.h:40
SnapIntent
Definition EngineTypes.h:32
WindowKind
Coarse structural classification for the snap-restore consume gate.
Definition EngineTypes.h:39
constexpr QLatin1String LayoutRegistry("org.plasmazones.LayoutRegistry")
QList< SnapAllResultEntry > SnapAllResultList
Definition NavigationTypes.h:38
QList< WindowGeometryEntry > WindowGeometryList
Definition WindowTypes.h:51
Definition WindowTrackingService.h:38
Definition IWindowTrackingService.h:23
Context for a cross-engine window handoff.
Definition IPlacementEngine.h:385
Target window + screen for a navigation or lifecycle operation.
Definition NavigationContext.h:18
Definition EngineTypes.h:84
Definition EngineTypes.h:109
Per-side edge gap values (resolved, non-negative pixel values)
Definition EdgeGaps.h:27
D-Bus struct for window state: (sssbsasb)
Definition WindowTypes.h:77
What a matched open-placement rule directs for an opening window.
Definition PlacementDirective.h:34