UI
This commit is contained in:
@@ -26,14 +26,14 @@ struct vamp_zero::touch_input::state : std::enable_shared_from_this<state> {
|
||||
if (!command) {
|
||||
return;
|
||||
}
|
||||
boost::asio::post(timer.get_executor(), [weak = weak_from_this(), command = *command] {
|
||||
boost::asio::post(timer.get_executor(), [weak = weak_from_this(), command = *command, generation = input_generation] {
|
||||
auto self = weak.lock();
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
auto lock = std::scoped_lock{self->mutex};
|
||||
if (self->stopped) {
|
||||
if (self->stopped || generation != self->input_generation) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ struct vamp_zero::touch_input::state : std::enable_shared_from_this<state> {
|
||||
vamp_protocol::gesture_state gesture{};
|
||||
std::optional<std::int32_t> active_touch{};
|
||||
std::uint64_t timer_generation{};
|
||||
std::uint64_t input_generation{};
|
||||
std::bool_t stopped{};
|
||||
};
|
||||
|
||||
@@ -108,6 +109,15 @@ auto vamp_zero::touch_input::handle(luma::touch_event const &event) -> std::bool
|
||||
auto vamp_zero::touch_input::stop() -> void {
|
||||
auto lock = std::scoped_lock{state_->mutex};
|
||||
state_->stopped = true;
|
||||
++state_->input_generation;
|
||||
state_->active_touch.reset();
|
||||
state_->gesture.reset();
|
||||
state_->schedule();
|
||||
}
|
||||
|
||||
auto vamp_zero::touch_input::reset() -> void {
|
||||
auto lock = std::scoped_lock{state_->mutex};
|
||||
++state_->input_generation;
|
||||
state_->active_touch.reset();
|
||||
state_->gesture.reset();
|
||||
state_->schedule();
|
||||
|
||||
Reference in New Issue
Block a user