| Index: components/exo/wayland/clients/motion_events.cc
|
| diff --git a/components/exo/wayland/clients/motion_events.cc b/components/exo/wayland/clients/motion_events.cc
|
| index a55b6cd1971a61cceac43768127d2926203620a6..99e38eba2b79c3ddac9e12daf2ca9fc85fdb2ec3 100644
|
| --- a/components/exo/wayland/clients/motion_events.cc
|
| +++ b/components/exo/wayland/clients/motion_events.cc
|
| @@ -34,6 +34,7 @@ DEFAULT_DELETER(wl_shell_surface, wl_shell_surface_destroy)
|
| DEFAULT_DELETER(wl_seat, wl_seat_destroy)
|
| DEFAULT_DELETER(wl_pointer, wl_pointer_destroy)
|
| DEFAULT_DELETER(wl_touch, wl_touch_destroy)
|
| +DEFAULT_DELETER(wl_callback, wl_callback_destroy)
|
|
|
| namespace exo {
|
| namespace wayland {
|
| @@ -105,6 +106,7 @@ struct MainLoopContext {
|
| uint32_t color = 0xffffffff;
|
| bool needs_redraw = true;
|
| bool shutdown = false;
|
| + bool throttled = false;
|
| };
|
|
|
| void PointerEnter(void* data,
|
| @@ -195,6 +197,12 @@ void TouchFrame(void* data, wl_touch* touch) {}
|
|
|
| void TouchCancel(void* data, wl_touch* touch) {}
|
|
|
| +void FrameCallback(void* data, wl_callback* callback, uint32_t time) {
|
| + MainLoopContext* context = static_cast<MainLoopContext*>(data);
|
| +
|
| + context->throttled = false;
|
| +}
|
| +
|
| } // namespace
|
|
|
| int MotionEventsMain() {
|
| @@ -305,6 +313,9 @@ int MotionEventsMain() {
|
| TouchFrame, TouchCancel};
|
| wl_touch_add_listener(touch.get(), &touch_listener, &context);
|
|
|
| + std::unique_ptr<wl_callback> frame_callback;
|
| + wl_callback_listener frame_listener = {FrameCallback};
|
| +
|
| do {
|
| if (context.shutdown)
|
| break;
|
| @@ -312,6 +323,9 @@ int MotionEventsMain() {
|
| if (!context.needs_redraw)
|
| continue;
|
|
|
| + if (context.throttled)
|
| + continue;
|
| +
|
| BufferState* buffer =
|
| std::find_if(std::begin(buffers), std::end(buffers),
|
| [](const BufferState& buffer) { return !buffer.busy; });
|
| @@ -331,6 +345,10 @@ int MotionEventsMain() {
|
| wl_surface_attach(surface.get(), buffer->buffer.get(), 0, 0);
|
| buffer->busy = true;
|
|
|
| + frame_callback.reset(wl_surface_frame(surface.get()));
|
| + wl_callback_add_listener(frame_callback.get(), &frame_listener, &context);
|
| + context.throttled = true;
|
| +
|
| wl_surface_commit(surface.get());
|
| wl_display_flush(display.get());
|
| } while (wl_display_dispatch(display.get()) != -1);
|
|
|