diff options
author | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-12 11:29:28 +0200 |
---|---|---|
committer | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-12 11:29:28 +0200 |
commit | b154238b7b9e0d21b60c08a1bec23920bff40e36 (patch) | |
tree | a9aef373b01f3637d823046322b43ef6387a2349 /src | |
parent | 01058af8b919e1c58207008ea9609f2e7b23efac (diff) |
binding: ping() dispatches only pending events
* Also, move binding_m mutex to the binding glue.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/afb_binding_api.cpp | 2 | ||||
-rw-r--r-- | src/app.cpp | 14 | ||||
-rw-r--r-- | src/app.hpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/wayland.cpp | 3 |
5 files changed, 16 insertions, 5 deletions
diff --git a/src/afb_binding_api.cpp b/src/afb_binding_api.cpp index 7e6aa89..41eed13 100644 --- a/src/afb_binding_api.cpp +++ b/src/afb_binding_api.cpp @@ -100,7 +100,7 @@ binding_api::result_type binding_api::debug_terminate() { } binding_api::result_type binding_api::ping() { - this->app->dispatch_events(); + this->app->dispatch_pending_events(); return Ok(json_object_new_object()); } diff --git a/src/app.cpp b/src/app.cpp index e42d05f..7b2b69c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -147,9 +147,8 @@ int App::init() { } 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(); @@ -166,6 +165,15 @@ int App::dispatch_events() { 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; +} + // _ _ _ _ _ ____ // (_)_ __ (_) |_ | | __ _ _ _ ___ _ _| |_ / /\ \ // | | '_ \| | __| | |/ _` | | | |/ _ \| | | | __| | | | diff --git a/src/app.hpp b/src/app.hpp index 00a2ba2..e295797 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -162,6 +162,7 @@ struct App { 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); diff --git a/src/main.cpp b/src/main.cpp index 4c04f74..aee2756 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,6 @@ extern "C" { } namespace { -std::mutex binding_m; struct afb_instance { std::unique_ptr<wl::display> display; diff --git a/src/wayland.cpp b/src/wayland.cpp index 25c2359..fb18386 100644 --- a/src/wayland.cpp +++ b/src/wayland.cpp @@ -16,6 +16,7 @@ #include <utility> +#include "util.hpp" #include "wayland.hpp" // _ @@ -46,8 +47,10 @@ int display::dispatch() { return wl_display_dispatch(this->d.get()); } 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; } |