Commit e3440b10 authored by spang@chromium.org's avatar spang@chromium.org

Remove common EventConverterOzone class & move to EventConverterEvdev

There's no need for this interface in common code; the DispatchEvent
function can be moved onto EventFactoryOzone.

We're still relying on this class in the evdev implementation for

- unifying storage of TouchEventConverter & KeyEventConverter instances
- overriding event dispatching in the tests

Therefore, move it into evdev as EventConverterEvdev.

R=rjkroege
TEST=events_unittests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247997 0039d316-1c4b-4281-b951-d872f2087c98
parent 1c8ce46b
......@@ -112,6 +112,8 @@
'gestures/gesture_types.h',
'gestures/velocity_calculator.cc',
'gestures/velocity_calculator.h',
'ozone/evdev/event_converter.cc',
'ozone/evdev/event_converter.h',
'ozone/evdev/event_device_info.cc',
'ozone/evdev/event_device_info.h',
'ozone/evdev/event_factory.cc',
......@@ -122,8 +124,6 @@
'ozone/evdev/key_event_converter.h',
'ozone/evdev/touch_event_converter.cc',
'ozone/evdev/touch_event_converter.h',
'ozone/event_converter_ozone.cc',
'ozone/event_converter_ozone.h',
'ozone/event_factory_ozone.cc',
'ozone/event_factory_ozone.h',
'ozone/events_ozone.cc',
......
// Copyright 2014 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 "ui/events/ozone/evdev/event_converter.h"
#include "ui/events/event.h"
#include "ui/events/ozone/event_factory_ozone.h"
namespace ui {
EventConverterEvdev::EventConverterEvdev() {}
EventConverterEvdev::~EventConverterEvdev() {}
void EventConverterEvdev::DispatchEvent(scoped_ptr<ui::Event> event) {
EventFactoryOzone::DispatchEvent(event.Pass());
}
} // namespace ui
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Copyright 2014 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.
#ifndef UI_EVENTS_OZONE_EVENT_CONVERTER_OZONE_H_
#define UI_EVENTS_OZONE_EVENT_CONVERTER_OZONE_H_
#ifndef UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_H_
#define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/events/events_export.h"
namespace ui {
class Event;
// Ozone implementations can generate input events in whatever way is
// appropriate for the platform.
// This class provides the functionality needed in common across all
// converters: dispatching the |ui::Event| to aura.
class EVENTS_EXPORT EventConverterOzone {
// Base class for device-specific evdev event conversion.
class EventConverterEvdev {
public:
EventConverterOzone();
virtual ~EventConverterOzone();
EventConverterEvdev();
virtual ~EventConverterEvdev();
protected:
// Subclasses should use this method to post a task that will dispatch
......@@ -27,9 +25,9 @@ class EVENTS_EXPORT EventConverterOzone {
virtual void DispatchEvent(scoped_ptr<ui::Event> event);
private:
DISALLOW_COPY_AND_ASSIGN(EventConverterOzone);
DISALLOW_COPY_AND_ASSIGN(EventConverterEvdev);
};
} // namespace ui
#endif // UI_EVENTS_OZONE_EVENT_CONVERTER_OZONE_H_
#endif // UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_H_
......@@ -65,7 +65,7 @@ void EventFactoryEvdev::AttachInputDevice(const base::FilePath& path) {
}
// TODO(spang) Add more device types. Support hot-plugging.
scoped_ptr<EventConverterOzone> converter;
scoped_ptr<EventConverterEvdev> converter;
if (IsTouchScreen(devinfo))
converter.reset(new TouchEventConverterEvdev(fd, path));
else if (devinfo.HasEventType(EV_KEY))
......
......@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "ui/events/events_export.h"
#include "ui/events/ozone/evdev/event_converter.h"
#include "ui/events/ozone/evdev/event_modifiers.h"
#include "ui/events/ozone/event_factory_ozone.h"
......@@ -26,7 +27,7 @@ class EVENTS_EXPORT EventFactoryEvdev : public EventFactoryOzone {
void AttachInputDevice(const base::FilePath& file_path);
// Owned per-device event converters (by path).
std::map<base::FilePath, EventConverterOzone*> converters_;
std::map<base::FilePath, EventConverterEvdev*> converters_;
EventModifiersEvdev modifiers_;
......
......@@ -5,8 +5,8 @@
#ifndef UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_H_
#define UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_H_
#include "base/basictypes.h"
#include "ui/events/events_export.h"
#include "ui/events/ozone/event_converter_ozone.h"
namespace ui {
......
......@@ -11,6 +11,7 @@
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/ozone/evdev/event_modifiers.h"
#include "ui/events/ozone/event_factory_ozone.h"
namespace ui {
......
......@@ -9,15 +9,15 @@
#include "base/message_loop/message_pump_libevent.h"
#include "ui/events/event.h"
#include "ui/events/events_export.h"
#include "ui/events/ozone/evdev/event_converter.h"
#include "ui/events/ozone/evdev/event_modifiers.h"
#include "ui/events/ozone/event_converter_ozone.h"
struct input_event;
namespace ui {
class EVENTS_EXPORT KeyEventConverterEvdev
: public EventConverterOzone,
: public EventConverterEvdev,
base::MessagePumpLibevent::Watcher {
public:
KeyEventConverterEvdev(int fd,
......
......@@ -20,6 +20,7 @@
#include "base/message_loop/message_pump_ozone.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/ozone/event_factory_ozone.h"
#include "ui/gfx/ozone/surface_factory_ozone.h"
namespace {
......
......@@ -12,14 +12,14 @@
#include "base/message_loop/message_pump_libevent.h"
#include "ui/events/event_constants.h"
#include "ui/events/events_export.h"
#include "ui/events/ozone/event_converter_ozone.h"
#include "ui/events/ozone/evdev/event_converter.h"
namespace ui {
class TouchEvent;
class EVENTS_EXPORT TouchEventConverterEvdev
: public EventConverterOzone,
: public EventConverterEvdev,
base::MessagePumpLibevent::Watcher {
public:
enum {
......
// Copyright (c) 2013 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 "ui/events/ozone/event_converter_ozone.h"
#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_pump_ozone.h"
#include "ui/events/event.h"
namespace {
void DispatchEventHelper(scoped_ptr<ui::Event> key) {
TRACE_EVENT1("ozone", "DispatchEventHelper", "type", key->type());
base::MessagePumpOzone::Current()->Dispatch(key.get());
}
} // namespace
namespace ui {
EventConverterOzone::EventConverterOzone() {
}
EventConverterOzone::~EventConverterOzone() {
}
void EventConverterOzone::DispatchEvent(scoped_ptr<ui::Event> event) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&DispatchEventHelper, base::Passed(&event)));
}
} // namespace ui
......@@ -5,12 +5,23 @@
#include "ui/events/ozone/event_factory_ozone.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
#include "base/message_loop/message_pump_ozone.h"
#include "base/strings/stringprintf.h"
#include "ui/events/event.h"
#include "ui/events/event_switches.h"
namespace ui {
namespace {
void DispatchEventTask(scoped_ptr<ui::Event> key) {
TRACE_EVENT1("ozone", "DispatchEventTask", "type", key->type());
base::MessagePumpOzone::Current()->Dispatch(key.get());
}
} // namespace
// static
EventFactoryOzone* EventFactoryOzone::impl_ = NULL;
......@@ -27,4 +38,10 @@ void EventFactoryOzone::SetInstance(EventFactoryOzone* impl) { impl_ = impl; }
void EventFactoryOzone::StartProcessingEvents() {}
// static
void EventFactoryOzone::DispatchEvent(scoped_ptr<ui::Event> event) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&DispatchEventTask, base::Passed(&event)));
}
} // namespace ui
......@@ -10,10 +10,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_pump_libevent.h"
#include "ui/events/events_export.h"
#include "ui/events/ozone/event_converter_ozone.h"
namespace ui {
class Event;
// Creates and dispatches |ui.Event|'s. Ozone assumes that events arrive on file
// descriptors with one |EventConverterOzone| instance for each descriptor.
// Ozone presumes that the set of file desctiprtors can vary at runtime so this
......@@ -38,6 +39,11 @@ class EVENTS_EXPORT EventFactoryOzone {
// Sets the implementation delegate. Ownership is retained by the caller.
static void SetInstance(EventFactoryOzone*);
// Subclasses should use this method to post a task that will dispatch
// |event| from the UI message loop. This method takes ownership of
// |event|. |event| will be deleted at the end of the posted task.
static void DispatchEvent(scoped_ptr<ui::Event> event);
private:
static EventFactoryOzone* impl_; // not owned
......
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