mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-11 11:05:59 +01:00
492f36f7df
* Added center orientation to master layout to improve experience on ultra widescreen monitors. * Added support for orientationcenter layout message for master layout * Added ability to optionally always center master window when in centered master mode.
86 lines
3.1 KiB
C++
86 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "IHyprLayout.hpp"
|
|
#include <vector>
|
|
#include <list>
|
|
#include <deque>
|
|
#include <any>
|
|
|
|
enum eFullscreenMode : uint8_t;
|
|
|
|
//orientation determines which side of the screen the master area resides
|
|
enum eOrientation : uint8_t
|
|
{
|
|
ORIENTATION_LEFT = 0,
|
|
ORIENTATION_TOP,
|
|
ORIENTATION_RIGHT,
|
|
ORIENTATION_BOTTOM,
|
|
ORIENTATION_CENTER
|
|
};
|
|
|
|
struct SMasterNodeData {
|
|
bool isMaster = false;
|
|
float percMaster = 0.5f;
|
|
|
|
CWindow* pWindow = nullptr;
|
|
|
|
Vector2D position;
|
|
Vector2D size;
|
|
|
|
float percSize = 1.f; // size multiplier for resizing children
|
|
|
|
int workspaceID = -1;
|
|
|
|
bool operator==(const SMasterNodeData& rhs) const {
|
|
return pWindow == rhs.pWindow;
|
|
}
|
|
};
|
|
|
|
struct SMasterWorkspaceData {
|
|
int workspaceID = -1;
|
|
eOrientation orientation = ORIENTATION_LEFT;
|
|
|
|
bool operator==(const SMasterWorkspaceData& rhs) const {
|
|
return workspaceID == rhs.workspaceID;
|
|
}
|
|
};
|
|
|
|
class CHyprMasterLayout : public IHyprLayout {
|
|
public:
|
|
virtual void onWindowCreatedTiling(CWindow*);
|
|
virtual void onWindowRemovedTiling(CWindow*);
|
|
virtual bool isWindowTiled(CWindow*);
|
|
virtual void recalculateMonitor(const int&);
|
|
virtual void recalculateWindow(CWindow*);
|
|
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
|
virtual void switchWindows(CWindow*, CWindow*);
|
|
virtual void alterSplitRatio(CWindow*, float, bool);
|
|
virtual std::string getLayoutName();
|
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
|
|
|
virtual void onEnable();
|
|
virtual void onDisable();
|
|
|
|
private:
|
|
std::list<SMasterNodeData> m_lMasterNodesData;
|
|
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
|
|
|
|
bool m_bForceWarps = false;
|
|
|
|
int getNodesOnWorkspace(const int&);
|
|
void applyNodeDataToWindow(SMasterNodeData*);
|
|
SMasterNodeData* getNodeFromWindow(CWindow*);
|
|
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
|
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
|
void calculateWorkspace(const int&);
|
|
CWindow* getNextWindow(CWindow*, bool);
|
|
int getMastersOnWorkspace(const int&);
|
|
bool prepareLoseFocus(CWindow*);
|
|
void prepareNewFocus(CWindow*, bool inherit_fullscreen);
|
|
|
|
friend struct SMasterNodeData;
|
|
friend struct SMasterWorkspaceData;
|
|
};
|