Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyprland workspaces hosting-monitor css class #2968

Merged
merged 4 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/modules/hyprland/workspaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Workspace {
void setVisible(bool value = true) { m_isVisible = value; };
void setWindows(uint value) { m_windows = value; };
void setName(std::string const& value) { m_name = value; };
void setOutput(std::string const& value) { m_output = value; };
bool containsWindow(WindowAddress const& addr) const { return m_windowMap.contains(addr); }
void insertWindow(WindowCreationPayload create_window_paylod);
std::string removeWindow(WindowAddress const& addr);
Expand Down
1 change: 1 addition & 0 deletions man/waybar-hyprland-workspaces.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ Additional to workspace name matching, the following *format-icons* can be set.
- *#workspaces button.persistent*
- *#workspaces button.special*
- *#workspaces button.urgent*
- *#workspaces button.hosting-monitor* (gets applied if workspace-monitor == waybar-monitor)
12 changes: 12 additions & 0 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
* Note: some memberfields are modified by both UI thread and event listener thread, use m_mutex to
* protect these member fields, and lock should released before calling AModule::update().
*/
void Workspaces::doUpdate() {

Check warning on line 179 in src/modules/hyprland/workspaces.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/hyprland/workspaces.cpp:179:18 [readability-function-cognitive-complexity]

function 'doUpdate' has cognitive complexity of 35 (threshold 25)
std::unique_lock lock(m_mutex);

// remove workspaces that wait to be removed
Expand Down Expand Up @@ -208,6 +208,7 @@
}

spdlog::trace("Updating workspace states");
auto updated_workspaces = gIPC->getSocket1JsonReply("workspaces");

Check warning on line 211 in src/modules/hyprland/workspaces.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/hyprland/workspaces.cpp:211:8 [readability-identifier-naming]

invalid case style for variable 'updated_workspaces'
for (auto &workspace : m_workspaces) {
// active
workspace->setActive(workspace->name() == m_activeWorkspaceName ||
Expand All @@ -226,6 +227,16 @@
if (m_withIcon) {
workspaceIcon = workspace->selectIcon(m_iconsMap);
}

// update m_output
auto updated_workspace =

Check warning on line 232 in src/modules/hyprland/workspaces.cpp

View workflow job for this annotation

GitHub Actions / build

src/modules/hyprland/workspaces.cpp:232:10 [readability-identifier-naming]

invalid case style for variable 'updated_workspace'
std::find_if(updated_workspaces.begin(), updated_workspaces.end(), [&workspace](auto &w) {
auto wNameRaw = w["name"].asString();
auto wName = wNameRaw.starts_with("special:") ? wNameRaw.substr(8) : wNameRaw;
return wName == workspace->name();
});
workspace->setOutput((*updated_workspace)["monitor"].asString());

workspace->update(m_format, workspaceIcon);
}

Expand Down Expand Up @@ -861,6 +872,7 @@
addOrRemoveClass(styleContext, isPersistent(), "persistent");
addOrRemoveClass(styleContext, isUrgent(), "urgent");
addOrRemoveClass(styleContext, isVisible(), "visible");
addOrRemoveClass(styleContext, m_workspaceManager.getBarOutput() == output(), "hosting-monitor");

std::string windows;
auto windowSeparator = m_workspaceManager.getWindowSeparator();
Expand Down
Loading