mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-16 16:50:35 +01:00
animations: Add option for animating workspaces as if the first and last were adjacent (#10277)
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland with Meson (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Waiting to run
Build Hyprland / Code Style (Arch) (push) Waiting to run
Nix (CI) / update-inputs (push) Waiting to run
Nix (CI) / build (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland with Meson (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Waiting to run
Build Hyprland / Code Style (Arch) (push) Waiting to run
Nix (CI) / update-inputs (push) Waiting to run
Nix (CI) / build (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
* add option for animating workspaces as if the first and last were adjacent * change wraparound detection to use IDs instead of dispatcher * move shouldWraparound from MiscFunctions to Monitor
This commit is contained in:
parent
930eeac900
commit
1ce614dfc0
3 changed files with 27 additions and 1 deletions
|
@ -372,6 +372,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||||
.type = CONFIG_OPTION_BOOL,
|
.type = CONFIG_OPTION_BOOL,
|
||||||
.data = SConfigOptionDescription::SBoolData{true},
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
},
|
},
|
||||||
|
SConfigOptionDescription{
|
||||||
|
.value = "animations:workspace_wraparound",
|
||||||
|
.description = "changes the direction of slide animations between the first and last workspaces",
|
||||||
|
.type = CONFIG_OPTION_BOOL,
|
||||||
|
.data = SConfigOptionDescription::SBoolData{true},
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* input:
|
* input:
|
||||||
|
|
|
@ -610,6 +610,7 @@ CConfigManager::CConfigManager() {
|
||||||
|
|
||||||
registerConfigVar("animations:enabled", Hyprlang::INT{1});
|
registerConfigVar("animations:enabled", Hyprlang::INT{1});
|
||||||
registerConfigVar("animations:first_launch_animation", Hyprlang::INT{1});
|
registerConfigVar("animations:first_launch_animation", Hyprlang::INT{1});
|
||||||
|
registerConfigVar("animations:workspace_wraparound", Hyprlang::INT{0});
|
||||||
|
|
||||||
registerConfigVar("input:follow_mouse", Hyprlang::INT{1});
|
registerConfigVar("input:follow_mouse", Hyprlang::INT{1});
|
||||||
registerConfigVar("input:follow_mouse_threshold", Hyprlang::FLOAT{0});
|
registerConfigVar("input:follow_mouse_threshold", Hyprlang::FLOAT{0});
|
||||||
|
|
|
@ -1100,6 +1100,25 @@ float CMonitor::getDefaultScale() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool shouldWraparound(const WORKSPACEID id1, const WORKSPACEID id2) {
|
||||||
|
static auto PWORKSPACEWRAPAROUND = CConfigValue<Hyprlang::INT>("animations:workspace_wraparound");
|
||||||
|
|
||||||
|
if (!*PWORKSPACEWRAPAROUND)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WORKSPACEID lowestID = INT64_MAX;
|
||||||
|
WORKSPACEID highestID = INT64_MIN;
|
||||||
|
|
||||||
|
for (auto const& w : g_pCompositor->m_workspaces) {
|
||||||
|
if (w->m_id < 0 || w->m_isSpecialWorkspace)
|
||||||
|
continue;
|
||||||
|
lowestID = std::min(w->m_id, lowestID);
|
||||||
|
highestID = std::max(w->m_id, highestID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::min(id1, id2) == lowestID && std::max(id1, id2) == highestID;
|
||||||
|
}
|
||||||
|
|
||||||
void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bool noMouseMove, bool noFocus) {
|
void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bool noMouseMove, bool noFocus) {
|
||||||
if (!pWorkspace)
|
if (!pWorkspace)
|
||||||
return;
|
return;
|
||||||
|
@ -1123,7 +1142,7 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo
|
||||||
m_activeWorkspace = pWorkspace;
|
m_activeWorkspace = pWorkspace;
|
||||||
|
|
||||||
if (!internal) {
|
if (!internal) {
|
||||||
const auto ANIMTOLEFT = POLDWORKSPACE && pWorkspace->m_id > POLDWORKSPACE->m_id;
|
const auto ANIMTOLEFT = POLDWORKSPACE && (shouldWraparound(pWorkspace->m_id, POLDWORKSPACE->m_id) ^ (pWorkspace->m_id > POLDWORKSPACE->m_id));
|
||||||
if (POLDWORKSPACE)
|
if (POLDWORKSPACE)
|
||||||
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
|
||||||
pWorkspace->startAnim(true, ANIMTOLEFT);
|
pWorkspace->startAnim(true, ANIMTOLEFT);
|
||||||
|
|
Loading…
Reference in a new issue