Commit 885fe5dc authored by sadrul@chromium.org's avatar sadrul@chromium.org

ozone: Remove the explicit call to start listening for events.

It is not necessary for WindowTreeHostOzone to call into the event-factory
to explicitly request it to start receiving events. The evdev implementation
can start listening to the events immediately, and the canca implementation
can start listening for events when the dispatcher list changes (this is the
same we do for the libevent based x11 event-source).

BUG=361137
R=spang@chromium.org

Review URL: https://codereview.chromium.org/285303004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271036 0039d316-1c4b-4281-b951-d872f2087c98
parent 60c86b06
......@@ -15,11 +15,6 @@ namespace aura {
WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds)
: widget_(0),
bounds_(bounds) {
// EventFactoryOzone creates converters that obtain input events from the
// underlying input system and dispatch them as |ui::Event| instances into
// Aura.
ui::EventFactoryOzone::GetInstance()->StartProcessingEvents();
gfx::SurfaceFactoryOzone* surface_factory =
gfx::SurfaceFactoryOzone::GetInstance();
widget_ = surface_factory->GetAcceleratedWidget();
......
......@@ -134,13 +134,13 @@ EventFactoryEvdev::EventFactoryEvdev(
CursorDelegateEvdev* cursor,
DeviceManager* device_manager)
: device_manager_(device_manager),
has_started_processing_events_(false),
ui_task_runner_(base::MessageLoopProxy::current()),
cursor_(cursor),
dispatch_callback_(
base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent),
base::Unretained(this))),
weak_ptr_factory_(this) {}
weak_ptr_factory_(this) {
CHECK(device_manager_);
}
EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); }
......@@ -197,10 +197,12 @@ void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) {
}
void EventFactoryEvdev::OnDispatcherListChanged() {
if (ui_task_runner_)
return;
ui_task_runner_ = base::MessageLoopProxy::current();
StartProcessingEvents();
if (!ui_task_runner_) {
ui_task_runner_ = base::MessageLoopProxy::current();
// Scan & monitor devices.
device_manager_->AddObserver(this);
device_manager_->ScanDevices(this);
}
}
void EventFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
......@@ -224,19 +226,6 @@ void EventFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
}
}
void EventFactoryEvdev::StartProcessingEvents() {
if (!ui_task_runner_)
return;
CHECK(ui_task_runner_->RunsTasksOnCurrentThread());
if (device_manager_ && !has_started_processing_events_) {
has_started_processing_events_ = true;
// Scan & monitor devices.
device_manager_->AddObserver(this);
device_manager_->ScanDevices(this);
}
}
void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
if (cursor_) {
......
......@@ -34,7 +34,6 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public EventFactoryOzone,
void DispatchUiEvent(Event* event);
// EventFactoryOzone:
virtual void StartProcessingEvents() OVERRIDE;
virtual void WarpCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) OVERRIDE;
......@@ -60,14 +59,6 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public EventFactoryOzone,
// Interface for scanning & monitoring input devices.
DeviceManager* device_manager_; // Not owned.
// True if this was registered with |device_manager_|. This is needed since
// StartProcessingEvents() is called multiple times (when a
// WindowTreeHostOzone is created) but we shouldn't register this multiple
// times.
// TODO(dnicoara) Remove once event processing is refactored and we no longer
// rely on WTH for starting event processing.
bool has_started_processing_events_;
// Task runner for event dispatch.
scoped_refptr<base::TaskRunner> ui_task_runner_;
......
......@@ -26,8 +26,6 @@ EventFactoryOzone* EventFactoryOzone::GetInstance() {
return impl_;
}
void EventFactoryOzone::StartProcessingEvents() {}
void EventFactoryOzone::WarpCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
NOTIMPLEMENTED();
......
......@@ -30,14 +30,6 @@ class EVENTS_OZONE_EXPORT EventFactoryOzone {
EventFactoryOzone();
virtual ~EventFactoryOzone();
// Called from WindowTreeHostOzone to initialize and start processing events.
// This should create the initial set of converters, and potentially arrange
// for more converters to be created as new event sources become available.
// No events processing should happen until this is called. All processes have
// an EventFactoryOzone but not all of them should process events. In chrome,
// events are dispatched in the browser process on the UI thread.
virtual void StartProcessingEvents();
// Request to warp the cursor to a location within an AccelerateWidget.
// If the cursor actually moves, the implementation must dispatch a mouse
// move event with the new location.
......
......@@ -146,15 +146,15 @@ CacaEventFactory::CacaEventFactory(CacaConnection* connection)
CacaEventFactory::~CacaEventFactory() {
}
void CacaEventFactory::StartProcessingEvents() {
ScheduleEventProcessing();
}
void CacaEventFactory::WarpCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) {
NOTIMPLEMENTED();
}
void CacaEventFactory::OnDispatcherListChanged() {
ScheduleEventProcessing();
}
void CacaEventFactory::ScheduleEventProcessing() {
// Caca uses a poll based event retrieval. Since we don't want to block we'd
// either need to spin up a new thread or just poll. For simplicity just poll
......
......@@ -15,17 +15,20 @@ namespace ui {
class CacaConnection;
class CacaEventFactory : public EventFactoryOzone, PlatformEventSource {
class CacaEventFactory : public EventFactoryOzone,
public PlatformEventSource {
public:
CacaEventFactory(CacaConnection* connection);
virtual ~CacaEventFactory();
// ui::EventFactoryOzone overrides:
virtual void StartProcessingEvents() OVERRIDE;
// ui::EventFactoryOzone:
virtual void WarpCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) OVERRIDE;
private:
// PlatformEventSource:
virtual void OnDispatcherListChanged() OVERRIDE;
void ScheduleEventProcessing();
void TryProcessingEvent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment