mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-24 17:45:58 +01:00
Add option for animating workspaces as an infinite band
This commit is contained in:
parent
489ac40abd
commit
4218031aec
6 changed files with 21 additions and 4 deletions
|
@ -432,6 +432,7 @@ CConfigManager::CConfigManager() {
|
||||||
|
|
||||||
m_pConfig->addConfigValue("animations:enabled", {1L});
|
m_pConfig->addConfigValue("animations:enabled", {1L});
|
||||||
m_pConfig->addConfigValue("animations:first_launch_animation", {1L});
|
m_pConfig->addConfigValue("animations:first_launch_animation", {1L});
|
||||||
|
m_pConfig->addConfigValue("animations:workspace_wraparound", {0L});
|
||||||
|
|
||||||
m_pConfig->addConfigValue("input:follow_mouse", {1L});
|
m_pConfig->addConfigValue("input:follow_mouse", {1L});
|
||||||
m_pConfig->addConfigValue("input:mouse_refocus", {1L});
|
m_pConfig->addConfigValue("input:mouse_refocus", {1L});
|
||||||
|
|
|
@ -521,6 +521,15 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<bool> isWorkspaceChangeDirectionLeft(const std::string& args) {
|
||||||
|
if ((args[0] == '-' || args[0] == '+') && isNumber(args.substr(1)))
|
||||||
|
return args[0] == '+';
|
||||||
|
else if ((args[0] == 'r' || args[0] == 'm' || args[0] == 'e') && (args[1] == '-' || args[1] == '+') && isNumber(args.substr(2)))
|
||||||
|
return args[1] == '+';
|
||||||
|
else
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<std::string> cleanCmdForWorkspace(const std::string& inWorkspaceName, std::string dirtyCmd) {
|
std::optional<std::string> cleanCmdForWorkspace(const std::string& inWorkspaceName, std::string dirtyCmd) {
|
||||||
|
|
||||||
std::string cmd = removeBeginEndSpacesTabs(dirtyCmd);
|
std::string cmd = removeBeginEndSpacesTabs(dirtyCmd);
|
||||||
|
|
|
@ -22,6 +22,7 @@ bool isNumber(const std::string&, bool allowfloat =
|
||||||
bool isDirection(const std::string&);
|
bool isDirection(const std::string&);
|
||||||
bool isDirection(const char&);
|
bool isDirection(const char&);
|
||||||
int getWorkspaceIDFromString(const std::string&, std::string&);
|
int getWorkspaceIDFromString(const std::string&, std::string&);
|
||||||
|
std::optional<bool> isWorkspaceChangeDirectionLeft(const std::string&);
|
||||||
std::optional<std::string> cleanCmdForWorkspace(const std::string&, std::string);
|
std::optional<std::string> cleanCmdForWorkspace(const std::string&, std::string);
|
||||||
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
|
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
|
||||||
void logSystemInfo();
|
void logSystemInfo();
|
||||||
|
|
|
@ -536,7 +536,7 @@ float CMonitor::getDefaultScale() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool noMouseMove, bool noFocus) {
|
void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool noMouseMove, bool noFocus, std::optional<bool> animateLeftOverride) {
|
||||||
if (!pWorkspace)
|
if (!pWorkspace)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool
|
||||||
activeWorkspace = pWorkspace->m_iID;
|
activeWorkspace = pWorkspace->m_iID;
|
||||||
|
|
||||||
if (!internal) {
|
if (!internal) {
|
||||||
const auto ANIMTOLEFT = pWorkspace->m_iID > POLDWORKSPACE->m_iID;
|
const auto ANIMTOLEFT = animateLeftOverride.value_or(pWorkspace->m_iID > POLDWORKSPACE->m_iID);
|
||||||
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
||||||
pWorkspace->startAnim(true, ANIMTOLEFT);
|
pWorkspace->startAnim(true, ANIMTOLEFT);
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class CMonitor {
|
||||||
bool isMirror();
|
bool isMirror();
|
||||||
bool matchesStaticSelector(const std::string& selector) const;
|
bool matchesStaticSelector(const std::string& selector) const;
|
||||||
float getDefaultScale();
|
float getDefaultScale();
|
||||||
void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false);
|
void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false, bool noMouseMove = false, bool noFocus = false, std::optional<bool> animateLeftOverride = {});
|
||||||
void changeWorkspace(const int& id, bool internal = false, bool noMouseMove = false, bool noFocus = false);
|
void changeWorkspace(const int& id, bool internal = false, bool noMouseMove = false, bool noFocus = false);
|
||||||
void setSpecialWorkspace(CWorkspace* const pWorkspace);
|
void setSpecialWorkspace(CWorkspace* const pWorkspace);
|
||||||
void setSpecialWorkspace(const int& id);
|
void setSpecialWorkspace(const int& id);
|
||||||
|
|
|
@ -895,6 +895,7 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
static auto* const PBACKANDFORTH = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth");
|
static auto* const PBACKANDFORTH = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth");
|
||||||
static auto* const PALLOWWORKSPACECYCLES = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles");
|
static auto* const PALLOWWORKSPACECYCLES = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles");
|
||||||
static auto* const PWORKSPACECENTERON = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:workspace_center_on");
|
static auto* const PWORKSPACECENTERON = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("binds:workspace_center_on");
|
||||||
|
static auto* const PWORKSPACEWRAPAROUND = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("animations:workspace_wraparound");
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
|
|
||||||
|
@ -955,7 +956,12 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
|
|
||||||
g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);
|
g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);
|
||||||
|
|
||||||
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
|
if (**PWORKSPACEWRAPAROUND) {
|
||||||
|
const auto ANIMATELEFT = isWorkspaceChangeDirectionLeft(args);
|
||||||
|
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true, false, ANIMATELEFT);
|
||||||
|
} else {
|
||||||
|
PMONITORWORKSPACEOWNER->changeWorkspace(pWorkspaceToChangeTo, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (PMONITOR != PMONITORWORKSPACEOWNER) {
|
if (PMONITOR != PMONITORWORKSPACEOWNER) {
|
||||||
Vector2D middle = PMONITORWORKSPACEOWNER->middle();
|
Vector2D middle = PMONITORWORKSPACEOWNER->middle();
|
||||||
|
|
Loading…
Reference in a new issue