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

Fixes for hyprland/workspaces #3143

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
14 changes: 11 additions & 3 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,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 184 in src/modules/hyprland/workspaces.cpp

View workflow job for this annotation

GitHub Actions / build

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

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

// remove workspaces that wait to be removed
Expand All @@ -194,6 +194,10 @@
for (auto &[workspaceData, clientsData] : m_workspacesToCreate) {
createWorkspace(workspaceData, clientsData);
}
if (!m_workspacesToCreate.empty()) {
updateWindowCount();
sortWorkspaces();
}
m_workspacesToCreate.clear();

// get all active workspaces
Expand Down Expand Up @@ -318,7 +322,7 @@
onWorkspaceCreated(payload);
} else if (eventName == "focusedmon") {
onMonitorFocused(payload);
} else if (eventName == "moveworkspace" && !allOutputs()) {
} else if (eventName == "moveworkspace") {
onWorkspaceMoved(payload);
} else if (eventName == "openwindow") {
onWindowOpened(payload);
Expand Down Expand Up @@ -387,6 +391,12 @@

void Workspaces::onWorkspaceMoved(std::string const &payload) {
spdlog::debug("Workspace moved: {}", payload);

// Update active workspace
m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString();

if (allOutputs()) return;

std::string workspaceName = payload.substr(0, payload.find(','));
std::string monitorName = payload.substr(payload.find(',') + 1);

Expand Down Expand Up @@ -826,8 +836,6 @@
m_activeWorkspaceName = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString();

initializeWorkspaces();
updateWindowCount();
sortWorkspaces();
dp.emit();
}

Expand Down
Loading