2023-04-12 01:33:00 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-07 03:22:17 -07:00
|
|
|
#include <hyprland/src/layout/IHyprLayout.hpp>
|
|
|
|
#include <list>
|
|
|
|
|
2023-05-16 03:02:26 -07:00
|
|
|
struct Hy3Node;
|
|
|
|
#include "TabGroup.hpp"
|
|
|
|
|
2023-04-12 01:33:00 -07:00
|
|
|
class Hy3Layout;
|
|
|
|
struct Hy3Node;
|
|
|
|
|
|
|
|
enum class Hy3GroupLayout {
|
|
|
|
SplitH,
|
|
|
|
SplitV,
|
|
|
|
Tabbed,
|
|
|
|
};
|
|
|
|
|
2023-06-28 18:11:48 -07:00
|
|
|
enum class Hy3NodeType {
|
|
|
|
Window,
|
|
|
|
Group,
|
|
|
|
};
|
|
|
|
|
2023-04-13 14:12:48 -07:00
|
|
|
enum class ShiftDirection {
|
|
|
|
Left,
|
|
|
|
Up,
|
|
|
|
Down,
|
|
|
|
Right,
|
|
|
|
};
|
|
|
|
|
2023-06-11 22:19:43 -07:00
|
|
|
enum class FocusShift {
|
|
|
|
Top,
|
|
|
|
Bottom,
|
|
|
|
Raise,
|
|
|
|
Lower,
|
|
|
|
Tab,
|
|
|
|
TabNode,
|
|
|
|
};
|
|
|
|
|
2023-06-15 00:27:02 -07:00
|
|
|
enum class TabFocus {
|
|
|
|
MouseLocation,
|
|
|
|
Left,
|
|
|
|
Right,
|
2023-06-28 12:58:31 -07:00
|
|
|
Index,
|
2023-06-15 00:27:02 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class TabFocusMousePriority {
|
|
|
|
Ignore,
|
|
|
|
Prioritize,
|
|
|
|
Require,
|
|
|
|
};
|
|
|
|
|
2023-04-12 01:33:00 -07:00
|
|
|
struct Hy3GroupData {
|
|
|
|
Hy3GroupLayout layout = Hy3GroupLayout::SplitH;
|
|
|
|
std::list<Hy3Node*> children;
|
2023-05-26 20:37:05 -07:00
|
|
|
bool group_focused = true;
|
|
|
|
Hy3Node* focused_child = nullptr;
|
2023-05-28 23:19:35 -07:00
|
|
|
Hy3TabGroup* tab_bar = nullptr;
|
2023-04-12 01:33:00 -07:00
|
|
|
|
2023-04-13 14:12:48 -07:00
|
|
|
bool hasChild(Hy3Node* child);
|
|
|
|
|
2023-04-12 01:33:00 -07:00
|
|
|
Hy3GroupData(Hy3GroupLayout layout);
|
2023-05-28 23:19:35 -07:00
|
|
|
~Hy3GroupData();
|
2023-04-13 14:12:48 -07:00
|
|
|
|
|
|
|
private:
|
2023-05-28 23:19:35 -07:00
|
|
|
Hy3GroupData(Hy3GroupData&&);
|
|
|
|
Hy3GroupData(const Hy3GroupData&) = delete;
|
2023-04-13 14:12:48 -07:00
|
|
|
|
|
|
|
friend class Hy3NodeData;
|
2023-04-12 01:33:00 -07:00
|
|
|
};
|
|
|
|
|
2023-04-13 14:12:48 -07:00
|
|
|
class Hy3NodeData {
|
|
|
|
public:
|
2023-06-28 18:11:48 -07:00
|
|
|
Hy3NodeType type;
|
2023-04-12 01:33:00 -07:00
|
|
|
union {
|
|
|
|
Hy3GroupData as_group;
|
|
|
|
CWindow* as_window;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const Hy3NodeData&) const;
|
|
|
|
|
|
|
|
Hy3NodeData();
|
2023-04-13 14:12:48 -07:00
|
|
|
~Hy3NodeData();
|
2023-06-28 16:24:10 -07:00
|
|
|
Hy3NodeData(CWindow* window);
|
|
|
|
Hy3NodeData(Hy3GroupLayout layout);
|
2023-04-13 14:12:48 -07:00
|
|
|
Hy3NodeData& operator=(CWindow*);
|
|
|
|
Hy3NodeData& operator=(Hy3GroupLayout);
|
|
|
|
|
2023-06-07 03:22:17 -07:00
|
|
|
// private: - I give up, C++ wins
|
2023-04-13 14:12:48 -07:00
|
|
|
Hy3NodeData(Hy3GroupData);
|
2023-04-12 01:33:00 -07:00
|
|
|
Hy3NodeData(Hy3NodeData&&);
|
2023-05-16 03:02:26 -07:00
|
|
|
Hy3NodeData& operator=(Hy3NodeData&&);
|
2023-04-12 01:33:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Hy3Node {
|
|
|
|
Hy3Node* parent = nullptr;
|
|
|
|
Hy3NodeData data;
|
|
|
|
Vector2D position;
|
|
|
|
Vector2D size;
|
2023-06-04 21:32:30 -07:00
|
|
|
Vector2D gap_pos_offset;
|
|
|
|
Vector2D gap_size_offset;
|
2023-04-12 01:33:00 -07:00
|
|
|
float size_ratio = 1.0;
|
|
|
|
int workspace_id = -1;
|
2023-06-01 21:58:18 -07:00
|
|
|
bool hidden = false;
|
2023-04-12 01:33:00 -07:00
|
|
|
bool valid = true;
|
|
|
|
Hy3Layout* layout = nullptr;
|
|
|
|
|
2023-06-28 16:24:10 -07:00
|
|
|
void recalcSizePosRecursive(bool no_animation = false);
|
2023-04-19 01:58:22 -07:00
|
|
|
std::string debugNode();
|
2023-04-26 00:57:24 -07:00
|
|
|
void markFocused();
|
|
|
|
void focus();
|
2023-05-31 01:31:22 -07:00
|
|
|
bool focusWindow();
|
2023-04-26 00:57:24 -07:00
|
|
|
void raiseToTop();
|
|
|
|
Hy3Node* getFocusedNode();
|
|
|
|
void updateDecos();
|
2023-06-28 16:24:10 -07:00
|
|
|
void setHidden(bool);
|
2023-06-28 16:46:05 -07:00
|
|
|
void updateTabBar(bool no_animation = false);
|
2023-06-04 17:28:26 -07:00
|
|
|
void updateTabBarRecursive();
|
2023-05-16 03:02:26 -07:00
|
|
|
bool isUrgent();
|
2023-05-28 23:19:35 -07:00
|
|
|
bool isIndirectlyFocused();
|
2023-06-04 20:26:22 -07:00
|
|
|
Hy3Node* findNodeForTabGroup(Hy3TabGroup&);
|
2023-05-16 03:02:26 -07:00
|
|
|
std::string getTitle();
|
2023-06-25 15:29:02 -07:00
|
|
|
void appendAllWindows(std::vector<CWindow*>&);
|
2023-04-12 01:33:00 -07:00
|
|
|
|
|
|
|
bool operator==(const Hy3Node&) const;
|
|
|
|
|
2023-04-23 21:02:51 -07:00
|
|
|
// Attempt to swallow a group. returns true if swallowed
|
2023-06-28 16:24:10 -07:00
|
|
|
static bool swallowGroups(Hy3Node* into);
|
2023-04-23 21:02:51 -07:00
|
|
|
// Remove this node from its parent, deleting the parent if it was
|
2023-06-07 03:22:17 -07:00
|
|
|
// the only child and recursing if the parent was the only child of it's
|
|
|
|
// parent.
|
2023-04-23 21:02:51 -07:00
|
|
|
Hy3Node* removeFromParentRecursive();
|
|
|
|
|
2023-05-04 03:10:06 -07:00
|
|
|
// Replace this node with a group, returning this node's new address.
|
|
|
|
Hy3Node* intoGroup(Hy3GroupLayout);
|
|
|
|
|
2023-04-23 21:02:51 -07:00
|
|
|
static void swapData(Hy3Node&, Hy3Node&);
|
|
|
|
};
|
2023-04-19 02:07:47 -07:00
|
|
|
|
2023-04-12 01:33:00 -07:00
|
|
|
class Hy3Layout: public IHyprLayout {
|
|
|
|
public:
|
|
|
|
virtual void onWindowCreatedTiling(CWindow*);
|
|
|
|
virtual void onWindowRemovedTiling(CWindow*);
|
2023-04-12 03:33:45 -07:00
|
|
|
virtual void onWindowFocusChange(CWindow*);
|
2023-04-12 01:33:00 -07:00
|
|
|
virtual bool isWindowTiled(CWindow*);
|
2023-06-28 16:24:10 -07:00
|
|
|
virtual void recalculateMonitor(const int& monitor_id);
|
2023-04-12 01:33:00 -07:00
|
|
|
virtual void recalculateWindow(CWindow*);
|
2023-04-18 23:41:18 -07:00
|
|
|
virtual void onBeginDragWindow();
|
2023-06-28 16:24:10 -07:00
|
|
|
virtual void resizeActiveWindow(const Vector2D& delta, CWindow* pWindow = nullptr);
|
|
|
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool enable_fullscreen);
|
|
|
|
virtual std::any layoutMessage(SLayoutMessageHeader header, std::string content);
|
2023-04-12 01:33:00 -07:00
|
|
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
|
|
|
virtual void switchWindows(CWindow*, CWindow*);
|
|
|
|
virtual void alterSplitRatio(CWindow*, float, bool);
|
|
|
|
virtual std::string getLayoutName();
|
2023-04-16 23:53:22 -07:00
|
|
|
virtual CWindow* getNextWindowCandidate(CWindow*);
|
2023-06-28 16:24:10 -07:00
|
|
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
2023-04-12 01:33:00 -07:00
|
|
|
|
|
|
|
virtual void onEnable();
|
|
|
|
virtual void onDisable();
|
|
|
|
|
2023-06-28 16:24:10 -07:00
|
|
|
void makeGroupOnWorkspace(int workspace, Hy3GroupLayout);
|
|
|
|
void makeOppositeGroupOnWorkspace(int workspace);
|
2023-05-04 03:10:06 -07:00
|
|
|
void makeGroupOn(Hy3Node*, Hy3GroupLayout);
|
|
|
|
void makeOppositeGroupOn(Hy3Node*);
|
2023-06-28 16:24:10 -07:00
|
|
|
void shiftWindow(int workspace, ShiftDirection, bool once);
|
|
|
|
void shiftFocus(int workspace, ShiftDirection, bool visible);
|
|
|
|
void changeFocus(int workspace, FocusShift);
|
|
|
|
void focusTab(int workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index);
|
|
|
|
void killFocusedNode(int workspace);
|
2023-04-26 00:57:24 -07:00
|
|
|
|
|
|
|
bool shouldRenderSelected(CWindow*);
|
2023-04-13 14:12:48 -07:00
|
|
|
|
2023-06-28 16:24:10 -07:00
|
|
|
Hy3Node* getWorkspaceRootGroup(const int& workspace);
|
|
|
|
Hy3Node* getWorkspaceFocusedNode(const int& workspace);
|
2023-04-19 01:58:22 -07:00
|
|
|
|
2023-05-16 03:02:26 -07:00
|
|
|
static void renderHook(void*, std::any);
|
2023-06-09 01:19:13 -07:00
|
|
|
static void windowGroupUrgentHook(void*, std::any);
|
|
|
|
static void windowGroupUpdateRecursiveHook(void*, std::any);
|
2023-05-30 23:23:46 -07:00
|
|
|
static void tickHook(void*, std::any);
|
2023-05-16 03:02:26 -07:00
|
|
|
|
2023-04-12 01:33:00 -07:00
|
|
|
std::list<Hy3Node> nodes;
|
2023-05-28 23:19:35 -07:00
|
|
|
std::list<Hy3TabGroup> tab_groups;
|
2023-06-07 03:22:17 -07:00
|
|
|
|
2023-04-16 21:56:19 -07:00
|
|
|
private:
|
2023-04-18 23:41:18 -07:00
|
|
|
struct {
|
|
|
|
bool started = false;
|
|
|
|
bool xExtent = false;
|
|
|
|
bool yExtent = false;
|
|
|
|
} drag_flags;
|
|
|
|
|
2023-06-28 16:24:10 -07:00
|
|
|
int getWorkspaceNodeCount(const int& workspace);
|
2023-04-12 01:33:00 -07:00
|
|
|
Hy3Node* getNodeFromWindow(CWindow*);
|
2023-06-28 16:24:10 -07:00
|
|
|
void applyNodeDataToWindow(Hy3Node*, bool no_animation = false);
|
2023-04-12 01:33:00 -07:00
|
|
|
|
2023-06-07 03:22:17 -07:00
|
|
|
// if shift is true, shift the window in the given direction, returning
|
|
|
|
// nullptr, if shift is false, return the window in the given direction or
|
|
|
|
// nullptr. if once is true, only one group will be broken out of / into
|
2023-06-28 16:24:10 -07:00
|
|
|
Hy3Node* shiftOrGetFocus(Hy3Node&, ShiftDirection, bool shift, bool once, bool visible);
|
2023-04-23 21:02:51 -07:00
|
|
|
|
2023-04-12 01:33:00 -07:00
|
|
|
friend struct Hy3Node;
|
|
|
|
};
|