forked from quickshell/quickshell
hyprland/ipc: fix monitorFor returning null during HyprlandIpc init
This commit is contained in:
parent
bc349998df
commit
5d1def3e49
|
@ -465,10 +465,12 @@ HyprlandMonitor* HyprlandIpc::focusedMonitor() const { return this->mFocusedMoni
|
||||||
|
|
||||||
HyprlandMonitor* HyprlandIpc::monitorFor(QuickshellScreenInfo* screen) {
|
HyprlandMonitor* HyprlandIpc::monitorFor(QuickshellScreenInfo* screen) {
|
||||||
// Wayland monitors appear after hyprland ones are created and disappear after destruction
|
// Wayland monitors appear after hyprland ones are created and disappear after destruction
|
||||||
// so simply not doing any preemptive creation is enough.
|
// so simply not doing any preemptive creation is enough, however if this call creates
|
||||||
|
// the HyprlandIpc singleton then monitors won't be initialized, in which case we
|
||||||
|
// preemptively create one.
|
||||||
|
|
||||||
if (screen == nullptr) return nullptr;
|
if (screen == nullptr) return nullptr;
|
||||||
return this->findMonitorByName(screen->name(), false);
|
return this->findMonitorByName(screen->name(), !this->monitorsRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HyprlandIpc::setFocusedMonitor(HyprlandMonitor* monitor) {
|
void HyprlandIpc::setFocusedMonitor(HyprlandMonitor* monitor) {
|
||||||
|
@ -505,6 +507,8 @@ void HyprlandIpc::refreshMonitors(bool canCreate, bool tryAgain) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->monitorsRequested = true;
|
||||||
|
|
||||||
qCDebug(logHyprlandIpc) << "parsing monitors response";
|
qCDebug(logHyprlandIpc) << "parsing monitors response";
|
||||||
auto json = QJsonDocument::fromJson(resp).array();
|
auto json = QJsonDocument::fromJson(resp).array();
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ private:
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
bool requestingMonitors = false;
|
bool requestingMonitors = false;
|
||||||
bool requestingWorkspaces = false;
|
bool requestingWorkspaces = false;
|
||||||
|
bool monitorsRequested = false;
|
||||||
|
|
||||||
ObjectModel<HyprlandMonitor> mMonitors {this};
|
ObjectModel<HyprlandMonitor> mMonitors {this};
|
||||||
ObjectModel<HyprlandWorkspace> mWorkspaces {this};
|
ObjectModel<HyprlandWorkspace> mWorkspaces {this};
|
||||||
|
|
Loading…
Reference in a new issue