#pragma once #include "../../helpers/math/Math.hpp" #include "../../helpers/math/Direction.hpp" #include "../../helpers/memory/Memory.hpp" #include "../../desktop/DesktopTypes.hpp" #include "../LayoutManager.hpp" #include #include namespace Layout { enum eRecalculateReason : uint8_t { RECALCULATE_REASON_UNKNOWN, // when the recalculate reason is unknown or not important to preserve RECALCULATE_REASON_WORKSPACE_CHANGE, RECALCULATE_REASON_SPECIAL_WORKSPACE_TOGGLE, RECALCULATE_REASON_TOGGLE_FULLSCREEN, RECALCULATE_REASON_INVALIDATE_MONITOR_GEOMETRIES, RECALCULATE_REASON_RENDER_MOINTOR, }; eRecalculateReason recalcMonitorReasonToRecalcReason(CLayoutManager::eRecalculateMonitorReason reason); class ITarget; class CAlgorithm; class CSpace { public: static SP create(PHLWORKSPACE w); ~CSpace() = default; void add(SP t); void remove(SP t); void move(SP t, std::optional focalPoint = std::nullopt); void swap(SP a, SP b); SP getNextCandidate(SP old); void setAlgorithmProvider(SP algo); void recheckWorkArea(); eFullscreenRequestResult setFullscreen(SP t, eFullscreenMode currentEffectiveMode, eFullscreenMode mode); void moveTargetInDirection(SP t, Math::eDirection dir, bool silent); void recalculate(eRecalculateReason reason = RECALCULATE_REASON_UNKNOWN); void toggleTargetFloating(SP t); Config::ErrorResult layoutMsg(const std::string_view& sv); std::optional predictSizeForNewTiledTarget(); const CBox& workArea(bool floating = false) const; PHLWORKSPACE workspace() const; CBox targetPositionLocal(SP t) const; void resizeTarget(const Vector2D& Δ, SP target, eRectCorner corner = CORNER_NONE); void moveTarget(const Vector2D& Δ, SP target); void setTargetGeom(const CBox& box, SP target); // only for float SP algorithm() const; const std::vector>& targets() const; private: CSpace(PHLWORKSPACE parent); WP m_self; std::vector> m_targets; SP m_algorithm; PHLWORKSPACEREF m_parent; // work area is in global coords CBox m_workArea, m_floatingWorkArea; // for recalc CHyprSignalListener m_geomUpdateCallback; }; bool isHardRecalculateReason(eRecalculateReason reason); };