From a67e692d4ac491849d93e6b05aea19b19c662dc9 Mon Sep 17 00:00:00 2001 From: sigboe Date: Wed, 7 Jun 2023 15:25:59 +0200 Subject: [PATCH] sway: warp-on-scroll toggle --- man/waybar-sway-workspaces.5.scd | 5 +++++ resources/config | 1 + src/modules/sway/workspaces.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/man/waybar-sway-workspaces.5.scd b/man/waybar-sway-workspaces.5.scd index 644cba46..50e61b71 100644 --- a/man/waybar-sway-workspaces.5.scd +++ b/man/waybar-sway-workspaces.5.scd @@ -77,6 +77,11 @@ Addressed by *sway/workspaces* typeof: bool ++ Whether to sort workspaces alphabetically. Please note this can make "swaymsg workspace prev/next" move to workspaces inconsistent with the ordering shown in Waybar. +warp-on-scroll: ++ + typeof: bool ++ + default: true ++ + If set to false, you can scroll to cycle through workspaces without mouse warping being enabled. If set to true this behaviour is disabled. + # FORMAT REPLACEMENTS *{value}*: Name of the workspace, as defined by sway. diff --git a/resources/config b/resources/config index ad76e937..daad8ab1 100644 --- a/resources/config +++ b/resources/config @@ -12,6 +12,7 @@ // "sway/workspaces": { // "disable-scroll": true, // "all-outputs": true, + // "warp-on-scroll": false, // "format": "{name}: {icon}", // "format-icons": { // "1": "", diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 2bf02476..564a023e 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -326,11 +326,17 @@ bool Workspaces::handleScroll(GdkEventScroll *e) { return true; } } + if (!config_["warp-on-scroll"].asBool()) { + ipc_.sendCmd(IPC_COMMAND, fmt::format("mouse_warping none")); + } try { ipc_.sendCmd(IPC_COMMAND, fmt::format(workspace_switch_cmd_, "--no-auto-back-and-forth", name)); } catch (const std::exception &e) { spdlog::error("Workspaces: {}", e.what()); } + if (!config_["warp-on-scroll"].asBool()) { + ipc_.sendCmd(IPC_COMMAND, fmt::format("mouse_warping container")); + } return true; }