Implement "reverse-direction"

This commit is contained in:
Pol Rivero
2025-08-18 20:46:02 +02:00
parent 83f16a2092
commit 691b7d427b
4 changed files with 21 additions and 2 deletions

View File

@ -51,6 +51,7 @@ class Workspaces : public AModule, public EventHandler {
auto taskbarFormatAfter() const -> std::string { return m_taskbarFormatAfter; }
auto taskbarIconSize() const -> int { return m_taskbarIconSize; }
auto taskbarOrientation() const -> Gtk::Orientation { return m_taskbarOrientation; }
auto taskbarReverseDirection() const -> bool { return m_taskbarReverseDirection; }
auto onClickWindow() const -> std::string { return m_onClickWindow; }
auto getIgnoredWindows() const -> std::vector<std::regex> { return m_ignoreWindows; }
@ -183,6 +184,7 @@ class Workspaces : public AModule, public EventHandler {
std::string m_taskbarFormatAfter;
int m_taskbarIconSize = 16;
Gtk::Orientation m_taskbarOrientation = Gtk::ORIENTATION_HORIZONTAL;
bool m_taskbarReverseDirection = false;
std::string m_onClickWindow;
std::string m_currentActiveWindowAddress;

View File

@ -55,6 +55,11 @@ This setting is ignored if *workspace-taskbar.enable* is set to true.
default: false ++
If true, the active/focused window will have an 'active' class. Could cause higher CPU usage due to more frequent redraws.
*reverse-direction*: ++
typeof: bool ++
default: false ++
If true, the taskbar windows will be added in reverse order (right to left if orientation is horizontal, bottom to top if vertical).
*format*: ++
typeof: string ++
default: {icon} ++

View File

@ -259,9 +259,9 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
}
bool isFirst = true;
for (const auto &window_repr : m_windowMap) {
auto processWindow = [&](const WindowRepr &window_repr) {
if (shouldSkipWindow(window_repr)) {
continue;
return; // skip
}
if (isFirst) {
isFirst = false;
@ -270,6 +270,7 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
m_content.pack_start(*windowSeparator, false, false);
windowSeparator->show();
}
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
window_box->set_tooltip_text(window_repr.window_title);
window_box->get_style_context()->add_class("taskbar-window");
@ -307,6 +308,16 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
m_content.pack_start(*event_box, true, false);
event_box->show_all();
};
if (m_workspaceManager.taskbarReverseDirection()) {
for (auto it = m_windowMap.rbegin(); it != m_windowMap.rend(); ++it) {
processWindow(*it);
}
} else {
for (const auto &window_repr : m_windowMap) {
processWindow(window_repr);
}
}
auto formatAfter = m_workspaceManager.formatAfter();

View File

@ -728,6 +728,7 @@ auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value &config) -> vo
populateBoolConfig(workspaceTaskbar, "enable", m_enableTaskbar);
populateBoolConfig(workspaceTaskbar, "update-active-window", m_updateActiveWindow);
populateBoolConfig(workspaceTaskbar, "reverse-direction", m_taskbarReverseDirection);
if (workspaceTaskbar["format"].isString()) {
/* The user defined a format string, use it */