diff --git a/data/config b/data/config index 623b1d5..a1422b3 100644 --- a/data/config +++ b/data/config @@ -28,6 +28,12 @@ BatteryFolder: /sys/class/power_supply/BAT1 # The default symbol for the workspaces DefaultWorkspaceSymbol:  +# Scroll through the workspaces of the current monitor instead of all workspaces +WorkspaceScrollOnMonitor: true + +# When true: Scroll up -> Next workspace instead of previous workspace. Analogous with scroll down +WorkspaceScrollInvert: false + # Forces the time to be centered. # This can cause issues, if there is not enough space on screen (e.g. when opening the text) CenterTime: true diff --git a/src/Bar.cpp b/src/Bar.cpp index 6050195..c6aaf1b 100644 --- a/src/Bar.cpp +++ b/src/Bar.cpp @@ -196,6 +196,26 @@ namespace Bar } return TimerResult::Ok; } + + void ScrollWorkspaces(EventBox&, ScrollDirection direction) + { + switch (direction) + { + case ScrollDirection::Up: + if (Config::Get().workspaceScrollInvert) + System::GotoNextWorkspace('+'); + else + System::GotoNextWorkspace('-'); + break; + case ScrollDirection::Down: + if (Config::Get().workspaceScrollInvert) + System::GotoNextWorkspace('-'); + else + System::GotoNextWorkspace('+'); + break; + default: break; + } + } #endif } @@ -473,26 +493,30 @@ namespace Bar auto margin = Widget::Create(); margin->SetHorizontalTransform({12, true, Alignment::Left}); parent.AddChild(std::move(margin)); - - auto box = Widget::Create(); - box->SetSpacing({8, true}); - box->SetHorizontalTransform({-1, true, Alignment::Left}); + auto eventBox = Widget::Create(); + eventBox->SetScrollFn(DynCtx::ScrollWorkspaces); { - for (size_t i = 0; i < DynCtx::workspaces.size(); i++) + auto box = Widget::Create(); + box->SetSpacing({8, true}); + box->SetHorizontalTransform({-1, true, Alignment::Left}); { - auto workspace = Widget::Create