diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 02:34:06 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-05 02:34:06 +0000 |
commit | 9e599a93b7f032350fb16d4eed59c0ebc3b15db2 (patch) | |
tree | 9ca5511758c5034be4b402af9e1d55d9ecb64cf7 | |
parent | f1ccdf3d94a2aaa22c2b4d4371b9539a7324ee68 (diff) | |
download | chromium_src-9e599a93b7f032350fb16d4eed59c0ebc3b15db2.zip chromium_src-9e599a93b7f032350fb16d4eed59c0ebc3b15db2.tar.gz chromium_src-9e599a93b7f032350fb16d4eed59c0ebc3b15db2.tar.bz2 |
ozone: Use PlatformEventSource for dispatching events.
Notable changes:
* Convert EventFactoryOzone into a PlatformEventSource.
* Convert WindowTreeHostOzone into a PlatformEventDispatcher.
* The WindowTreeHostOzone looks at the location of the event for mouse, scroll
and touch-events to decide whether it should dispatch the event or not. It
expects the event-location it receives to be in the same coordinate space as
its bounds.
* Adds an ObserverList in MessagePumpOzone, and the EventFactoryOzone reaches
into the message-pump to trigger these observers. This is a short-term
workaround (the same is done for X11 in http://crrev.com/219743002/), until
the message-pump observers are converted into PlatformEventObservers.
* Have EventConverterEvdev take in a callback that can be used for dispatching
events it receives. The EventFactoryEvdev sets this callback to each of these
converters after creation.
* Change the asynchronous event-dispatch to be synchronous.
This set of changes allows dispatching events to multiple window-tree hosts (at
least in theory).
BUG=319986
R=rjkroege@chromium.org, spang@chromium.org
Review URL: https://codereview.chromium.org/223363003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261953 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/aura/window_event_dispatcher_unittest.cc | 17 | ||||
-rw-r--r-- | ui/aura/window_tree_host_ozone.cc | 17 | ||||
-rw-r--r-- | ui/aura/window_tree_host_ozone.h | 11 | ||||
-rw-r--r-- | ui/events/ozone/evdev/event_converter_evdev.cc | 4 | ||||
-rw-r--r-- | ui/events/ozone/evdev/event_converter_evdev.h | 14 | ||||
-rw-r--r-- | ui/events/ozone/evdev/event_factory_evdev.cc | 15 | ||||
-rw-r--r-- | ui/events/ozone/evdev/key_event_converter_evdev.cc | 6 | ||||
-rw-r--r-- | ui/events/ozone/evdev/key_event_converter_evdev_unittest.cc | 6 | ||||
-rw-r--r-- | ui/events/ozone/evdev/touch_event_converter_evdev.cc | 9 | ||||
-rw-r--r-- | ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc | 23 | ||||
-rw-r--r-- | ui/events/ozone/event_factory_ozone.cc | 15 | ||||
-rw-r--r-- | ui/events/ozone/event_factory_ozone.h | 8 | ||||
-rw-r--r-- | ui/ozone/platform/caca/caca_event_factory.cc | 28 |
13 files changed, 79 insertions, 94 deletions
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc index 3ac9857..d0985b4 100644 --- a/ui/aura/window_event_dispatcher_unittest.cc +++ b/ui/aura/window_event_dispatcher_unittest.cc @@ -36,15 +36,6 @@ namespace aura { namespace { -bool PlatformSupportsMultipleHosts() { -#if defined(USE_OZONE) - // Creating multiple WindowTreeHostOzone instances is broken. - return false; -#else - return true; -#endif -} - // A delegate that always returns a non-client component for hit tests. class NonClientDelegate : public test::TestWindowDelegate { public: @@ -1363,8 +1354,6 @@ class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver { // Verifies GetRootWindow() from ~Window returns a valid root. TEST_F(WindowEventDispatcherTest, ValidRootDuringDestruction) { - if (!PlatformSupportsMultipleHosts()) - return; bool got_destroying = false; bool has_valid_root = false; ValidRootDuringDestructionWindowObserver observer(&got_destroying, @@ -1478,8 +1467,6 @@ class DeleteHostFromHeldMouseEventDelegate // Verifies if a WindowTreeHost is deleted from dispatching a held mouse event // we don't crash. TEST_F(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { - if (!PlatformSupportsMultipleHosts()) - return; // Should be deleted by |delegate|. WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); h2->InitHost(); @@ -1948,8 +1935,6 @@ class MoveWindowHandler : public ui::EventHandler { // event being dispatched is moved to a different dispatcher in response to an // event in the inner loop. TEST_F(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { - if (!PlatformSupportsMultipleHosts()) - return; scoped_ptr<WindowTreeHost> second_host( WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); second_host->InitHost(); @@ -2006,8 +1991,6 @@ class AlwaysMouseDownInputStateLookup : public InputStateLookup { TEST_F(WindowEventDispatcherTest, CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { - if (!PlatformSupportsMultipleHosts()) - return; test::EventCountDelegate delegate; scoped_ptr<Window> window(CreateTestWindowWithDelegate(&delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); diff --git a/ui/aura/window_tree_host_ozone.cc b/ui/aura/window_tree_host_ozone.cc index 013fae8..0a01e42 100644 --- a/ui/aura/window_tree_host_ozone.cc +++ b/ui/aura/window_tree_host_ozone.cc @@ -7,6 +7,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/base/cursor/ozone/cursor_factory_ozone.h" #include "ui/events/ozone/event_factory_ozone.h" +#include "ui/events/platform/platform_event_source.h" #include "ui/gfx/ozone/surface_factory_ozone.h" #include "ui/ozone/ozone_platform.h" @@ -26,20 +27,28 @@ WindowTreeHostOzone::WindowTreeHostOzone(const gfx::Rect& bounds) gfx::SurfaceFactoryOzone::GetInstance(); widget_ = surface_factory->GetAcceleratedWidget(); - base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(this); + ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); CreateCompositor(GetAcceleratedWidget()); } WindowTreeHostOzone::~WindowTreeHostOzone() { - base::MessagePumpOzone::Current()->RemoveDispatcherForRootWindow(0); + ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); DestroyCompositor(); DestroyDispatcher(); } -uint32_t WindowTreeHostOzone::Dispatch(const base::NativeEvent& ne) { +bool WindowTreeHostOzone::CanDispatchEvent(const ui::PlatformEvent& ne) { + CHECK(ne); + ui::Event* event = static_cast<ui::Event*>(ne); + if (event->IsMouseEvent() || event->IsScrollEvent() || event->IsTouchEvent()) + return bounds_.Contains(static_cast<ui::LocatedEvent*>(event)->location()); + return true; +} + +uint32_t WindowTreeHostOzone::DispatchEvent(const ui::PlatformEvent& ne) { ui::Event* event = static_cast<ui::Event*>(ne); ui::EventDispatchDetails details ALLOW_UNUSED = SendEventToProcessor(event); - return POST_DISPATCH_NONE; + return ui::POST_DISPATCH_STOP_PROPAGATION; } gfx::AcceleratedWidget WindowTreeHostOzone::GetAcceleratedWidget() { diff --git a/ui/aura/window_tree_host_ozone.h b/ui/aura/window_tree_host_ozone.h index dadae63c..0e1f469 100644 --- a/ui/aura/window_tree_host_ozone.h +++ b/ui/aura/window_tree_host_ozone.h @@ -8,9 +8,9 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_pump_dispatcher.h" #include "ui/aura/window_tree_host.h" #include "ui/events/event_source.h" +#include "ui/events/platform/platform_event_dispatcher.h" #include "ui/gfx/insets.h" #include "ui/gfx/rect.h" @@ -18,16 +18,17 @@ namespace aura { class WindowTreeHostOzone : public WindowTreeHost, public ui::EventSource, - public base::MessagePumpDispatcher { + public ui::PlatformEventDispatcher { public: explicit WindowTreeHostOzone(const gfx::Rect& bounds); virtual ~WindowTreeHostOzone(); private: - // Overridden from Dispatcher overrides: - virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; + // ui::PlatformEventDispatcher: + virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; + virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; - // WindowTreeHost Overrides. + // WindowTreeHost: virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; diff --git a/ui/events/ozone/evdev/event_converter_evdev.cc b/ui/events/ozone/evdev/event_converter_evdev.cc index 6c88b62..d3d9aed 100644 --- a/ui/events/ozone/evdev/event_converter_evdev.cc +++ b/ui/events/ozone/evdev/event_converter_evdev.cc @@ -13,8 +13,8 @@ EventConverterEvdev::EventConverterEvdev() {} EventConverterEvdev::~EventConverterEvdev() {} -void EventConverterEvdev::DispatchEvent(scoped_ptr<ui::Event> event) { - EventFactoryOzone::DispatchEvent(event.Pass()); +void EventConverterEvdev::DispatchEventToCallback(ui::Event* event) { + dispatch_callback_.Run(event); } } // namespace ui diff --git a/ui/events/ozone/evdev/event_converter_evdev.h b/ui/events/ozone/evdev/event_converter_evdev.h index 7618e6a..5dd9988 100644 --- a/ui/events/ozone/evdev/event_converter_evdev.h +++ b/ui/events/ozone/evdev/event_converter_evdev.h @@ -6,6 +6,7 @@ #define UI_EVENTS_OZONE_EVDEV_EVENT_CONVERTER_EVDEV_H_ #include "base/basictypes.h" +#include "base/bind.h" #include "base/memory/scoped_ptr.h" #include "ui/events/events_export.h" @@ -20,6 +21,10 @@ class EVENTS_EXPORT EventConverterEvdev { EventConverterEvdev(); virtual ~EventConverterEvdev(); + void SetDispatchCallback(base::Callback<void(void*)> callback) { + dispatch_callback_ = callback; + } + // Start converting events. virtual void Start() = 0; @@ -27,12 +32,13 @@ class EVENTS_EXPORT EventConverterEvdev { virtual void Stop() = 0; protected: - // 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. - virtual void DispatchEvent(scoped_ptr<ui::Event> event); + // Dispatches an event using the dispatch-callback set using + // |SetDispatchCalback()|. + virtual void DispatchEventToCallback(ui::Event* event); private: + base::Callback<void(void*)> dispatch_callback_; + DISALLOW_COPY_AND_ASSIGN(EventConverterEvdev); }; diff --git a/ui/events/ozone/evdev/event_factory_evdev.cc b/ui/events/ozone/evdev/event_factory_evdev.cc index cf9a607..78d34b8 100644 --- a/ui/events/ozone/evdev/event_factory_evdev.cc +++ b/ui/events/ozone/evdev/event_factory_evdev.cc @@ -134,6 +134,9 @@ void EventFactoryEvdev::AttachInputDevice( // Add initialized device to map. converters_[path] = converter.release(); + converters_[path]->SetDispatchCallback( + base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchEvent), + base::Unretained(this))); converters_[path]->Start(); } @@ -204,12 +207,12 @@ void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, const gfx::PointF& location) { if (cursor_) { cursor_->MoveCursorTo(widget, location); - scoped_ptr<Event> ev(new MouseEvent(ET_MOUSE_MOVED, - cursor_->location(), - cursor_->location(), - modifiers_.GetModifierFlags(), - /* changed_button_flags */ 0)); - DispatchEvent(ev.Pass()); + MouseEvent mouse_event(ET_MOUSE_MOVED, + cursor_->location(), + cursor_->location(), + modifiers_.GetModifierFlags(), + /* changed_button_flags */ 0); + DispatchEvent(&mouse_event); } } diff --git a/ui/events/ozone/evdev/key_event_converter_evdev.cc b/ui/events/ozone/evdev/key_event_converter_evdev.cc index 6e59b17..a982c60 100644 --- a/ui/events/ozone/evdev/key_event_converter_evdev.cc +++ b/ui/events/ozone/evdev/key_event_converter_evdev.cc @@ -258,9 +258,9 @@ void KeyEventConverterEvdev::ConvertKeyEvent(int key, int value) { int flags = modifiers_->GetModifierFlags(); - scoped_ptr<KeyEvent> key_event( - new KeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true)); - DispatchEvent(key_event.PassAs<ui::Event>()); + KeyEvent key_event( + down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, true); + DispatchEventToCallback(&key_event); } } // namespace ui diff --git a/ui/events/ozone/evdev/key_event_converter_evdev_unittest.cc b/ui/events/ozone/evdev/key_event_converter_evdev_unittest.cc index e2aa58e..52cc62e 100644 --- a/ui/events/ozone/evdev/key_event_converter_evdev_unittest.cc +++ b/ui/events/ozone/evdev/key_event_converter_evdev_unittest.cc @@ -30,7 +30,7 @@ class MockKeyEventConverterEvdev : public KeyEventConverterEvdev { return dispatched_events_[index]; } - virtual void DispatchEvent(scoped_ptr<Event> event) OVERRIDE; + virtual void DispatchEventToCallback(Event* event) OVERRIDE; private: ScopedVector<KeyEvent> dispatched_events_; @@ -38,8 +38,8 @@ class MockKeyEventConverterEvdev : public KeyEventConverterEvdev { DISALLOW_COPY_AND_ASSIGN(MockKeyEventConverterEvdev); }; -void MockKeyEventConverterEvdev::DispatchEvent(scoped_ptr<Event> event) { - dispatched_events_.push_back(static_cast<KeyEvent*>(event.release())); +void MockKeyEventConverterEvdev::DispatchEventToCallback(Event* event) { + dispatched_events_.push_back(new KeyEvent(*static_cast<KeyEvent*>(event))); } } // namespace ui diff --git a/ui/events/ozone/evdev/touch_event_converter_evdev.cc b/ui/events/ozone/evdev/touch_event_converter_evdev.cc index cb78cbe..1944714 100644 --- a/ui/events/ozone/evdev/touch_event_converter_evdev.cc +++ b/ui/events/ozone/evdev/touch_event_converter_evdev.cc @@ -17,6 +17,7 @@ #include "base/bind.h" #include "base/callback.h" #include "base/logging.h" +#include "base/memory/scoped_vector.h" #include "base/message_loop/message_pump_ozone.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" @@ -93,6 +94,7 @@ void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { return; } + ScopedVector<ui::TouchEvent> touch_events; for (unsigned i = 0; i < read_size / sizeof(*inputs); i++) { const input_event& input = inputs[i]; if (input.type == EV_ABS) { @@ -139,7 +141,7 @@ void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { for (int j = 0; j < MAX_FINGERS; j++) { if (altered_slots_[j]) { // TODO(rjkroege): Support elliptical finger regions. - scoped_ptr<TouchEvent> tev(new TouchEvent( + touch_events.push_back(new TouchEvent( events_[j].type_, gfx::Point(std::min(x_max_, events_[j].x_), std::min(y_max_, events_[j].y_)), @@ -151,7 +153,6 @@ void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { events_[j].pressure_ * kFingerWidth, /* angle */ 0., events_[j].pressure_)); - DispatchEvent(tev.PassAs<ui::Event>()); // Subsequent events for this finger will be touch-move until it // is released. @@ -177,6 +178,10 @@ void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { NOTIMPLEMENTED() << "invalid type: " << input.type; } } + for (ScopedVector<ui::TouchEvent>::iterator iter = touch_events.begin(); + iter != touch_events.end(); ++iter) { + DispatchEventToCallback(*iter); + } } } // namespace ui diff --git a/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc b/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc index 5fb8886..472e79e 100644 --- a/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc +++ b/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc @@ -11,13 +11,14 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" -#include "base/message_loop/message_pump_dispatcher.h" #include "base/posix/eintr_wrapper.h" #include "base/run_loop.h" #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/events/event.h" #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" +#include "ui/events/platform/platform_event_dispatcher.h" +#include "ui/events/platform/platform_event_source.h" namespace { @@ -34,8 +35,7 @@ const char kTestDevicePath[] = "/dev/input/test-device"; namespace ui { -class MockTouchEventConverterEvdev : public TouchEventConverterEvdev, - public base::MessagePumpDispatcher { +class MockTouchEventConverterEvdev : public TouchEventConverterEvdev { public: MockTouchEventConverterEvdev(int fd, base::FilePath path); virtual ~MockTouchEventConverterEvdev() {}; @@ -53,7 +53,10 @@ class MockTouchEventConverterEvdev : public TouchEventConverterEvdev, base::RunLoop().RunUntilIdle(); } - virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE; + void DispatchCallback(void* event) { + dispatched_events_.push_back( + new TouchEvent(*static_cast<TouchEvent*>(event))); + } private: int read_pipe_; @@ -89,13 +92,6 @@ MockTouchEventConverterEvdev::MockTouchEventConverterEvdev(int fd, write_pipe_ = fds[1]; } -uint32_t MockTouchEventConverterEvdev::Dispatch( - const base::NativeEvent& event) { - ui::TouchEvent* ev = new ui::TouchEvent(event); - dispatched_events_.push_back(ev); - return POST_DISPATCH_NONE; -} - void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event* queue, long read_this_many, long queue_index) { @@ -126,8 +122,11 @@ class TouchEventConverterEvdevTest : public testing::Test { loop_ = new base::MessageLoopForUI; device_ = new ui::MockTouchEventConverterEvdev( events_in_, base::FilePath(kTestDevicePath)); - base::MessagePumpOzone::Current()->AddDispatcherForRootWindow(device_); + device_->SetDispatchCallback( + base::Bind(&ui::MockTouchEventConverterEvdev::DispatchCallback, + base::Unretained(device_))); } + virtual void TearDown() OVERRIDE { delete device_; delete loop_; diff --git a/ui/events/ozone/event_factory_ozone.cc b/ui/events/ozone/event_factory_ozone.cc index 730975b..3afb2b8 100644 --- a/ui/events/ozone/event_factory_ozone.cc +++ b/ui/events/ozone/event_factory_ozone.cc @@ -13,15 +13,6 @@ 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; @@ -46,10 +37,4 @@ void EventFactoryOzone::WarpCursorTo(gfx::AcceleratedWidget widget, NOTIMPLEMENTED(); } -// static -void EventFactoryOzone::DispatchEvent(scoped_ptr<ui::Event> event) { - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&DispatchEventTask, base::Passed(&event))); -} - } // namespace ui diff --git a/ui/events/ozone/event_factory_ozone.h b/ui/events/ozone/event_factory_ozone.h index 49e92dd..9e0a6b9 100644 --- a/ui/events/ozone/event_factory_ozone.h +++ b/ui/events/ozone/event_factory_ozone.h @@ -11,6 +11,7 @@ #include "base/message_loop/message_pump_libevent.h" #include "base/task_runner.h" #include "ui/events/events_export.h" +#include "ui/events/platform/platform_event_source.h" #include "ui/gfx/native_widget_types.h" namespace gfx { @@ -26,7 +27,7 @@ class Event; // Ozone presumes that the set of file desctiprtors can vary at runtime so this // class supports dynamically adding and removing |EventConverterOzone| // instances as necessary. -class EVENTS_EXPORT EventFactoryOzone { +class EVENTS_EXPORT EventFactoryOzone : public ui::PlatformEventSource { public: EventFactoryOzone(); virtual ~EventFactoryOzone(); @@ -56,11 +57,6 @@ 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 diff --git a/ui/ozone/platform/caca/caca_event_factory.cc b/ui/ozone/platform/caca/caca_event_factory.cc index 279f80a7..dd8bfc2 100644 --- a/ui/ozone/platform/caca/caca_event_factory.cc +++ b/ui/ozone/platform/caca/caca_event_factory.cc @@ -177,19 +177,19 @@ void CacaEventFactory::TryProcessingEvent() { ui::EventType type = GetEventTypeFromNative(event); bool pressed = type == ui::ET_KEY_PRESSED || type == ui::ET_MOUSE_PRESSED; - scoped_ptr<ui::Event> ui_event; switch (type) { case ui::ET_KEY_PRESSED: - case ui::ET_KEY_RELEASED: - if (pressed) { + case ui::ET_KEY_RELEASED: { + if (pressed) modifier_flags_ |= ModifierFromKey(event); - } else { + else modifier_flags_ &= ~ModifierFromKey(event); - } - ui_event.reset(new ui::KeyEvent( - type, GetKeyboardCode(event), modifier_flags_, true)); + ui::KeyEvent key_event( + type, GetKeyboardCode(event), modifier_flags_, true); + DispatchEvent(&key_event); break; + } case ui::ET_MOUSE_MOVED: last_cursor_location_.SetPoint(caca_get_event_mouse_x(&event), caca_get_event_mouse_y(&event)); @@ -197,9 +197,9 @@ void CacaEventFactory::TryProcessingEvent() { caca_gotoxy(caca_get_canvas(connection_->display()), last_cursor_location_.x(), last_cursor_location_.y()); + // fallthrough case ui::ET_MOUSE_PRESSED: - case ui::ET_MOUSE_RELEASED: - { + case ui::ET_MOUSE_RELEASED: { int flags = 0; int changed_flags = 0; if (type != ui::ET_MOUSE_MOVED) { @@ -215,17 +215,15 @@ void CacaEventFactory::TryProcessingEvent() { } gfx::PointF location = TranslateLocation(last_cursor_location_, connection_); - ui_event.reset(new ui::MouseEvent( - type, location, location, flags, changed_flags)); - } + ui::MouseEvent mouse_event( + type, location, location, flags, changed_flags); + DispatchEvent(&mouse_event); break; + } default: NOTIMPLEMENTED(); break; } - - if (ui_event) - DispatchEvent(ui_event.Pass()); } ScheduleEventProcessing(); |