hyprland/focus_grab: wait for surface creation if null

Fixes an occasional crash with QWaylandWindow::surface() returning null.
This commit is contained in:
outfoxxed 2024-08-20 16:41:04 -07:00
parent fe1d15e8f6
commit f95e7dbaf6
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 37 additions and 7 deletions

View file

@ -74,13 +74,13 @@ void HyprlandFocusGrab::tryActivate() {
QObject::connect(this->grab, &FocusGrab::activated, this, &HyprlandFocusGrab::onGrabActivated);
QObject::connect(this->grab, &FocusGrab::cleared, this, &HyprlandFocusGrab::onGrabCleared);
this->grab->startTransaction();
for (auto* proxy: this->trackedProxies) {
if (proxy->backingWindow() != nullptr) {
this->grab->addWindow(proxy->backingWindow());
}
}
this->grab->sync();
this->grab->completeTransaction();
}
void HyprlandFocusGrab::syncWindows() {
@ -99,6 +99,8 @@ void HyprlandFocusGrab::syncWindows() {
}
}
if (this->grab) this->grab->startTransaction();
for (auto* oldWindow: this->trackedProxies) {
if (!newProxy.contains(oldWindow)) {
QObject::disconnect(oldWindow, nullptr, this, nullptr);
@ -125,7 +127,7 @@ void HyprlandFocusGrab::syncWindows() {
}
this->trackedProxies = newProxy;
if (this->grab != nullptr) this->grab->sync();
if (this->grab) this->grab->completeTransaction();
}
} // namespace qs::hyprland