+void App::enqueue_flushdraw(int surface_id) {
+ this->check_flushdraw(surface_id);
+ logdebug("Enqueuing EndDraw for surface_id %d", surface_id);
+ this->pending_end_draw.push_back(surface_id);
+}
+
+void App::check_flushdraw(int surface_id) {
+ auto i = std::find(std::begin(this->pending_end_draw),
+ std::end(this->pending_end_draw), surface_id);
+ if (i != std::end(this->pending_end_draw)) {
+ auto n = this->lookup_name(surface_id);
+ logerror("Application %s (%d) has pending EndDraw call(s)!",
+ n ? n->c_str() : "unknown-name", surface_id);
+ std::swap(this->pending_end_draw[std::distance(
+ std::begin(this->pending_end_draw), i)],
+ this->pending_end_draw.back());
+ this->pending_end_draw.resize(this->pending_end_draw.size() - 1);
+ }
+}
+
+char const *App::api_enddraw(char const *drawing_name) {
+ for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) {
+ auto n = this->lookup_name(this->pending_end_draw[i]);
+ if (n && *n == drawing_name) {
+ std::swap(this->pending_end_draw[i], this->pending_end_draw[iend - 1]);
+ this->pending_end_draw.resize(iend - 1);
+ // XXX: Please tell the compositor to thaw the surface...
+ this->emit_flushdraw(drawing_name);
+ return nullptr;
+ }
+ }
+ return "No EndDraw pending for surface";
+}
+
+void App::api_ping() { this->dispatch_pending_events(); }
+