Skip to content

Commit 370cb83

Browse files
committed
sway/workspaces: implement reverse-scroll
1 parent 8490a1d commit 370cb83

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

man/waybar-sway-workspaces.5.scd

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Addressed by *sway/workspaces*
3131
default: false ++
3232
If set to false, you can scroll to cycle through workspaces. If set to true this behaviour is disabled.
3333

34+
*reverse-scroll*: ++
35+
typeof: bool ++
36+
default: false ++
37+
If set to false, scrolling up will switch to the previous workspace and scrolling down will switch to the next workspace. If set to true, the behavior will be reversed.
38+
3439
*disable-click*: ++
3540
typeof: bool ++
3641
default: false ++

src/modules/sway/workspaces.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,11 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
443443
if (it == workspaces_.end()) {
444444
return true;
445445
}
446+
bool reverse_scroll = config_["reverse-scroll"].isBool() && config_["reverse-scroll"].asBool();
446447
if (dir == SCROLL_DIR::DOWN || dir == SCROLL_DIR::RIGHT) {
447-
name = getCycleWorkspace(it, false);
448+
name = getCycleWorkspace(it, reverse_scroll ? true : false);
448449
} else if (dir == SCROLL_DIR::UP || dir == SCROLL_DIR::LEFT) {
449-
name = getCycleWorkspace(it, true);
450+
name = getCycleWorkspace(it, reverse_scroll ? false : true);
450451
} else {
451452
return true;
452453
}

0 commit comments

Comments
 (0)