* Also, move binding_m mutex to the binding glue.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
p(' {}', '};')
def emit_binding(api):
- p('namespace {', '')
+ p('namespace {')
+ p('std::mutex binding_m;', '')
for func in api['functions']:
emit_func(api, func)
p('} // namespace', '')
for f in api['functions']:
p(' result_type %(name)s(' % f + ', '.join(map(lambda x: '%(type)s %(name)s' % x, f.get('args', []))) + ');')
p('};', '')
- p('} // namespace wm')
+ p('} // namespace wm', '')
# names must always be valid in c and unique for each function (that is its arguments)
# arguments will be looked up from json request, range checking needs to be implemented
}
binding_api::result_type binding_api::ping() {
- this->app->dispatch_events();
+ this->app->dispatch_pending_events();
return Ok(json_object_new_object());
}
}
int App::dispatch_events() {
- if (this->pending_events.load(std::memory_order_consume)) {
- this->pending_events.store(false, std::memory_order_release);
- return this->display->dispatch_pending();
+ if (this->dispatch_events() == 0) {
+ return 0;
}
int ret = this->display->dispatch();
return 0;
}
+int App::dispatch_pending_events() {
+ if (this->pending_events.load(std::memory_order_consume)) {
+ this->pending_events.store(false, std::memory_order_release);
+ this->display->dispatch_pending();
+ return 0;
+ }
+ return -1;
+}
+
// _ _ _ _ _ ____
// (_)_ __ (_) |_ | | __ _ _ _ ___ _ _| |_ / /\ \
// | | '_ \| | __| | |/ _` | | | |/ _ \| | | | __| | | |
int init_layers();
int dispatch_events();
+ int dispatch_pending_events();
void surface_set_layout_full(uint32_t surface_id);
void surface_set_layout_split(uint32_t surface_id, uint32_t sub_surface_id);
}
namespace {
-std::mutex binding_m;
struct afb_instance {
std::unique_ptr<wl::display> display;
#include <utility>
+#include "util.hpp"
#include "wayland.hpp"
// _
int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
int display::read_events() {
+ ST();
// XXX: uhm, how?!
while (wl_display_prepare_read(this->d.get()) == -1) {
+ STN(pending_events_dispatch);
if (wl_display_dispatch_pending(this->d.get()) == -1) {
return -1;
}