blob: 98d367e40356dc08a9e0c88562d4f8e762ebd861 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/component_export.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
namespace aura {
class WindowTreeHost;
namespace ui {
class Event;
struct EventDispatchDetails;
namespace ws {
class EventQueue;
class HostEventDispatcher;
// HostEventQueue is associated with a single WindowTreeHost and used to queue
// events (if necessary), before the WindowTreeHost does processing.
// HostEventQueue is created by way of
// WindowService::RegisterHostEventDispatcher(). The expectation is
// WindowTreeHost calls to HostEventQueue::DispatchOrQueueEvent() on every
// event. When necessary, HostEventQueue calls back to HostEventDispatcher to
// handle the actual dispatch.
HostEventQueue(base::WeakPtr<EventQueue> event_queue,
aura::WindowTreeHost* window_tree_host,
HostEventDispatcher* host_event_dispatcher);
// If necessary, queues the event. If the event need not be queued,
// HostEventDispatcher::DispatchEventFromQueue() is called synchronously. If
// the event was not queued, the return value contains the result of the
// event processing.
base::Optional<ui::EventDispatchDetails> DispatchOrQueueEvent(
ui::Event* event,
bool honor_rewriters = true);
aura::WindowTreeHost* window_tree_host() { return window_tree_host_; }
HostEventDispatcher* host_event_dispatcher() {
return host_event_dispatcher_;
friend class EventQueue;
// Dispatches an event directly, circumventing any queuing. This is private as
// it's only useful internally.
ui::EventDispatchDetails DispatchEventDontQueue(ui::Event* event,
bool honor_rewriters);
// Because of shutdown ordering, HostEventQueue may be deleted *after*
// EventQueue.
base::WeakPtr<EventQueue> event_queue_;
aura::WindowTreeHost* window_tree_host_;
HostEventDispatcher* host_event_dispatcher_;
} // namespace ws