support gradients in dwindle group colors

This commit is contained in:
Vaxry 2022-12-31 16:23:56 +01:00
parent a91d0a374a
commit 7f595ed0ca
4 changed files with 43 additions and 41 deletions

View file

@ -1486,8 +1486,8 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
// border // border
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow); const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);
if (RENDERDATA.isBorderColor) if (RENDERDATA.isBorderGradient)
setBorderColor(RENDERDATA.borderColor * (1.f / 255.f)); setBorderColor(*RENDERDATA.borderGradient);
else else
setBorderColor( setBorderColor(
pWindow == m_pLastWindow ? pWindow == m_pLastWindow ?

View file

@ -11,8 +11,10 @@
#include <iostream> #include <iostream>
CConfigManager::CConfigManager() { CConfigManager::CConfigManager() {
configValues["general:col.active_border"].data = std::make_shared<CGradientValueData>(0xffffffff); configValues["general:col.active_border"].data = std::make_shared<CGradientValueData>(0xffffffff);
configValues["general:col.inactive_border"].data = std::make_shared<CGradientValueData>(0xff444444); configValues["general:col.inactive_border"].data = std::make_shared<CGradientValueData>(0xff444444);
configValues["dwindle:col.group_border"].data = std::make_shared<CGradientValueData>(0x66777700);
configValues["dwindle:col.group_border_active"].data = std::make_shared<CGradientValueData>(0x66ffff00);
setDefaultVars(); setDefaultVars();
setDefaultAnimationVars(); setDefaultAnimationVars();
@ -94,9 +96,9 @@ void CConfigManager::setDefaultVars() {
configValues["decoration:dim_around"].floatValue = 0.4f; configValues["decoration:dim_around"].floatValue = 0.4f;
configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY; configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY;
((CGradientValueData*)configValues["dwindle:col.group_border"].data.get())->reset(0x66777700);
((CGradientValueData*)configValues["dwindle:col.group_border_active"].data.get())->reset(0x66ffff00);
configValues["dwindle:pseudotile"].intValue = 0; configValues["dwindle:pseudotile"].intValue = 0;
configValues["dwindle:col.group_border"].intValue = 0x66777700;
configValues["dwindle:col.group_border_active"].intValue = 0x66ffff00;
configValues["dwindle:force_split"].intValue = 0; configValues["dwindle:force_split"].intValue = 0;
configValues["dwindle:preserve_split"].intValue = 0; configValues["dwindle:preserve_split"].intValue = 0;
configValues["dwindle:special_scale_factor"].floatValue = 0.8f; configValues["dwindle:special_scale_factor"].floatValue = 0.8f;

View file

@ -655,7 +655,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_vPosition.y + PWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y); const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_vPosition.y + PWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
// construct allowed movement // construct allowed movement
Vector2D allowedMovement = pixResize; Vector2D allowedMovement = pixResize;
if (DISPLAYLEFT && DISPLAYRIGHT) if (DISPLAYLEFT && DISPLAYRIGHT)
allowedMovement.x = 0; allowedMovement.x = 0;
@ -671,7 +671,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const bool PARENTSIDEBYSIDE = !PPARENT->splitTop; const bool PARENTSIDEBYSIDE = !PPARENT->splitTop;
// Get the parent's parent // Get the parent's parent
auto PPARENT2 = PPARENT->pParent; auto PPARENT2 = PPARENT->pParent;
// No parent means we have only 2 windows, and thus one axis of freedom // No parent means we have only 2 windows, and thus one axis of freedom
if (!PPARENT2) { if (!PPARENT2) {
@ -1044,20 +1044,20 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
SWindowRenderLayoutHints hints; SWindowRenderLayoutHints hints;
static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue; static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->data;
static auto* const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue; static auto* const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->data;
const auto PNODE = getNodeFromWindow(pWindow); const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE) if (!PNODE)
return hints; // left for the future, maybe floating funkiness return hints; // left for the future, maybe floating funkiness
if (PNODE->isGroupMember()) { if (PNODE->isGroupMember()) {
hints.isBorderColor = true; hints.isBorderGradient = true;
if (pWindow == g_pCompositor->m_pLastWindow) if (pWindow == g_pCompositor->m_pLastWindow)
hints.borderColor = CColor(*PGROUPCOLACTIVE); hints.borderGradient = (CGradientValueData*)PGROUPCOLACTIVE->get();
else else
hints.borderColor = CColor(*PGROUPCOLINACTIVE); hints.borderGradient = (CGradientValueData*)PGROUPCOLINACTIVE->get();
} }
return hints; return hints;
@ -1174,7 +1174,7 @@ void CHyprDwindleLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exa
if (!PNODE || !PNODE->pParent || (PNODE->isGroupMember() && PNODE->getGroupMemberCount() == g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID))) if (!PNODE || !PNODE->pParent || (PNODE->isGroupMember() && PNODE->getGroupMemberCount() == g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID)))
return; return;
float newRatio = exact ? ratio : PNODE->pParent->splitRatio + ratio; float newRatio = exact ? ratio : PNODE->pParent->splitRatio + ratio;
PNODE->pParent->splitRatio = std::clamp(newRatio, 0.1f, 1.9f); PNODE->pParent->splitRatio = std::clamp(newRatio, 0.1f, 1.9f);
PNODE->pParent->recalcSizePosRecursive(); PNODE->pParent->recalcSizePosRecursive();

View file

@ -5,8 +5,8 @@
#include <any> #include <any>
struct SWindowRenderLayoutHints { struct SWindowRenderLayoutHints {
bool isBorderColor = false; bool isBorderGradient = false;
CColor borderColor; CGradientValueData* borderGradient;
}; };
struct SLayoutMessageHeader { struct SLayoutMessageHeader {
@ -17,89 +17,89 @@ enum eFullscreenMode : uint8_t;
interface IHyprLayout { interface IHyprLayout {
public: public:
virtual ~IHyprLayout() = 0; virtual ~IHyprLayout() = 0;
virtual void onEnable() = 0; virtual void onEnable() = 0;
virtual void onDisable() = 0; virtual void onDisable() = 0;
/* /*
Called when a window is created (mapped) Called when a window is created (mapped)
The layout HAS TO set the goal pos and size (anim mgr will use it) 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. If !animationinprogress, then the anim mgr will not apply an anim.
*/ */
virtual void onWindowCreated(CWindow*); virtual void onWindowCreated(CWindow*);
virtual void onWindowCreatedTiling(CWindow*) = 0; virtual void onWindowCreatedTiling(CWindow*) = 0;
virtual void onWindowCreatedFloating(CWindow*); virtual void onWindowCreatedFloating(CWindow*);
/* /*
Return tiled status Return tiled status
*/ */
virtual bool isWindowTiled(CWindow*) = 0; virtual bool isWindowTiled(CWindow*) = 0;
/* /*
Called when a window is removed (unmapped) Called when a window is removed (unmapped)
*/ */
virtual void onWindowRemoved(CWindow*); virtual void onWindowRemoved(CWindow*);
virtual void onWindowRemovedTiling(CWindow*) = 0; virtual void onWindowRemovedTiling(CWindow*) = 0;
virtual void onWindowRemovedFloating(CWindow*); virtual void onWindowRemovedFloating(CWindow*);
/* /*
Called when the monitor requires a layout recalculation Called when the monitor requires a layout recalculation
this usually means reserved area changes this usually means reserved area changes
*/ */
virtual void recalculateMonitor(const int&) = 0; virtual void recalculateMonitor(const int&) = 0;
/* /*
Called when the compositor requests a window Called when the compositor requests a window
to be recalculated, e.g. when pseudo is toggled. to be recalculated, e.g. when pseudo is toggled.
*/ */
virtual void recalculateWindow(CWindow*) = 0; virtual void recalculateWindow(CWindow*) = 0;
/* /*
Called when a window is requested to be floated Called when a window is requested to be floated
*/ */
virtual void changeWindowFloatingMode(CWindow*); virtual void changeWindowFloatingMode(CWindow*);
/* /*
Called when a window is clicked on, beginning a drag Called when a window is clicked on, beginning a drag
this might be a resize, move, whatever the layout defines it this might be a resize, move, whatever the layout defines it
as. as.
*/ */
virtual void onBeginDragWindow(); virtual void onBeginDragWindow();
/* /*
Called when a user requests a resize of the current window by a vec Called when a user requests a resize of the current window by a vec
Vector2D holds pixel values Vector2D holds pixel values
Optional pWindow for a specific window Optional pWindow for a specific window
*/ */
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0; virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
/* /*
Called when a user requests a move of the current window by a vec Called when a user requests a move of the current window by a vec
Vector2D holds pixel values Vector2D holds pixel values
Optional pWindow for a specific window Optional pWindow for a specific window
*/ */
virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr); virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
/* /*
Called when a window is ended being dragged Called when a window is ended being dragged
(mouse up) (mouse up)
*/ */
virtual void onEndDragWindow(); virtual void onEndDragWindow();
/* /*
Called whenever the mouse moves, should the layout want to Called whenever the mouse moves, should the layout want to
do anything with it. do anything with it.
Useful for dragging. Useful for dragging.
*/ */
virtual void onMouseMove(const Vector2D&); virtual void onMouseMove(const Vector2D&);
/* /*
Called when a window / the user requests to toggle the fullscreen state of a window Called when a window / the user requests to toggle the fullscreen state of a window
The layout sets all the fullscreen flags. The layout sets all the fullscreen flags.
It can either accept or ignore. It can either accept or ignore.
*/ */
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0; virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
/* /*
Called when a dispatcher requests a custom message Called when a dispatcher requests a custom message
The layout is free to ignore. The layout is free to ignore.
std::any is the reply. Can be empty. std::any is the reply. Can be empty.
*/ */
virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0; virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0;
/* /*
Required to be handled, but may return just SWindowRenderLayoutHints() Required to be handled, but may return just SWindowRenderLayoutHints()
@ -112,28 +112,28 @@ interface IHyprLayout {
Called when the user requests two windows to be swapped places. Called when the user requests two windows to be swapped places.
The layout is free to ignore. The layout is free to ignore.
*/ */
virtual void switchWindows(CWindow*, CWindow*) = 0; virtual void switchWindows(CWindow*, CWindow*) = 0;
/* /*
Called when the user requests to change the splitratio by or to X Called when the user requests to change the splitratio by or to X
on a window on a window
*/ */
virtual void alterSplitRatio(CWindow*, float, bool exact = false) = 0; virtual void alterSplitRatio(CWindow*, float, bool exact = false) = 0;
/* /*
Called when something wants the current layout's name Called when something wants the current layout's name
*/ */
virtual std::string getLayoutName() = 0; virtual std::string getLayoutName() = 0;
/* /*
Called for getting the next candidate for a focus Called for getting the next candidate for a focus
*/ */
virtual CWindow* getNextWindowCandidate(CWindow*); virtual CWindow* getNextWindowCandidate(CWindow*);
/* /*
Internal: called when window focus changes Internal: called when window focus changes
*/ */
virtual void onWindowFocusChange(CWindow*); virtual void onWindowFocusChange(CWindow*);
private: private:
Vector2D m_vBeginDragXY; Vector2D m_vBeginDragXY;