mirror of https://github.com/hyprwm/Hyprland
Added some workspace-specific rules (#1986)
* added some workspace-specific rules * added some worskpace-specific rules, with windowrule like syntax * monitor is not mandatory anymore * pointers to config are now static * fixed optional WorkspaceRule fields * Windows can now specify border size * removed CHyprOpenGLImpl::renderBorder borderSize default value * stuff --------- Co-authored-by: Alessio Molinari <alessiomolinari@gmail.com> Co-authored-by: vaxerski <43317083+vaxerski@users.noreply.github.com>
This commit is contained in:
parent
250d5cf78c
commit
c949173bc9
|
@ -10,8 +10,7 @@
|
||||||
#include "helpers/Vector2D.hpp"
|
#include "helpers/Vector2D.hpp"
|
||||||
#include "helpers/WLSurface.hpp"
|
#include "helpers/WLSurface.hpp"
|
||||||
|
|
||||||
enum eIdleInhibitMode
|
enum eIdleInhibitMode {
|
||||||
{
|
|
||||||
IDLEINHIBIT_NONE = 0,
|
IDLEINHIBIT_NONE = 0,
|
||||||
IDLEINHIBIT_ALWAYS,
|
IDLEINHIBIT_ALWAYS,
|
||||||
IDLEINHIBIT_FULLSCREEN,
|
IDLEINHIBIT_FULLSCREEN,
|
||||||
|
@ -101,9 +100,10 @@ struct SWindowSpecialRenderData {
|
||||||
CWindowOverridableVar<int64_t> inactiveBorderColor = -1; // -1 means unset
|
CWindowOverridableVar<int64_t> inactiveBorderColor = -1; // -1 means unset
|
||||||
|
|
||||||
// set by the layout
|
// set by the layout
|
||||||
bool rounding = true;
|
int borderSize = -1;
|
||||||
bool border = true;
|
bool rounding = true;
|
||||||
bool decorate = true;
|
bool border = true;
|
||||||
|
bool decorate = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWindowAdditionalConfigData {
|
struct SWindowAdditionalConfigData {
|
||||||
|
|
|
@ -574,7 +574,16 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]);
|
newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]);
|
||||||
argno++;
|
argno++;
|
||||||
} else if (ARGS[argno] == "workspace") {
|
} else if (ARGS[argno] == "workspace") {
|
||||||
m_mDefaultWorkspaces[newrule.name] = ARGS[argno + 1];
|
std::string name = "";
|
||||||
|
int wsId = getWorkspaceIDFromString(ARGS[argno + 1], name);
|
||||||
|
|
||||||
|
SWorkspaceRule wsRule;
|
||||||
|
wsRule.monitor = newrule.name;
|
||||||
|
wsRule.workspaceString = ARGS[argno + 1];
|
||||||
|
wsRule.workspaceName = name;
|
||||||
|
wsRule.workspaceId = wsId;
|
||||||
|
|
||||||
|
m_mWorkspaceRules[wsId] = wsRule;
|
||||||
argno++;
|
argno++;
|
||||||
} else {
|
} else {
|
||||||
Debug::log(ERR, "Config error: invalid monitor syntax");
|
Debug::log(ERR, "Config error: invalid monitor syntax");
|
||||||
|
@ -1000,10 +1009,64 @@ void CConfigManager::handleBlurLS(const std::string& command, const std::string&
|
||||||
updateBlurredLS(value, true);
|
updateBlurredLS(value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) {
|
void CConfigManager::handleWorkspaceRules(const std::string& command, const std::string& value) {
|
||||||
const auto ARGS = CVarList(value);
|
// This can either be the monitor or the workspace identifier
|
||||||
|
const auto FIRST_DELIM = value.find_first_of(',');
|
||||||
|
|
||||||
m_mDefaultWorkspaces[ARGS[0]] = ARGS[1];
|
std::string name = "";
|
||||||
|
auto first_ident = removeBeginEndSpacesTabs(value.substr(0, FIRST_DELIM));
|
||||||
|
int id = getWorkspaceIDFromString(first_ident, name);
|
||||||
|
|
||||||
|
auto rules = value.substr(FIRST_DELIM + 1);
|
||||||
|
SWorkspaceRule wsRule;
|
||||||
|
wsRule.workspaceString = first_ident;
|
||||||
|
if (id == INT_MAX) {
|
||||||
|
// it could be the monitor. If so, second value MUST be
|
||||||
|
// the workspace.
|
||||||
|
const auto WORKSPACE_DELIM = value.find_first_of(',', FIRST_DELIM + 1);
|
||||||
|
auto wsIdent = removeBeginEndSpacesTabs(value.substr(FIRST_DELIM + 1, (WORKSPACE_DELIM - FIRST_DELIM - 1)));
|
||||||
|
id = getWorkspaceIDFromString(wsIdent, name);
|
||||||
|
if (id == INT_MAX) {
|
||||||
|
Debug::log(ERR, "Invalid workspace identifier found: %s", wsIdent.c_str());
|
||||||
|
parseError = "Invalid workspace identifier found: " + wsIdent;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wsRule.monitor = first_ident;
|
||||||
|
wsRule.workspaceString = wsIdent;
|
||||||
|
rules = value.substr(WORKSPACE_DELIM + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto assignRule = [&](std::string rule) {
|
||||||
|
size_t delim = std::string::npos;
|
||||||
|
Debug::log(INFO, "found workspacerule: %s", rule.c_str());
|
||||||
|
if ((delim = rule.find("gapsin:")) != std::string::npos)
|
||||||
|
wsRule.gapsIn = std::stoi(rule.substr(delim + 7));
|
||||||
|
else if ((delim = rule.find("gapsout:")) != std::string::npos)
|
||||||
|
wsRule.gapsOut = std::stoi(rule.substr(delim + 8));
|
||||||
|
else if ((delim = rule.find("bordersize:")) != std::string::npos)
|
||||||
|
wsRule.borderSize = std::stoi(rule.substr(delim + 11));
|
||||||
|
else if ((delim = rule.find("border:")) != std::string::npos)
|
||||||
|
wsRule.border = configStringToInt(rule.substr(delim + 7));
|
||||||
|
else if ((delim = rule.find("rounding:")) != std::string::npos)
|
||||||
|
wsRule.rounding = configStringToInt(rule.substr(delim + 9));
|
||||||
|
else if ((delim = rule.find("decorate:")) != std::string::npos)
|
||||||
|
wsRule.decorate = configStringToInt(rule.substr(delim + 9));
|
||||||
|
else if ((delim = rule.find("monitor:")) != std::string::npos)
|
||||||
|
wsRule.monitor = rule.substr(delim + 8);
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t pos = 0;
|
||||||
|
std::string rule;
|
||||||
|
while ((pos = rules.find(',')) != std::string::npos) {
|
||||||
|
rule = rules.substr(0, pos);
|
||||||
|
assignRule(rule);
|
||||||
|
rules.erase(0, pos + 1);
|
||||||
|
}
|
||||||
|
assignRule(rules); // match remaining rule
|
||||||
|
|
||||||
|
wsRule.workspaceId = id;
|
||||||
|
wsRule.workspaceName = name;
|
||||||
|
m_mWorkspaceRules[id] = wsRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) {
|
void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) {
|
||||||
|
@ -1140,7 +1203,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
||||||
else if (COMMAND == "unbind")
|
else if (COMMAND == "unbind")
|
||||||
handleUnbind(COMMAND, VALUE);
|
handleUnbind(COMMAND, VALUE);
|
||||||
else if (COMMAND == "workspace")
|
else if (COMMAND == "workspace")
|
||||||
handleDefaultWorkspace(COMMAND, VALUE);
|
handleWorkspaceRules(COMMAND, VALUE);
|
||||||
else if (COMMAND == "windowrule")
|
else if (COMMAND == "windowrule")
|
||||||
handleWindowRule(COMMAND, VALUE);
|
handleWindowRule(COMMAND, VALUE);
|
||||||
else if (COMMAND == "windowrulev2")
|
else if (COMMAND == "windowrulev2")
|
||||||
|
@ -1314,6 +1377,7 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
deviceConfigs.clear();
|
deviceConfigs.clear();
|
||||||
m_dBlurLSNamespaces.clear();
|
m_dBlurLSNamespaces.clear();
|
||||||
boundWorkspaces.clear();
|
boundWorkspaces.clear();
|
||||||
|
m_mWorkspaceRules.clear();
|
||||||
setDefaultAnimationVars(); // reset anims
|
setDefaultAnimationVars(); // reset anims
|
||||||
m_vDeclaredPlugins.clear();
|
m_vDeclaredPlugins.clear();
|
||||||
|
|
||||||
|
@ -1613,6 +1677,17 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const std::string& name, const st
|
||||||
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-1, -1), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
|
return SMonitorRule{.name = "", .resolution = Vector2D(0, 0), .offset = Vector2D(-1, -1), .scale = -1}; // 0, 0 is preferred and -1, -1 is auto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWorkspaceRule CConfigManager::getWorkspaceRuleFor(CWorkspace* pWorkspace) {
|
||||||
|
if (m_mWorkspaceRules.contains(pWorkspace->m_iID)) {
|
||||||
|
return m_mWorkspaceRules.at(pWorkspace->m_iID);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto IT = std::find_if(m_mWorkspaceRules.begin(), m_mWorkspaceRules.end(), [&](const auto& other) { return other.second.workspaceName == pWorkspace->m_szName; });
|
||||||
|
if (IT == m_mWorkspaceRules.end())
|
||||||
|
return SWorkspaceRule{};
|
||||||
|
return IT->second;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
||||||
if (!g_pCompositor->windowValidMapped(pWindow))
|
if (!g_pCompositor->windowValidMapped(pWindow))
|
||||||
return std::vector<SWindowRule>();
|
return std::vector<SWindowRule>();
|
||||||
|
@ -2020,8 +2095,8 @@ void CConfigManager::removePluginConfig(HANDLE handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
|
std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
|
||||||
const auto IT = std::find_if(m_mDefaultWorkspaces.begin(), m_mDefaultWorkspaces.end(), [&](const auto& other) { return other.first == name; });
|
const auto IT = std::find_if(m_mWorkspaceRules.begin(), m_mWorkspaceRules.end(), [&](const auto& other) { return other.second.monitor == name; });
|
||||||
if (IT == m_mDefaultWorkspaces.end())
|
if (IT == m_mWorkspaceRules.end())
|
||||||
return "";
|
return "";
|
||||||
return IT->second;
|
return IT->second.workspaceString;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <optional>
|
||||||
#include "../Window.hpp"
|
#include "../Window.hpp"
|
||||||
#include "../helpers/WLClasses.hpp"
|
#include "../helpers/WLClasses.hpp"
|
||||||
|
|
||||||
|
@ -45,6 +46,19 @@ struct SMonitorRule {
|
||||||
bool enable10bit = false;
|
bool enable10bit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SWorkspaceRule {
|
||||||
|
std::string monitor = "";
|
||||||
|
std::string workspaceString = "";
|
||||||
|
std::string workspaceName = "";
|
||||||
|
int workspaceId = -1;
|
||||||
|
std::optional<int64_t> gapsIn;
|
||||||
|
std::optional<int64_t> gapsOut;
|
||||||
|
std::optional<int64_t> borderSize;
|
||||||
|
std::optional<int> border;
|
||||||
|
std::optional<int> rounding;
|
||||||
|
std::optional<int> decorate;
|
||||||
|
};
|
||||||
|
|
||||||
struct SMonitorAdditionalReservedArea {
|
struct SMonitorAdditionalReservedArea {
|
||||||
int top = 0;
|
int top = 0;
|
||||||
int bottom = 0;
|
int bottom = 0;
|
||||||
|
@ -149,6 +163,7 @@ class CConfigManager {
|
||||||
SConfigValue* getConfigValuePtrSafe(const std::string&);
|
SConfigValue* getConfigValuePtrSafe(const std::string&);
|
||||||
|
|
||||||
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
|
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
|
||||||
|
SWorkspaceRule getWorkspaceRuleFor(CWorkspace*);
|
||||||
std::string getDefaultWorkspaceFor(const std::string&);
|
std::string getDefaultWorkspaceFor(const std::string&);
|
||||||
|
|
||||||
CMonitor* getBoundMonitorForWS(const std::string&);
|
CMonitor* getBoundMonitorForWS(const std::string&);
|
||||||
|
@ -211,7 +226,7 @@ class CConfigManager {
|
||||||
bool isFirstLaunch = true; // For exec-once
|
bool isFirstLaunch = true; // For exec-once
|
||||||
|
|
||||||
std::deque<SMonitorRule> m_dMonitorRules;
|
std::deque<SMonitorRule> m_dMonitorRules;
|
||||||
std::unordered_map<std::string, std::string> m_mDefaultWorkspaces;
|
std::unordered_map<int, SWorkspaceRule> m_mWorkspaceRules;
|
||||||
std::deque<SWindowRule> m_dWindowRules;
|
std::deque<SWindowRule> m_dWindowRules;
|
||||||
std::deque<SLayerRule> m_dLayerRules;
|
std::deque<SLayerRule> m_dLayerRules;
|
||||||
std::deque<std::string> m_dBlurLSNamespaces;
|
std::deque<std::string> m_dBlurLSNamespaces;
|
||||||
|
@ -245,7 +260,7 @@ class CConfigManager {
|
||||||
void handleWindowRule(const std::string&, const std::string&);
|
void handleWindowRule(const std::string&, const std::string&);
|
||||||
void handleLayerRule(const std::string&, const std::string&);
|
void handleLayerRule(const std::string&, const std::string&);
|
||||||
void handleWindowRuleV2(const std::string&, const std::string&);
|
void handleWindowRuleV2(const std::string&, const std::string&);
|
||||||
void handleDefaultWorkspace(const std::string&, const std::string&);
|
void handleWorkspaceRules(const std::string&, const std::string&);
|
||||||
void handleBezier(const std::string&, const std::string&);
|
void handleBezier(const std::string&, const std::string&);
|
||||||
void handleAnimation(const std::string&, const std::string&);
|
void handleAnimation(const std::string&, const std::string&);
|
||||||
void handleSource(const std::string&, const std::string&);
|
void handleSource(const std::string&, const std::string&);
|
||||||
|
|
|
@ -103,16 +103,23 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
}
|
}
|
||||||
|
|
||||||
// for gaps outer
|
// for gaps outer
|
||||||
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
||||||
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||||
|
|
||||||
|
const auto PWINDOW = pNode->pWindow;
|
||||||
|
// get specific gaps and rules for this workspace,
|
||||||
|
// if user specified them in config
|
||||||
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID));
|
||||||
|
|
||||||
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
|
||||||
static auto* const PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
static auto* const PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||||
static auto* const PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
static auto* const PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||||
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
|
|
||||||
const auto PWINDOW = pNode->pWindow;
|
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
|
||||||
|
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
|
||||||
|
auto borderSize = WORKSPACERULE.borderSize.value_or(*PBORDERSIZE);
|
||||||
|
|
||||||
if (!g_pCompositor->windowExists(PWINDOW) || !PWINDOW->m_bIsMapped) {
|
if (!g_pCompositor->windowExists(PWINDOW) || !PWINDOW->m_bIsMapped) {
|
||||||
Debug::log(ERR, "Node %lx holding invalid window %lx!!", pNode, PWINDOW);
|
Debug::log(ERR, "Node %lx holding invalid window %lx!!", pNode, PWINDOW);
|
||||||
|
@ -125,15 +132,15 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
|
|
||||||
static auto* const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
|
static auto* const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
|
||||||
|
|
||||||
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
auto calcPos = PWINDOW->m_vPosition + Vector2D(borderSize, borderSize);
|
||||||
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * borderSize, 2 * borderSize);
|
||||||
|
|
||||||
const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
|
const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
|
||||||
|
|
||||||
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
if (WORKSPACERULE.workspaceString.empty() && *PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
||||||
(NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
(NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
||||||
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
PWINDOW->m_vRealPosition = calcPos - Vector2D(borderSize, borderSize);
|
||||||
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * borderSize, 2 * borderSize);
|
||||||
|
|
||||||
PWINDOW->updateWindowDecos();
|
PWINDOW->updateWindowDecos();
|
||||||
|
|
||||||
|
@ -144,13 +151,14 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_sSpecialRenderData.rounding = true;
|
PWINDOW->m_sSpecialRenderData.rounding = WORKSPACERULE.rounding.value_or(true);
|
||||||
PWINDOW->m_sSpecialRenderData.border = true;
|
PWINDOW->m_sSpecialRenderData.decorate = WORKSPACERULE.decorate.value_or(true);
|
||||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
PWINDOW->m_sSpecialRenderData.border = WORKSPACERULE.border.value_or(true);
|
||||||
|
PWINDOW->m_sSpecialRenderData.borderSize = WORKSPACERULE.borderSize.value_or(-1);
|
||||||
|
|
||||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? gapsOut : gapsIn, DISPLAYTOP ? gapsOut : gapsIn);
|
||||||
|
|
||||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? gapsOut : gapsIn, DISPLAYBOTTOM ? gapsOut : gapsIn);
|
||||||
|
|
||||||
calcPos = calcPos + OFFSETTOPLEFT;
|
calcPos = calcPos + OFFSETTOPLEFT;
|
||||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||||
|
|
|
@ -473,16 +473,23 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for gaps outer
|
// for gaps outer
|
||||||
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
||||||
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||||
|
|
||||||
|
const auto PWINDOW = pNode->pWindow;
|
||||||
|
// get specific gaps and rules for this workspace,
|
||||||
|
// if user specified them in config
|
||||||
|
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID));
|
||||||
|
|
||||||
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
|
||||||
static auto* const PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
static auto* const PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||||
static auto* const PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
static auto* const PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||||
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
|
|
||||||
const auto PWINDOW = pNode->pWindow;
|
auto gapsIn = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
|
||||||
|
auto gapsOut = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
|
||||||
|
auto borderSize = WORKSPACERULE.borderSize.value_or(*PBORDERSIZE);
|
||||||
|
|
||||||
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
|
if (!g_pCompositor->windowValidMapped(PWINDOW)) {
|
||||||
Debug::log(ERR, "Node %lx holding invalid window %lx!!", pNode, PWINDOW);
|
Debug::log(ERR, "Node %lx holding invalid window %lx!!", pNode, PWINDOW);
|
||||||
|
@ -494,14 +501,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
PWINDOW->m_vSize = pNode->size;
|
PWINDOW->m_vSize = pNode->size;
|
||||||
PWINDOW->m_vPosition = pNode->position;
|
PWINDOW->m_vPosition = pNode->position;
|
||||||
|
|
||||||
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
auto calcPos = PWINDOW->m_vPosition + Vector2D(borderSize, borderSize);
|
||||||
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * borderSize, 2 * borderSize);
|
||||||
|
|
||||||
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
if (WORKSPACERULE.workspaceString.empty() && *PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
||||||
(getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 ||
|
(getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 ||
|
||||||
(PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
(PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
||||||
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
PWINDOW->m_vRealPosition = calcPos - Vector2D(borderSize, borderSize);
|
||||||
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * borderSize, 2 * borderSize);
|
||||||
|
|
||||||
PWINDOW->updateWindowDecos();
|
PWINDOW->updateWindowDecos();
|
||||||
|
|
||||||
|
@ -512,13 +519,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_sSpecialRenderData.rounding = true;
|
PWINDOW->m_sSpecialRenderData.rounding = WORKSPACERULE.rounding.value_or(true);
|
||||||
PWINDOW->m_sSpecialRenderData.border = true;
|
PWINDOW->m_sSpecialRenderData.decorate = WORKSPACERULE.decorate.value_or(true);
|
||||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
PWINDOW->m_sSpecialRenderData.border = WORKSPACERULE.border.value_or(true);
|
||||||
|
PWINDOW->m_sSpecialRenderData.borderSize = WORKSPACERULE.borderSize.value_or(-1);
|
||||||
|
|
||||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? gapsOut : gapsIn, DISPLAYTOP ? gapsOut : gapsIn);
|
||||||
|
|
||||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? gapsOut : gapsIn, DISPLAYBOTTOM ? gapsOut : gapsIn);
|
||||||
|
|
||||||
calcPos = calcPos + OFFSETTOPLEFT;
|
calcPos = calcPos + OFFSETTOPLEFT;
|
||||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ void pushVert2D(float x, float y, float* arr, int& counter, wlr_box* box) {
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, int round, float a) {
|
void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad, int round, int borderSize, float a) {
|
||||||
RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!");
|
RASSERT((box->width > 0 && box->height > 0), "Tried to render rect with width/height < 0!");
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
||||||
|
|
||||||
|
@ -1068,10 +1068,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
||||||
|
|
||||||
box = &newBox;
|
box = &newBox;
|
||||||
|
|
||||||
if (*PBORDERSIZE < 1)
|
if (borderSize < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int scaledBorderSize = *PBORDERSIZE * m_RenderData.pMonitor->scale * m_RenderData.renderModif.scale;
|
int scaledBorderSize = borderSize * m_RenderData.pMonitor->scale * m_RenderData.renderModif.scale;
|
||||||
|
|
||||||
// adjust box
|
// adjust box
|
||||||
box->x -= scaledBorderSize;
|
box->x -= scaledBorderSize;
|
||||||
|
|
|
@ -23,8 +23,7 @@ inline const float fullVerts[] = {
|
||||||
};
|
};
|
||||||
inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
||||||
|
|
||||||
enum eDiscardMode
|
enum eDiscardMode {
|
||||||
{
|
|
||||||
DISCARD_OPAQUE = 1,
|
DISCARD_OPAQUE = 1,
|
||||||
DISCARD_ALPHAZERO = 1 << 1
|
DISCARD_ALPHAZERO = 1 << 1
|
||||||
};
|
};
|
||||||
|
@ -102,7 +101,7 @@ class CHyprOpenGLImpl {
|
||||||
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
|
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardActive = false, bool allowCustomUV = false);
|
||||||
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false);
|
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false);
|
||||||
void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
||||||
void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
|
void renderBorder(wlr_box*, const CGradientValueData&, int round, int borderSize, float a = 1.0);
|
||||||
|
|
||||||
void saveMatrix();
|
void saveMatrix();
|
||||||
void setMatrixScaleTranslate(const Vector2D& translate, const float& scale);
|
void setMatrixScaleTranslate(const Vector2D& translate, const float& scale);
|
||||||
|
|
|
@ -248,6 +248,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec());
|
const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec());
|
||||||
static auto* const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue;
|
static auto* const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue;
|
||||||
static auto* const PDIMAROUND = &g_pConfigManager->getConfigValuePtr("decoration:dim_around")->floatValue;
|
static auto* const PDIMAROUND = &g_pConfigManager->getConfigValuePtr("decoration:dim_around")->floatValue;
|
||||||
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
|
|
||||||
SRenderData renderdata = {pMonitor, time, REALPOS.x, REALPOS.y};
|
SRenderData renderdata = {pMonitor, time, REALPOS.x, REALPOS.y};
|
||||||
if (ignorePosition) {
|
if (ignorePosition) {
|
||||||
|
@ -342,11 +343,13 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
|
|
||||||
scaleBox(&windowBox, pMonitor->scale);
|
scaleBox(&windowBox, pMonitor->scale);
|
||||||
|
|
||||||
g_pHyprOpenGL->renderBorder(&windowBox, grad, rounding, a1);
|
const int BORDERSIZE = pWindow->m_sSpecialRenderData.borderSize == -1 ? *PBORDERSIZE : pWindow->m_sSpecialRenderData.borderSize;
|
||||||
|
|
||||||
|
g_pHyprOpenGL->renderBorder(&windowBox, grad, rounding, BORDERSIZE, a1);
|
||||||
|
|
||||||
if (ANIMATED) {
|
if (ANIMATED) {
|
||||||
float a2 = renderdata.fadeAlpha * renderdata.alpha * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.fl());
|
float a2 = renderdata.fadeAlpha * renderdata.alpha * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.fl());
|
||||||
g_pHyprOpenGL->renderBorder(&windowBox, g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColorPrevious, rounding, a2);
|
g_pHyprOpenGL->renderBorder(&windowBox, g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColorPrevious, rounding, BORDERSIZE, a2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue