6#include <phosphorsnapengine_export.h>
30class INavigationStateProvider;
31class IZoneAdjacencyResolver;
32class SnapNavigationTargetResolver;
57 QObject* parent =
nullptr);
79 using IPlacementEngine::windowOpened;
80 void windowOpened(const QString& windowId, const QString& screenId,
int minWidth,
int minHeight) override;
118 m_shouldRestorePredicate = std::move(predicate);
122 void windowFocused(
const QString& windowId,
const QString& screenId)
override;
131 return QStringLiteral(
"snap");
175 QVector<PhosphorEngine::ZoneAssignmentEntry>
351 void commitSnap(
const QString& windowId,
const QString& zoneId,
const QString& screenId,
364 std::function<QString()> fallbackScreenResolver = {});
371 bool isSticky)
const;
373 bool isSticky)
const;
375 bool isSticky)
const;
385 QVector<PhosphorEngine::ZoneAssignmentEntry>
387 QVector<PhosphorEngine::ZoneAssignmentEntry>
390 const QString& screenId)
const;
392 const QString& screenFilter = QString())
const;
405 return restoreSnapFloating(windowId);
409 for (
const QString& windowId : windowIds) {
410 m_savedSnapFloatingWindows.remove(windowId);
415 saveSnapFloating(windowId);
419 clearSavedSnapFloating();
429 return m_effectReportedWindows;
474 m_saveFn = std::move(saveFn);
475 m_loadFn = std::move(loadFn);
484 return m_lastActiveScreenId;
500 const QString& screenId,
bool sizeOnly);
528 GapParams resolveGapParams()
const;
530 void commitSnapImpl(
const QString& windowId,
const QStringList& zoneIds,
const QString& screenId,
538 QPointer<QObject> m_autotileEngineObj;
551 std::unique_ptr<SnapNavigationTargetResolver> m_targetResolver;
552 QSet<QString> m_savedSnapFloatingWindows;
553 QSet<QString> m_effectReportedWindows;
562 bool unfloatToZone(
const QString& windowId,
const QString& screenId);
563 bool applyGeometryForFloat(
const QString& windowId,
const QString& screenId);
580 bool isWindowExcludedForAction(
const QString& windowId,
const QString& action,
const QString& screenId);
583 std::function<void()> m_saveFn;
584 std::function<void()> m_loadFn;
587 QString m_lastActiveScreenId;
593 ShouldRestorePredicate m_shouldRestorePredicate{};
Unified placement engine interface.
Definition IPlacementEngine.h:57
Per-screen placement state contract.
Definition IPlacementState.h:26
Definition ISnapSettings.h:13
Definition IVirtualDesktopManager.h:11
Definition IWindowTrackingService.h:33
Abstract base class for placement engines.
Definition PlacementEngineBase.h:37
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:50
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.
void markWindowReported(const QString &windowId)
void setPersistenceDelegate(std::function< void()> saveFn, std::function< void()> loadFn)
Set persistence callbacks for save/load.
Definition SnapEngine.h:472
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateRotation(bool clockwise, const QString &screenFilter=QString()) const
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).
void saveSnapFloating(const QString &windowId)
const QSet< QString > & effectReportedWindows() const
Definition SnapEngine.h:427
PhosphorEngine::SnapResult calculateRestoreFromSession(const QString &windowId, const QString &screenId, bool isSticky, PhosphorEngine::WindowKind kind=PhosphorEngine::WindowKind::Unknown) const
PhosphorEngine::SnapResult calculateSnapToLastZone(const QString &windowId, const QString &windowScreenId, bool isSticky) const
int pruneStaleWindows(const QSet< QString > &aliveWindowIds) override
void clearSavedSnapFloating()
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 calculateSnapToAppRule(const QString &windowId, const QString &windowScreenName, bool isSticky) const
SnapState * snapState() const
Definition SnapEngine.h:247
void saveModeFloat(const QString &windowId) override
Definition SnapEngine.h:413
void onWindowFloated(const QString &windowId) override
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 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:107
void onWindowUnfloated(const QString &windowId) override
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.
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.
void saveState() override
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()
void clearSavedFloatingForWindows(const QStringList &windowIds) override
Remove saved floating state for the given windows (per-window, not bulk clear).
Definition SnapEngine.h:407
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,...
bool isEnabled() const noexcept override
True when snapping is globally enabled.
QString engineId() const override
Stable engine identity for HandoffContext.fromEngineId.
Definition SnapEngine.h:129
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapFromAutotileOrder(const QStringList &autotileWindowOrder, const QString &screenId) const
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 (rotate,...
void resnapToNewLayoutRequested(const QString &resnapData)
Batched resnap data (routed through WTA::handleBatchedResnap for bookkeeping)
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)
void onWindowClaimed(const QString &windowId) override
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateSnapAllWindowEntries(const QStringList &windowIds, const QString &screenId) const
void windowClosed(const QString &windowId) override
A window was closed.
void onWindowReleased(const QString &windowId) override
void snapAllWindows(const PhosphorEngine::NavigationContext &ctx) override
Snap every unmanaged window on the screen.
QVector< PhosphorEngine::ZoneAssignmentEntry > calculateResnapEntriesFromAutotileOrder(const QStringList &autotileWindowOrder, const QString &screenId)
Calculate resnap entries from autotile order WITHOUT emitting signal.
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
bool restoreSavedModeFloat(const QString &windowId) override
Definition SnapEngine.h:403
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:482
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.
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 clearSavedModeFloating() override
Definition SnapEngine.h:417
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)
bool restoreSnapFloating(const QString &windowId)
void commitSnap(const QString &windowId, const QString &zoneId, const QString &screenId, PhosphorEngine::SnapIntent intent=PhosphorEngine::SnapIntent::UserInitiated)
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:54
Per-screen snap placement state.
Definition SnapState.h:32
Abstract interface for zone detection + highlight lifecycle.
Definition IZoneDetector.h:84
Manual zone-layout registry + per-context assignment store.
Definition LayoutRegistry.h:48
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:37
Definition IWindowTrackingService.h:22
Context for a cross-engine window handoff.
Definition IPlacementEngine.h:310
Target window + screen for a navigation or lifecycle operation.
Definition NavigationContext.h:18
Definition EngineTypes.h:66
Definition EngineTypes.h:85
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