Skip to content

Commit 90f287c

Browse files
committed
feat(hyprland/workspaces): add deduplicate-windows option
Add a new configuration option 'deduplicate-windows' that filters duplicate application entries from workspace window lists. When enabled, this feature tracks seen window representations and skips duplicates based on their rewritten representation (after window-rewrite rules are applied). The deduplication works for both display modes: - Regular {windows} format string substitution - Workspace taskbar feature This is useful when multiple windows of the same application appear in a workspace and users prefer to see only unique entries. Usage: "hyprland/workspaces": { "deduplicate-windows": true }
1 parent 161367d commit 90f287c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

include/modules/hyprland/workspaces.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Workspaces : public AModule, public EventHandler {
4141
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
4242
auto persistentOnly() const -> bool { return m_persistentOnly; }
4343
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
44+
auto deduplicateWindows() const -> bool { return m_deduplicateWindows; }
4445
auto enableTaskbar() const -> bool { return m_enableTaskbar; }
4546
auto taskbarWithIcon() const -> bool { return m_taskbarWithIcon; }
4647

@@ -145,6 +146,7 @@ class Workspaces : public AModule, public EventHandler {
145146
bool m_specialVisibleOnly = false;
146147
bool m_persistentOnly = false;
147148
bool m_moveToMonitor = false;
149+
bool m_deduplicateWindows = false;
148150
Json::Value m_persistentWorkspaceConfig;
149151

150152
// Map for windows stored in workspaces not present in the current bar.

src/modules/hyprland/workspace.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <spdlog/spdlog.h>
33

44
#include <memory>
5+
#include <set>
56
#include <string>
67
#include <utility>
78

@@ -247,8 +248,18 @@ void Workspace::update(const std::string &workspace_icon) {
247248
auto windowSeparator = m_workspaceManager.getWindowSeparator();
248249

249250
bool isNotFirst = false;
251+
std::set<std::string> seenWindows;
250252

251253
for (const auto &window_repr : m_windowMap) {
254+
if (shouldSkipWindow(window_repr)) {
255+
continue;
256+
}
257+
if (m_workspaceManager.deduplicateWindows()) {
258+
if (seenWindows.contains(window_repr.repr_rewrite)) {
259+
continue; // skip duplicate
260+
}
261+
seenWindows.insert(window_repr.repr_rewrite);
262+
}
252263
if (isNotFirst) {
253264
windows.append(windowSeparator);
254265
}
@@ -287,10 +298,17 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
287298
}
288299

289300
bool isFirst = true;
301+
std::set<std::string> seenWindows;
290302
auto processWindow = [&](const WindowRepr &window_repr) {
291303
if (shouldSkipWindow(window_repr)) {
292304
return; // skip
293305
}
306+
if (m_workspaceManager.deduplicateWindows()) {
307+
if (seenWindows.contains(window_repr.repr_rewrite)) {
308+
return; // skip duplicate
309+
}
310+
seenWindows.insert(window_repr.repr_rewrite);
311+
}
294312
if (isFirst) {
295313
isFirst = false;
296314
} else if (m_workspaceManager.getWindowSeparator() != "") {

src/modules/hyprland/workspaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
631631
populateBoolConfig(config, "persistent-only", m_persistentOnly);
632632
populateBoolConfig(config, "active-only", m_activeOnly);
633633
populateBoolConfig(config, "move-to-monitor", m_moveToMonitor);
634+
populateBoolConfig(config, "deduplicate-windows", m_deduplicateWindows);
634635

635636
m_persistentWorkspaceConfig = config.get("persistent-workspaces", Json::Value());
636637
populateSortByConfig(config);

0 commit comments

Comments
 (0)