mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 01:25:58 +01:00
internal: replace INT_MAX with WORKSPACE_INVALID
This commit is contained in:
parent
1bfd4a2bff
commit
69e314207d
7 changed files with 20 additions and 20 deletions
|
@ -1164,13 +1164,13 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
|
||||||
auto rules = value.substr(FIRST_DELIM + 1);
|
auto rules = value.substr(FIRST_DELIM + 1);
|
||||||
SWorkspaceRule wsRule;
|
SWorkspaceRule wsRule;
|
||||||
wsRule.workspaceString = first_ident;
|
wsRule.workspaceString = first_ident;
|
||||||
if (id == INT_MAX) {
|
if (id == WORKSPACE_INVALID) {
|
||||||
// it could be the monitor. If so, second value MUST be
|
// it could be the monitor. If so, second value MUST be
|
||||||
// the workspace.
|
// the workspace.
|
||||||
const auto WORKSPACE_DELIM = value.find_first_of(',', FIRST_DELIM + 1);
|
const auto WORKSPACE_DELIM = value.find_first_of(',', FIRST_DELIM + 1);
|
||||||
auto wsIdent = removeBeginEndSpacesTabs(value.substr(FIRST_DELIM + 1, (WORKSPACE_DELIM - FIRST_DELIM - 1)));
|
auto wsIdent = removeBeginEndSpacesTabs(value.substr(FIRST_DELIM + 1, (WORKSPACE_DELIM - FIRST_DELIM - 1)));
|
||||||
id = getWorkspaceIDFromString(wsIdent, name);
|
id = getWorkspaceIDFromString(wsIdent, name);
|
||||||
if (id == INT_MAX) {
|
if (id == WORKSPACE_INVALID) {
|
||||||
Debug::log(ERR, "Invalid workspace identifier found: {}", wsIdent);
|
Debug::log(ERR, "Invalid workspace identifier found: {}", wsIdent);
|
||||||
parseError = "Invalid workspace identifier found: " + wsIdent;
|
parseError = "Invalid workspace identifier found: " + wsIdent;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -279,7 +279,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
std::string requestedWorkspaceName;
|
std::string requestedWorkspaceName;
|
||||||
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString(WORKSPACEARGS.join(" ", 0, workspaceSilent ? WORKSPACEARGS.size() - 1 : 0), requestedWorkspaceName);
|
const int REQUESTEDWORKSPACEID = getWorkspaceIDFromString(WORKSPACEARGS.join(" ", 0, workspaceSilent ? WORKSPACEARGS.size() - 1 : 0), requestedWorkspaceName);
|
||||||
|
|
||||||
if (REQUESTEDWORKSPACEID != INT_MAX) {
|
if (REQUESTEDWORKSPACEID != WORKSPACE_INVALID) {
|
||||||
auto pWorkspace = g_pCompositor->getWorkspaceByID(REQUESTEDWORKSPACEID);
|
auto pWorkspace = g_pCompositor->getWorkspaceByID(REQUESTEDWORKSPACEID);
|
||||||
|
|
||||||
if (!pWorkspace)
|
if (!pWorkspace)
|
||||||
|
|
|
@ -247,7 +247,7 @@ bool isDirection(const char& arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
int result = INT_MAX;
|
int result = WORKSPACE_INVALID;
|
||||||
if (in.starts_with("special")) {
|
if (in.starts_with("special")) {
|
||||||
outName = "special";
|
outName = "special";
|
||||||
|
|
||||||
|
@ -280,17 +280,17 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
}
|
}
|
||||||
} else if (in.starts_with("prev")) {
|
} else if (in.starts_with("prev")) {
|
||||||
if (!g_pCompositor->m_pLastMonitor)
|
if (!g_pCompositor->m_pLastMonitor)
|
||||||
return INT_MAX;
|
return WORKSPACE_INVALID;
|
||||||
|
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
||||||
|
|
||||||
if (!PWORKSPACE)
|
if (!PWORKSPACE)
|
||||||
return INT_MAX;
|
return WORKSPACE_INVALID;
|
||||||
|
|
||||||
const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PWORKSPACE->m_sPrevWorkspace.iID);
|
const auto PLASTWORKSPACE = g_pCompositor->getWorkspaceByID(PWORKSPACE->m_sPrevWorkspace.iID);
|
||||||
|
|
||||||
if (!PLASTWORKSPACE)
|
if (!PLASTWORKSPACE)
|
||||||
return INT_MAX;
|
return WORKSPACE_INVALID;
|
||||||
|
|
||||||
outName = PLASTWORKSPACE->m_szName;
|
outName = PLASTWORKSPACE->m_szName;
|
||||||
return PLASTWORKSPACE->m_iID;
|
return PLASTWORKSPACE->m_iID;
|
||||||
|
@ -298,8 +298,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
if (in[0] == 'r' && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
|
if (in[0] == 'r' && (in[1] == '-' || in[1] == '+') && isNumber(in.substr(2))) {
|
||||||
if (!g_pCompositor->m_pLastMonitor) {
|
if (!g_pCompositor->m_pLastMonitor) {
|
||||||
Debug::log(ERR, "Relative monitor workspace on monitor null!");
|
Debug::log(ERR, "Relative monitor workspace on monitor null!");
|
||||||
result = INT_MAX;
|
return WORKSPACE_INVALID;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
|
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
|
||||||
|
|
||||||
|
@ -433,8 +432,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
|
|
||||||
if (!g_pCompositor->m_pLastMonitor) {
|
if (!g_pCompositor->m_pLastMonitor) {
|
||||||
Debug::log(ERR, "Relative monitor workspace on monitor null!");
|
Debug::log(ERR, "Relative monitor workspace on monitor null!");
|
||||||
result = INT_MAX;
|
return WORKSPACE_INVALID;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// monitor relative
|
// monitor relative
|
||||||
|
@ -483,7 +481,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
result = std::max((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1);
|
result = std::max((int)getPlusMinusKeywordResult(in, g_pCompositor->m_pLastMonitor->activeWorkspace), 1);
|
||||||
else {
|
else {
|
||||||
Debug::log(ERR, "Relative workspace on no mon!");
|
Debug::log(ERR, "Relative workspace on no mon!");
|
||||||
result = INT_MAX;
|
return WORKSPACE_INVALID;
|
||||||
}
|
}
|
||||||
} else if (isNumber(in))
|
} else if (isNumber(in))
|
||||||
result = std::max(std::stoi(in), 1);
|
result = std::max(std::stoi(in), 1);
|
||||||
|
|
|
@ -353,7 +353,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
||||||
findAvailableDefaultWS() :
|
findAvailableDefaultWS() :
|
||||||
getWorkspaceIDFromString(g_pConfigManager->getDefaultWorkspaceFor(szName), newDefaultWorkspaceName);
|
getWorkspaceIDFromString(g_pConfigManager->getDefaultWorkspaceFor(szName), newDefaultWorkspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
|
if (WORKSPACEID == WORKSPACE_INVALID || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
|
||||||
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
||||||
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
|
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#define STRVAL_EMPTY "[[EMPTY]]"
|
#define STRVAL_EMPTY "[[EMPTY]]"
|
||||||
|
|
||||||
|
#define WORKSPACE_INVALID -1L
|
||||||
|
|
||||||
#define LISTENER(name) \
|
#define LISTENER(name) \
|
||||||
void listener_##name(wl_listener*, void*); \
|
void listener_##name(wl_listener*, void*); \
|
||||||
inline wl_listener listen_##name = {.notify = listener_##name}
|
inline wl_listener listen_##name = {.notify = listener_##name}
|
||||||
|
|
|
@ -831,7 +831,7 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName);
|
workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workspaceToChangeTo == INT_MAX) {
|
if (workspaceToChangeTo == WORKSPACE_INVALID) {
|
||||||
Debug::log(ERR, "Error in changeworkspace, invalid value");
|
Debug::log(ERR, "Error in changeworkspace, invalid value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -920,7 +920,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
std::string workspaceName;
|
std::string workspaceName;
|
||||||
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX) {
|
if (WORKSPACEID == WORKSPACE_INVALID) {
|
||||||
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
|
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -977,7 +977,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
|
|
||||||
const int WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
const int WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX) {
|
if (WORKSPACEID == WORKSPACE_INVALID) {
|
||||||
Debug::log(ERR, "Error in moveActiveToWorkspaceSilent, invalid value");
|
Debug::log(ERR, "Error in moveActiveToWorkspaceSilent, invalid value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1233,7 @@ void CKeybindManager::alterSplitRatio(std::string args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (splitratio == INT_MAX) {
|
if (splitratio == WORKSPACE_INVALID) {
|
||||||
Debug::log(ERR, "Splitratio invalid in alterSplitRatio!");
|
Debug::log(ERR, "Splitratio invalid in alterSplitRatio!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1425,7 +1425,7 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
|
||||||
std::string workspaceName;
|
std::string workspaceName;
|
||||||
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX) {
|
if (WORKSPACEID == WORKSPACE_INVALID) {
|
||||||
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!");
|
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1447,7 +1447,7 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
std::string workspaceName = "";
|
std::string workspaceName = "";
|
||||||
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
||||||
|
|
||||||
if (workspaceID == INT_MAX || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
|
if (workspaceID == WORKSPACE_INVALID || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
|
||||||
Debug::log(ERR, "Invalid workspace passed to special");
|
Debug::log(ERR, "Invalid workspace passed to special");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
auto workspaceIDLeft = getWorkspaceIDFromString(*PSWIPENUMBER ? "-1" : (*PSWIPEUSER ? "r-1" : "m-1"), wsname);
|
auto workspaceIDLeft = getWorkspaceIDFromString(*PSWIPENUMBER ? "-1" : (*PSWIPEUSER ? "r-1" : "m-1"), wsname);
|
||||||
auto workspaceIDRight = getWorkspaceIDFromString(*PSWIPENUMBER ? "+1" : (*PSWIPEUSER ? "r+1" : "m+1"), wsname);
|
auto workspaceIDRight = getWorkspaceIDFromString(*PSWIPENUMBER ? "+1" : (*PSWIPEUSER ? "r+1" : "m+1"), wsname);
|
||||||
|
|
||||||
if ((workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) && !*PSWIPENEW) {
|
if ((workspaceIDLeft == WORKSPACE_INVALID || workspaceIDRight == WORKSPACE_INVALID || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) && !*PSWIPENEW) {
|
||||||
m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe
|
m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue