Fix timeout with multiple monitors
This commit is contained in:
@@ -44,6 +44,7 @@ class Client {
|
|||||||
const char* interface, uint32_t version);
|
const char* interface, uint32_t version);
|
||||||
static void handleGlobalRemove(void* data, struct wl_registry* registry, uint32_t name);
|
static void handleGlobalRemove(void* data, struct wl_registry* registry, uint32_t name);
|
||||||
static void handleOutputDone(void*, struct zxdg_output_v1*);
|
static void handleOutputDone(void*, struct zxdg_output_v1*);
|
||||||
|
void createBarsBatch();
|
||||||
static void handleOutputName(void*, struct zxdg_output_v1*, const char*);
|
static void handleOutputName(void*, struct zxdg_output_v1*, const char*);
|
||||||
static void handleOutputDescription(void*, struct zxdg_output_v1*, const char*);
|
static void handleOutputDescription(void*, struct zxdg_output_v1*, const char*);
|
||||||
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||||
@@ -58,6 +59,8 @@ class Client {
|
|||||||
std::string m_cssFile;
|
std::string m_cssFile;
|
||||||
sigc::connection monitor_added_connection_;
|
sigc::connection monitor_added_connection_;
|
||||||
sigc::connection monitor_removed_connection_;
|
sigc::connection monitor_removed_connection_;
|
||||||
|
std::vector<waybar_output*> pending_outputs_;
|
||||||
|
bool bars_scheduled_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar
|
} // namespace waybar
|
||||||
|
|||||||
+26
-5
@@ -91,11 +91,14 @@ void waybar::Client::handleOutputDone(void* data, struct zxdg_output_v1* /*xdg_o
|
|||||||
output.xdg_output.reset();
|
output.xdg_output.reset();
|
||||||
spdlog::debug("Output detection done: {} ({})", output.name, output.identifier);
|
spdlog::debug("Output detection done: {} ({})", output.name, output.identifier);
|
||||||
|
|
||||||
auto configs = client->getOutputConfigs(output);
|
client->pending_outputs_.push_back(&output);
|
||||||
if (!configs.empty()) {
|
|
||||||
for (const auto& config : configs) {
|
if (!client->bars_scheduled_) {
|
||||||
client->bars.emplace_back(std::make_unique<Bar>(&output, config));
|
client->bars_scheduled_ = true;
|
||||||
}
|
|
||||||
|
Glib::signal_idle().connect_once([client]() {
|
||||||
|
client->createBarsBatch();
|
||||||
|
}, Glib::PRIORITY_HIGH_IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
@@ -103,6 +106,24 @@ void waybar::Client::handleOutputDone(void* data, struct zxdg_output_v1* /*xdg_o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void waybar::Client::createBarsBatch() {
|
||||||
|
for (auto* output : pending_outputs_) {
|
||||||
|
try {
|
||||||
|
auto configs = getOutputConfigs(*output);
|
||||||
|
if (!configs.empty()) {
|
||||||
|
for (const auto& config : configs) {
|
||||||
|
bars.emplace_back(std::make_unique<Bar>(output, config));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
spdlog::warn("Error creating bar: {}", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pending_outputs_.clear();
|
||||||
|
bars_scheduled_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
void waybar::Client::handleOutputName(void* data, struct zxdg_output_v1* /*xdg_output*/,
|
void waybar::Client::handleOutputName(void* data, struct zxdg_output_v1* /*xdg_output*/,
|
||||||
const char* name) {
|
const char* name) {
|
||||||
auto* client = waybar::Client::inst();
|
auto* client = waybar::Client::inst();
|
||||||
|
|||||||
Reference in New Issue
Block a user