2022-03-19 15:59:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
|
|
|
#include "../Window.hpp"
|
2022-12-16 18:17:31 +01:00
|
|
|
#include <any>
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-04-12 16:44:18 +02:00
|
|
|
struct SWindowRenderLayoutHints {
|
2022-12-31 16:23:56 +01:00
|
|
|
bool isBorderGradient = false;
|
|
|
|
CGradientValueData* borderGradient;
|
2022-04-12 16:44:18 +02:00
|
|
|
};
|
|
|
|
|
2022-05-16 17:37:46 +02:00
|
|
|
struct SLayoutMessageHeader {
|
2022-12-16 18:17:31 +01:00
|
|
|
CWindow* pWindow = nullptr;
|
2022-05-16 17:37:46 +02:00
|
|
|
};
|
|
|
|
|
2022-05-29 15:44:30 +02:00
|
|
|
enum eFullscreenMode : uint8_t;
|
|
|
|
|
2023-07-13 16:52:11 +02:00
|
|
|
enum eRectCorner {
|
|
|
|
CORNER_NONE = 0,
|
|
|
|
CORNER_TOPLEFT,
|
2023-02-12 23:24:47 +01:00
|
|
|
CORNER_TOPRIGHT,
|
|
|
|
CORNER_BOTTOMRIGHT,
|
|
|
|
CORNER_BOTTOMLEFT
|
|
|
|
};
|
|
|
|
|
2022-03-19 15:59:53 +01:00
|
|
|
interface IHyprLayout {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual ~IHyprLayout() = 0;
|
|
|
|
virtual void onEnable() = 0;
|
|
|
|
virtual void onDisable() = 0;
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
|
|
|
Called when a window is created (mapped)
|
2022-05-14 16:43:30 +02:00
|
|
|
The layout HAS TO set the goal pos and size (anim mgr will use it)
|
|
|
|
If !animationinprogress, then the anim mgr will not apply an anim.
|
2022-03-21 19:18:33 +01:00
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void onWindowCreated(CWindow*);
|
|
|
|
virtual void onWindowCreatedTiling(CWindow*) = 0;
|
|
|
|
virtual void onWindowCreatedFloating(CWindow*);
|
2022-06-30 12:09:05 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Return tiled status
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual bool isWindowTiled(CWindow*) = 0;
|
2022-06-30 12:09:05 +02:00
|
|
|
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
|
|
|
Called when a window is removed (unmapped)
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void onWindowRemoved(CWindow*);
|
|
|
|
virtual void onWindowRemovedTiling(CWindow*) = 0;
|
|
|
|
virtual void onWindowRemovedFloating(CWindow*);
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
2022-04-02 20:04:32 +02:00
|
|
|
Called when the monitor requires a layout recalculation
|
2022-03-21 19:18:33 +01:00
|
|
|
this usually means reserved area changes
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void recalculateMonitor(const int&) = 0;
|
2022-03-20 11:14:24 +01:00
|
|
|
|
2022-04-02 20:04:32 +02:00
|
|
|
/*
|
|
|
|
Called when the compositor requests a window
|
|
|
|
to be recalculated, e.g. when pseudo is toggled.
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void recalculateWindow(CWindow*) = 0;
|
2022-04-02 20:04:32 +02:00
|
|
|
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
|
|
|
Called when a window is requested to be floated
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void changeWindowFloatingMode(CWindow*);
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
|
|
|
Called when a window is clicked on, beginning a drag
|
|
|
|
this might be a resize, move, whatever the layout defines it
|
|
|
|
as.
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void onBeginDragWindow();
|
2022-06-06 19:32:14 +02:00
|
|
|
/*
|
|
|
|
Called when a user requests a resize of the current window by a vec
|
|
|
|
Vector2D holds pixel values
|
|
|
|
Optional pWindow for a specific window
|
|
|
|
*/
|
2023-07-13 16:52:11 +02:00
|
|
|
virtual void resizeActiveWindow(const Vector2D&, eRectCorner corner = CORNER_NONE, CWindow* pWindow = nullptr) = 0;
|
2022-06-23 10:14:59 +02:00
|
|
|
/*
|
|
|
|
Called when a user requests a move of the current window by a vec
|
|
|
|
Vector2D holds pixel values
|
|
|
|
Optional pWindow for a specific window
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
2022-04-03 13:49:21 +02:00
|
|
|
/*
|
|
|
|
Called when a window is ended being dragged
|
|
|
|
(mouse up)
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void onEndDragWindow();
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
2022-09-25 20:07:48 +02:00
|
|
|
Called whenever the mouse moves, should the layout want to
|
2022-03-21 19:18:33 +01:00
|
|
|
do anything with it.
|
|
|
|
Useful for dragging.
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void onMouseMove(const Vector2D&);
|
2022-03-19 15:59:53 +01:00
|
|
|
|
2022-03-21 19:18:33 +01:00
|
|
|
/*
|
2022-05-29 15:44:30 +02:00
|
|
|
Called when a window / the user requests to toggle the fullscreen state of a window
|
2022-03-21 19:18:33 +01:00
|
|
|
The layout sets all the fullscreen flags.
|
|
|
|
It can either accept or ignore.
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
|
2022-03-21 19:18:33 +01:00
|
|
|
|
2022-04-12 16:44:18 +02:00
|
|
|
/*
|
2022-05-16 17:37:46 +02:00
|
|
|
Called when a dispatcher requests a custom message
|
2022-09-25 20:07:48 +02:00
|
|
|
The layout is free to ignore.
|
2022-05-28 20:46:20 +02:00
|
|
|
std::any is the reply. Can be empty.
|
2022-04-12 16:44:18 +02:00
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0;
|
2022-04-12 16:44:18 +02:00
|
|
|
|
2022-09-25 20:07:48 +02:00
|
|
|
/*
|
2022-04-12 16:44:18 +02:00
|
|
|
Required to be handled, but may return just SWindowRenderLayoutHints()
|
|
|
|
Called when the renderer requests any special draw flags for
|
|
|
|
a specific window, e.g. border color for groups.
|
|
|
|
*/
|
|
|
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*) = 0;
|
2022-04-20 16:18:58 +02:00
|
|
|
|
2022-09-25 20:07:48 +02:00
|
|
|
/*
|
2022-04-20 16:18:58 +02:00
|
|
|
Called when the user requests two windows to be swapped places.
|
|
|
|
The layout is free to ignore.
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void switchWindows(CWindow*, CWindow*) = 0;
|
2022-04-20 16:53:41 +02:00
|
|
|
|
|
|
|
/*
|
2022-12-17 23:37:44 +01:00
|
|
|
Called when the user requests to change the splitratio by or to X
|
2022-04-20 16:53:41 +02:00
|
|
|
on a window
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void alterSplitRatio(CWindow*, float, bool exact = false) = 0;
|
2022-05-28 20:46:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Called when something wants the current layout's name
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual std::string getLayoutName() = 0;
|
2022-06-30 12:09:05 +02:00
|
|
|
|
2022-10-24 13:25:36 +02:00
|
|
|
/*
|
|
|
|
Called for getting the next candidate for a focus
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual CWindow* getNextWindowCandidate(CWindow*);
|
2022-10-24 13:25:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Internal: called when window focus changes
|
|
|
|
*/
|
2022-12-31 16:23:56 +01:00
|
|
|
virtual void onWindowFocusChange(CWindow*);
|
2022-10-24 13:25:36 +02:00
|
|
|
|
2023-02-19 22:07:32 +01:00
|
|
|
/*
|
|
|
|
Called for replacing any data a layout has for a new window
|
|
|
|
*/
|
2023-07-13 16:52:11 +02:00
|
|
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to) = 0;
|
2023-02-19 22:07:32 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
private:
|
2023-02-12 23:24:47 +01:00
|
|
|
Vector2D m_vBeginDragXY;
|
|
|
|
Vector2D m_vLastDragXY;
|
|
|
|
Vector2D m_vBeginDragPositionXY;
|
|
|
|
Vector2D m_vBeginDragSizeXY;
|
2023-05-29 18:05:41 +02:00
|
|
|
Vector2D m_vDraggingWindowOriginalFloatSize;
|
2023-02-12 23:24:47 +01:00
|
|
|
eRectCorner m_eGrabbedCorner = CORNER_TOPLEFT;
|
2022-10-24 13:25:36 +02:00
|
|
|
|
2023-02-12 23:24:47 +01:00
|
|
|
CWindow* m_pLastTiledWindow = nullptr;
|
2022-09-25 20:07:48 +02:00
|
|
|
};
|