From 3e1c77d1588b8c72e6f2203f16af9f927dd7a3d0 Mon Sep 17 00:00:00 2001 From: RX14 Date: Fri, 17 May 2019 17:53:38 +0100 Subject: [PATCH] Add option to disable scroll wraparound on workspaces --- src/modules/sway/workspaces.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index a623b411..231b3363 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -215,7 +215,7 @@ bool Workspaces::handleScroll(GdkEventScroll *e) { const std::string Workspaces::getCycleWorkspace(std::vector::iterator it, bool prev) const { - if (prev && it == workspaces_.begin()) { + if (prev && it == workspaces_.begin() && !config_["disable-scroll-wraparound"].asBool()) { return (*(--workspaces_.end()))["name"].asString(); } if (prev && it != workspaces_.begin()) @@ -223,7 +223,11 @@ const std::string Workspaces::getCycleWorkspace(std::vector::iterat else if (!prev && it != workspaces_.end()) ++it; if (!prev && it == workspaces_.end()) { - return (*(workspaces_.begin()))["name"].asString(); + if (config_["disable-scroll-wraparound"].asBool()) { + --it; + } else { + return (*(workspaces_.begin()))["name"].asString(); + } } return (*it)["name"].asString(); }