2022-07-16 15:57:31 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "IHyprLayout.hpp"
|
2024-04-04 02:10:46 +02:00
|
|
|
#include "../desktop/DesktopTypes.hpp"
|
2023-09-04 16:45:58 +02:00
|
|
|
#include "../config/ConfigManager.hpp"
|
2022-12-10 22:59:16 +01:00
|
|
|
#include <vector>
|
2022-07-16 15:57:31 +02:00
|
|
|
#include <list>
|
|
|
|
#include <deque>
|
2022-12-16 18:17:31 +01:00
|
|
|
#include <any>
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2023-09-28 18:49:33 +02:00
|
|
|
enum eFullscreenMode : int8_t;
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2022-12-10 22:59:16 +01:00
|
|
|
//orientation determines which side of the screen the master area resides
|
2023-11-03 13:19:23 +01:00
|
|
|
enum eOrientation : uint8_t {
|
2022-12-10 22:59:16 +01:00
|
|
|
ORIENTATION_LEFT = 0,
|
|
|
|
ORIENTATION_TOP,
|
|
|
|
ORIENTATION_RIGHT,
|
2023-02-27 00:12:14 +01:00
|
|
|
ORIENTATION_BOTTOM,
|
|
|
|
ORIENTATION_CENTER
|
2022-12-10 22:59:16 +01:00
|
|
|
};
|
|
|
|
|
2022-07-16 15:57:31 +02:00
|
|
|
struct SMasterNodeData {
|
2024-04-27 13:43:12 +02:00
|
|
|
bool isMaster = false;
|
|
|
|
float percMaster = 0.5f;
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOWREF pWindow;
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
Vector2D position;
|
|
|
|
Vector2D size;
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
float percSize = 1.f; // size multiplier for resizing children
|
2022-11-10 13:05:22 +01:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
int workspaceID = -1;
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
bool ignoreFullscreenChecks = false;
|
2023-11-03 13:19:23 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
bool operator==(const SMasterNodeData& rhs) const {
|
2024-04-27 13:43:12 +02:00
|
|
|
return pWindow.lock() == rhs.pWindow.lock();
|
2022-07-16 15:57:31 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-10 22:59:16 +01:00
|
|
|
struct SMasterWorkspaceData {
|
2022-12-16 18:17:31 +01:00
|
|
|
int workspaceID = -1;
|
2022-12-10 22:59:16 +01:00
|
|
|
eOrientation orientation = ORIENTATION_LEFT;
|
|
|
|
|
2023-11-03 13:19:23 +01:00
|
|
|
//
|
|
|
|
bool operator==(const SMasterWorkspaceData& rhs) const {
|
2023-09-20 17:25:03 +02:00
|
|
|
return workspaceID == rhs.workspaceID;
|
2022-12-10 22:59:16 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-07-16 15:57:31 +02:00
|
|
|
class CHyprMasterLayout : public IHyprLayout {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2024-04-27 13:43:12 +02:00
|
|
|
virtual void onWindowCreatedTiling(PHLWINDOW, eDirection direction = DIRECTION_DEFAULT);
|
|
|
|
virtual void onWindowRemovedTiling(PHLWINDOW);
|
|
|
|
virtual bool isWindowTiled(PHLWINDOW);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual void recalculateMonitor(const int&);
|
2024-04-27 13:43:12 +02:00
|
|
|
virtual void recalculateWindow(PHLWINDOW);
|
|
|
|
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, PHLWINDOW pWindow = nullptr);
|
|
|
|
virtual void fullscreenRequestForWindow(PHLWINDOW, eFullscreenMode, bool);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
2024-04-27 13:43:12 +02:00
|
|
|
virtual SWindowRenderLayoutHints requestRenderHints(PHLWINDOW);
|
|
|
|
virtual void switchWindows(PHLWINDOW, PHLWINDOW);
|
|
|
|
virtual void moveWindowTo(PHLWINDOW, const std::string& dir, bool silent);
|
|
|
|
virtual void alterSplitRatio(PHLWINDOW, float, bool);
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual std::string getLayoutName();
|
2024-04-27 13:43:12 +02:00
|
|
|
virtual void replaceWindowDataWith(PHLWINDOW from, PHLWINDOW to);
|
2024-03-29 01:43:50 +01:00
|
|
|
virtual Vector2D predictSizeForNewWindowTiled();
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
virtual void onEnable();
|
|
|
|
virtual void onDisable();
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
private:
|
|
|
|
std::list<SMasterNodeData> m_lMasterNodesData;
|
2022-12-10 22:59:16 +01:00
|
|
|
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
|
2022-07-16 15:57:31 +02:00
|
|
|
|
2023-09-15 23:13:23 +02:00
|
|
|
bool m_bForceWarps = false;
|
|
|
|
|
2023-09-04 16:45:58 +02:00
|
|
|
void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, CVarList& vars);
|
|
|
|
void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle);
|
|
|
|
void runOrientationCycle(SLayoutMessageHeader& header, CVarList* vars, int next);
|
2024-04-07 00:49:38 +02:00
|
|
|
eOrientation getDynamicOrientation(PHLWORKSPACE);
|
2022-12-16 18:17:31 +01:00
|
|
|
int getNodesOnWorkspace(const int&);
|
2023-11-03 13:19:23 +01:00
|
|
|
void applyNodeDataToWindow(SMasterNodeData*);
|
2024-04-27 13:43:12 +02:00
|
|
|
SMasterNodeData* getNodeFromWindow(PHLWINDOW);
|
2022-12-16 18:17:31 +01:00
|
|
|
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
|
|
|
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
2024-04-02 21:32:39 +02:00
|
|
|
void calculateWorkspace(PHLWORKSPACE);
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW getNextWindow(PHLWINDOW, bool);
|
2022-12-16 18:17:31 +01:00
|
|
|
int getMastersOnWorkspace(const int&);
|
2022-07-16 15:57:31 +02:00
|
|
|
|
|
|
|
friend struct SMasterNodeData;
|
2022-12-10 22:59:16 +01:00
|
|
|
friend struct SMasterWorkspaceData;
|
|
|
|
};
|
2023-09-20 17:25:03 +02:00
|
|
|
|
|
|
|
template <typename CharT>
|
|
|
|
struct std::formatter<SMasterNodeData*, CharT> : std::formatter<CharT> {
|
|
|
|
template <typename FormatContext>
|
|
|
|
auto format(const SMasterNodeData* const& node, FormatContext& ctx) const {
|
|
|
|
auto out = ctx.out();
|
|
|
|
if (!node)
|
|
|
|
return std::format_to(out, "[Node nullptr]");
|
|
|
|
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size);
|
|
|
|
if (node->isMaster)
|
|
|
|
std::format_to(out, ", master");
|
2024-04-27 13:43:12 +02:00
|
|
|
if (!node->pWindow.expired())
|
|
|
|
std::format_to(out, ", window: {:x}", node->pWindow.lock());
|
2023-09-20 17:25:03 +02:00
|
|
|
return std::format_to(out, "]");
|
|
|
|
}
|
2024-03-13 03:09:20 +01:00
|
|
|
};
|