Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for animating workspaces as an infinite band #4684

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ CConfigManager::CConfigManager() {

m_pConfig->addConfigValue("animations:enabled", {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:mouse_refocus", {1L});
Expand Down
9 changes: 9 additions & 0 deletions src/helpers/MiscFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
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::string cmd = removeBeginEndSpacesTabs(dirtyCmd);
Expand Down
1 change: 1 addition & 0 deletions src/helpers/MiscFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ bool isNumber(const std::string&, bool allowfloat =
bool isDirection(const std::string&);
bool isDirection(const char&);
int getWorkspaceIDFromString(const std::string&, std::string&);
std::optional<bool> isWorkspaceChangeDirectionLeft(const std::string&);
std::optional<std::string> cleanCmdForWorkspace(const std::string&, std::string);
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
void logSystemInfo();
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ float CMonitor::getDefaultScale() {
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)
return;

Expand All @@ -556,7 +556,7 @@ void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal, bool
activeWorkspace = pWorkspace->m_iID;

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);
pWorkspace->startAnim(true, ANIMTOLEFT);

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CMonitor {
bool isMirror();
bool matchesStaticSelector(const std::string& selector) const;
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 setSpecialWorkspace(CWorkspace* const pWorkspace);
void setSpecialWorkspace(const int& id);
Expand Down
8 changes: 7 additions & 1 deletion src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 PWORKSPACEWRAPAROUND = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("animations:workspace_wraparound");

const auto PMONITOR = g_pCompositor->m_pLastMonitor;

Expand Down Expand Up @@ -955,7 +956,12 @@ void CKeybindManager::changeworkspace(std::string args) {

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) {
Vector2D middle = PMONITORWORKSPACEOWNER->middle();
Expand Down
Loading