X Tutup
Skip to content

sway monitor fixes upstream#605

Open
Mathew-D wants to merge 4 commits intoquickshell-mirror:masterfrom
Mathew-D:pr/sway-monitor-fixes-upstream
Open

sway monitor fixes upstream#605
Mathew-D wants to merge 4 commits intoquickshell-mirror:masterfrom
Mathew-D:pr/sway-monitor-fixes-upstream

Conversation

@Mathew-D
Copy link

@Mathew-D Mathew-D commented Mar 4, 2026

When monitors were turned off quick shell would crash. When it went into lock it would red screen. This fixes that.

This PR fixes two issues seen on Sway when monitors are powered off/on:

  • quickshell could segfault during output/workspace churn
    
  • after recovery, one monitor panel could remain missing
    

Root Cause

The i3/Sway IPC path was keeping cross-references between monitor/workspace objects that could become stale during rapid output/workspace updates.
Panel windows that are recreated on invisibility could lose requested-visible intent during compositor-driven hide/recreate cycles.

Mathew-D added 2 commits March 4, 2026 17:53
Harden I3/Sway IPC monitor/workspace lifetime handling: avoid stale cross-pointers, use focused-monitor setter consistently, and guard focused monitor dereference during workspace removal.
Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two separate changes here. In the future please make one PR per isolated change so unrelated changes aren't blocked on reviews of other changes.

Comment on lines 290 to 294
if (this->bFocusedWorkspace == oldWorkspace) {
this->bFocusedMonitor->setFocusedWorkspace(nullptr);
if (auto* focusedMonitor = this->bFocusedMonitor.value()) {
focusedMonitor->setFocusedWorkspace(nullptr);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant with the destroy signal path.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed this null-check looks redundant with the existing binding and destroy handling. I added it defensively while debugging and never removed it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the whole if is redundant because the monitor will be updated by the destroy signal

Comment on lines +58 to +60
void I3Monitor::setFocusedWorkspace(I3Workspace* workspace) { this->setActiveWorkspace(workspace); };

void I3Monitor::setActiveWorkspace(I3Workspace* workspace) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to have one function that just calls the other one here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it this way to stay consistent with activeWorkspace, and to keep this fix small without touching a bunch of call sites. Mostly just a naming thing.

Copy link
Member

@outfoxxed outfoxxed Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just move the body to setFocusedWorkspace or delete setFocusedWorkspace

if (auto* focusedMonitor = this->bFocusedMonitor.value()) {
focusedMonitor->setFocusedWorkspace(nullptr);
}
this->bFocusedMonitor->setFocusedWorkspace(nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set is redundant as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about all the extra nullptr checks, I was mainly trying to catch the error that was crashing QS whenever I turned off my screens in Sway. I don’t currently run mainline QS anymore since the shell I use has moved to its own fork, and this patch has been working well there with no more crashes. Please feel free to adjust this PR as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup