diff options
-rw-r--r-- | components/html_viewer/html_frame.cc | 21 | ||||
-rw-r--r-- | components/html_viewer/html_frame.h | 11 | ||||
-rw-r--r-- | components/mus/public/cpp/BUILD.gn | 1 | ||||
-rw-r--r-- | components/mus/public/cpp/input_event_handler.h | 30 | ||||
-rw-r--r-- | components/mus/public/cpp/lib/window.cc | 1 | ||||
-rw-r--r-- | components/mus/public/cpp/lib/window_tree_client_impl.cc | 16 | ||||
-rw-r--r-- | components/mus/public/cpp/tests/BUILD.gn | 2 | ||||
-rw-r--r-- | components/mus/public/cpp/tests/test_window_tree.cc | 11 | ||||
-rw-r--r-- | components/mus/public/cpp/tests/test_window_tree.h | 5 | ||||
-rw-r--r-- | components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc | 75 | ||||
-rw-r--r-- | components/mus/public/cpp/window.h | 6 | ||||
-rw-r--r-- | components/mus/public/cpp/window_observer.h | 5 | ||||
-rw-r--r-- | components/pdf_viewer/pdf_viewer.cc | 19 | ||||
-rw-r--r-- | content/renderer/mus/compositor_mus_connection.cc | 14 | ||||
-rw-r--r-- | content/renderer/mus/compositor_mus_connection.h | 9 | ||||
-rw-r--r-- | ui/views/mus/platform_window_mus.cc | 16 | ||||
-rw-r--r-- | ui/views/mus/platform_window_mus.h | 11 |
17 files changed, 206 insertions, 47 deletions
diff --git a/components/html_viewer/html_frame.cc b/components/html_viewer/html_frame.cc index 1ddb997..50a183d 100644 --- a/components/html_viewer/html_frame.cc +++ b/components/html_viewer/html_frame.cc @@ -584,11 +584,15 @@ web_view::mojom::Frame* HTMLFrame::GetServerFrame() { } void HTMLFrame::SetWindow(mus::Window* window) { - if (window_) + if (window_) { + window_->set_input_event_handler(nullptr); window_->RemoveObserver(this); + } window_ = window; - if (window_) + if (window_) { window_->AddObserver(this); + window_->set_input_event_handler(this); + } } void HTMLFrame::CreateRootWebWidget() { @@ -757,8 +761,14 @@ void HTMLFrame::OnWindowDestroyed(mus::Window* window) { Close(); } +void HTMLFrame::OnWindowFocusChanged(mus::Window* gained_focus, + mus::Window* lost_focus) { + UpdateFocus(); +} + void HTMLFrame::OnWindowInputEvent(mus::Window* window, - const mus::mojom::EventPtr& event) { + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) { if (event->pointer_data && event->pointer_data->location) { // Blink expects coordintes to be in DIPs. event->pointer_data->location->x /= global_state()->device_pixel_ratio(); @@ -794,11 +804,6 @@ void HTMLFrame::OnWindowInputEvent(mus::Window* window, web_widget->handleInputEvent(*web_event); } -void HTMLFrame::OnWindowFocusChanged(mus::Window* gained_focus, - mus::Window* lost_focus) { - UpdateFocus(); -} - void HTMLFrame::OnConnect( web_view::mojom::FramePtr frame, uint32_t change_id, diff --git a/components/html_viewer/html_frame.h b/components/html_viewer/html_frame.h index 9f108ac..1439c6a2 100644 --- a/components/html_viewer/html_frame.h +++ b/components/html_viewer/html_frame.h @@ -13,6 +13,7 @@ #include "cc/layers/surface_layer.h" #include "components/html_viewer/html_frame_tree_manager.h" #include "components/html_viewer/replicated_frame_state.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/window_observer.h" #include "components/web_view/public/interfaces/frame.mojom.h" #include "mojo/public/cpp/bindings/binding.h" @@ -70,7 +71,8 @@ class WebLayerTreeViewImpl; class HTMLFrame : public blink::WebFrameClient, public blink::WebRemoteFrameClient, public web_view::mojom::FrameClient, - public mus::WindowObserver { + public mus::WindowObserver, + public mus::InputEventHandler { public: struct CreateParams { CreateParams( @@ -270,11 +272,14 @@ class HTMLFrame : public blink::WebFrameClient, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) override; void OnWindowDestroyed(mus::Window* window) override; - void OnWindowInputEvent(mus::Window* window, - const mus::mojom::EventPtr& event) override; void OnWindowFocusChanged(mus::Window* gained_focus, mus::Window* lost_focus) override; + // mus::InputEventHandler: + void OnWindowInputEvent(mus::Window* window, + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) override; + // web_view::mojom::FrameClient: void OnConnect(web_view::mojom::FramePtr server, uint32_t change_id, diff --git a/components/mus/public/cpp/BUILD.gn b/components/mus/public/cpp/BUILD.gn index 015040a..c172d32 100644 --- a/components/mus/public/cpp/BUILD.gn +++ b/components/mus/public/cpp/BUILD.gn @@ -6,6 +6,7 @@ source_set("cpp") { sources = [ "context_provider.h", "event_matcher.h", + "input_event_handler.h", "lib/context_provider.cc", "lib/event_matcher.cc", "lib/in_flight_change.cc", diff --git a/components/mus/public/cpp/input_event_handler.h b/components/mus/public/cpp/input_event_handler.h new file mode 100644 index 0000000..ebd1597 --- /dev/null +++ b/components/mus/public/cpp/input_event_handler.h @@ -0,0 +1,30 @@ +// Copyright 2015 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 COMPONENTS_MUS_PUBLIC_CPP_INPUT_EVENT_HANDLER_H_ +#define COMPONENTS_MUS_PUBLIC_CPP_INPUT_EVENT_HANDLER_H_ + +#include "base/callback_forward.h" +#include "components/mus/public/interfaces/input_events.mojom.h" + +namespace mus { + +class Window; + +// Responsible for processing input events for mus::Window. +class InputEventHandler { + public: + // The event handler can asynchronously ack the event by taking ownership of + // the |ack_callback|. If the handler does not take ownership of the callback, + // then WindowTreeClientImpl will ack the event. + virtual void OnWindowInputEvent(Window* target, + mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) = 0; + protected: + virtual ~InputEventHandler() {} +}; + +} // namespace mus + +#endif // COMPONENTS_MUS_PUBLIC_CPP_INPUT_EVENT_HANDLER_H_ diff --git a/components/mus/public/cpp/lib/window.cc b/components/mus/public/cpp/lib/window.cc index 084bac5..c09438c 100644 --- a/components/mus/public/cpp/lib/window.cc +++ b/components/mus/public/cpp/lib/window.cc @@ -408,6 +408,7 @@ Window::Window() parent_(nullptr), stacking_target_(nullptr), transient_parent_(nullptr), + input_event_handler_(nullptr), viewport_metrics_(CreateEmptyViewportMetrics()), visible_(true), drawn_(false) {} diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc index 570c9b5..4e0d946 100644 --- a/components/mus/public/cpp/lib/window_tree_client_impl.cc +++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "components/mus/common/util.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/lib/in_flight_change.h" #include "components/mus/public/cpp/lib/window_private.h" #include "components/mus/public/cpp/window_manager_delegate.h" @@ -640,11 +641,18 @@ void WindowTreeClientImpl::OnWindowInputEvent(uint32_t event_id, Id window_id, mojom::EventPtr event) { Window* window = GetWindowById(window_id); - if (window) { - FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(window).observers(), - OnWindowInputEvent(window, event)); + if (!window || !window->input_event_handler_) { + tree_->OnWindowInputEventAck(event_id); + return; } - tree_->OnWindowInputEventAck(event_id); + + scoped_ptr<base::Closure> ack_callback( + new base::Closure(base::Bind(&mojom::WindowTree::OnWindowInputEventAck, + base::Unretained(tree_), event_id))); + window->input_event_handler_->OnWindowInputEvent(window, std::move(event), + &ack_callback); + if (ack_callback) + ack_callback->Run(); } void WindowTreeClientImpl::OnWindowFocused(Id focused_window_id) { diff --git a/components/mus/public/cpp/tests/BUILD.gn b/components/mus/public/cpp/tests/BUILD.gn index b9cf72b..a8492a0 100644 --- a/components/mus/public/cpp/tests/BUILD.gn +++ b/components/mus/public/cpp/tests/BUILD.gn @@ -53,11 +53,13 @@ test("mojo_view_manager_lib_unittests") { "//components/mus/public/cpp", "//mojo/application/public/cpp", "//mojo/converters/geometry", + "//mojo/converters/input_events", "//mojo/gles2", "//mojo/platform_handle:platform_handle_impl", "//mojo/public/cpp/system", "//testing/gtest", "//third_party/mojo/src/mojo/edk/system", + "//ui/events", "//ui/gfx:test_support", "//ui/gfx/geometry", "//ui/mojo/geometry:interfaces", diff --git a/components/mus/public/cpp/tests/test_window_tree.cc b/components/mus/public/cpp/tests/test_window_tree.cc index 1d70f32..d1f7945 100644 --- a/components/mus/public/cpp/tests/test_window_tree.cc +++ b/components/mus/public/cpp/tests/test_window_tree.cc @@ -4,6 +4,8 @@ #include "components/mus/public/cpp/tests/test_window_tree.h" +#include "testing/gtest/include/gtest/gtest.h" + namespace mus { TestWindowTree::TestWindowTree() : got_change_(false), change_id_(0) {} @@ -20,6 +22,10 @@ bool TestWindowTree::GetAndClearChangeId(uint32_t* change_id) { return true; } +bool TestWindowTree::WasEventAcked(uint32_t event_id) const { + return acked_events_.count(event_id); +} + void TestWindowTree::NewWindow( uint32_t change_id, uint32_t window_id, @@ -106,7 +112,10 @@ void TestWindowTree::SetImeVisibility(uint32_t window_id, bool visible, mojo::TextInputStatePtr state) {} -void TestWindowTree::OnWindowInputEventAck(uint32_t event_id) {} +void TestWindowTree::OnWindowInputEventAck(uint32_t event_id) { + EXPECT_FALSE(acked_events_.count(event_id)); + acked_events_.insert(event_id); +} void TestWindowTree::WmResponse(uint32_t change_id, bool response) {} } // namespace mus diff --git a/components/mus/public/cpp/tests/test_window_tree.h b/components/mus/public/cpp/tests/test_window_tree.h index 8a35699..a61c8c9 100644 --- a/components/mus/public/cpp/tests/test_window_tree.h +++ b/components/mus/public/cpp/tests/test_window_tree.h @@ -5,6 +5,8 @@ #ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_ #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_H_ +#include <set> + #include "base/macros.h" #include "components/mus/public/interfaces/window_tree.mojom.h" @@ -21,6 +23,8 @@ class TestWindowTree : public mojom::WindowTree { // invoked since the last GetAndClearChangeId(). bool GetAndClearChangeId(uint32_t* change_id); + bool WasEventAcked(uint32_t event_id) const; + private: // mojom::WindowTree: void NewWindow( @@ -78,6 +82,7 @@ class TestWindowTree : public mojom::WindowTree { bool got_change_; uint32_t change_id_; + std::set<uint32_t> acked_events_; DISALLOW_COPY_AND_ASSIGN(TestWindowTree); }; diff --git a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc index 5c61a40..14542b8 100644 --- a/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc +++ b/components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "components/mus/common/util.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/lib/window_private.h" #include "components/mus/public/cpp/property_type_converters.h" #include "components/mus/public/cpp/tests/test_window.h" @@ -15,7 +16,10 @@ #include "components/mus/public/cpp/window_property.h" #include "components/mus/public/cpp/window_tree_delegate.h" #include "mojo/converters/geometry/geometry_type_converters.h" +#include "mojo/converters/input_events/input_events_type_converters.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/events/event.h" +#include "ui/events/event_utils.h" #include "ui/gfx/geometry/rect.h" namespace mus { @@ -96,6 +100,48 @@ class WindowTreeSetup { DISALLOW_COPY_AND_ASSIGN(WindowTreeSetup); }; +class TestInputEventHandler : public InputEventHandler { + public: + TestInputEventHandler() + : received_event_(false), should_manually_ack_(false) {} + ~TestInputEventHandler() override {} + + void set_should_manually_ack() { should_manually_ack_ = true; } + + void AckEvent() { + DCHECK(should_manually_ack_); + DCHECK(!ack_callback_.is_null()); + ack_callback_.Run(); + ack_callback_ = base::Closure(); + } + + void Reset() { + received_event_ = false; + ack_callback_ = base::Closure(); + } + bool received_event() const { return received_event_; } + + private: + // InputEventHandler: + void OnWindowInputEvent(Window* target, + mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) override { + EXPECT_FALSE(received_event_) + << "Observer was not reset after receiving event."; + received_event_ = true; + if (should_manually_ack_) { + ack_callback_ = *ack_callback->get(); + ack_callback->reset(); + } + } + + bool received_event_; + bool should_manually_ack_; + base::Closure ack_callback_; + + DISALLOW_COPY_AND_ASSIGN(TestInputEventHandler); +}; + using WindowTreeClientImplTest = testing::Test; // Verifies bounds are reverted if the server replied that the change failed. @@ -276,6 +322,35 @@ TEST_F(WindowTreeClientImplTest, SetVisibleFailedWithPendingChange) { EXPECT_EQ(original_visible, root->visible()); } +TEST_F(WindowTreeClientImplTest, InputEventBasic) { + WindowTreeSetup setup; + Window* root = setup.window_tree_connection()->GetRoot(); + ASSERT_TRUE(root); + + TestInputEventHandler event_handler; + root->set_input_event_handler(&event_handler); + + scoped_ptr<ui::Event> ui_event( + new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), + ui::EventTimeForNow(), ui::EF_NONE, 0)); + mojom::EventPtr mus_event = mojom::Event::From(*ui_event); + setup.window_tree_client()->OnWindowInputEvent(1, root->id(), + std::move(mus_event)); + EXPECT_TRUE(event_handler.received_event()); + EXPECT_TRUE(setup.window_tree()->WasEventAcked(1)); + event_handler.Reset(); + + event_handler.set_should_manually_ack(); + mus_event = mojom::Event::From(*ui_event); + setup.window_tree_client()->OnWindowInputEvent(33, root->id(), + std::move(mus_event)); + EXPECT_TRUE(event_handler.received_event()); + EXPECT_FALSE(setup.window_tree()->WasEventAcked(33)); + + event_handler.AckEvent(); + EXPECT_TRUE(setup.window_tree()->WasEventAcked(33)); +} + // Verifies focus is reverted if the server replied that the change failed. TEST_F(WindowTreeClientImplTest, SetFocusFailed) { WindowTreeSetup setup; diff --git a/components/mus/public/cpp/window.h b/components/mus/public/cpp/window.h index 8005cf4..6ed39dd 100644 --- a/components/mus/public/cpp/window.h +++ b/components/mus/public/cpp/window.h @@ -26,6 +26,7 @@ class Size; namespace mus { +class InputEventHandler; class ServiceProviderImpl; class WindowObserver; class WindowSurface; @@ -143,6 +144,10 @@ class Window { template <typename T> void ClearLocalProperty(const WindowProperty<T>* property); + void set_input_event_handler(InputEventHandler* input_event_handler) { + input_event_handler_ = input_event_handler; + } + // Observation. void AddObserver(WindowObserver* observer); void RemoveObserver(WindowObserver* observer); @@ -282,6 +287,7 @@ class Window { Children transient_children_; base::ObserverList<WindowObserver> observers_; + InputEventHandler* input_event_handler_; gfx::Rect bounds_; gfx::Insets client_area_; diff --git a/components/mus/public/cpp/window_observer.h b/components/mus/public/cpp/window_observer.h index b0b3597..52cc179 100644 --- a/components/mus/public/cpp/window_observer.h +++ b/components/mus/public/cpp/window_observer.h @@ -8,7 +8,6 @@ #include <vector> #include "components/mus/public/cpp/window.h" -#include "components/mus/public/interfaces/input_events.mojom.h" namespace mus { @@ -67,10 +66,6 @@ class WindowObserver { virtual void OnWindowPredefinedCursorChanged(Window* window, mojom::Cursor cursor) {} - - virtual void OnWindowInputEvent(Window* window, - const mojom::EventPtr& event) {} - virtual void OnWindowVisibilityChanging(Window* window) {} virtual void OnWindowVisibilityChanged(Window* window) {} diff --git a/components/pdf_viewer/pdf_viewer.cc b/components/pdf_viewer/pdf_viewer.cc index 5dc9097..870be0c 100644 --- a/components/pdf_viewer/pdf_viewer.cc +++ b/components/pdf_viewer/pdf_viewer.cc @@ -8,6 +8,7 @@ #include "base/memory/scoped_ptr.h" #include "components/bitmap_uploader/bitmap_uploader.h" #include "components/mus/common/types.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/scoped_window_ptr.h" #include "components/mus/public/cpp/window.h" #include "components/mus/public/cpp/window_observer.h" @@ -42,6 +43,7 @@ namespace { // Responsible for managing a particlar view displaying a PDF document. class PDFView : public mus::WindowTreeDelegate, public mus::WindowObserver, + public mus::InputEventHandler, public web_view::mojom::FrameClient, public mojo::InterfaceFactory<web_view::mojom::FrameClient> { public: @@ -105,6 +107,7 @@ class PDFView : public mus::WindowTreeDelegate, DCHECK(!root_); root_ = root; root_->AddObserver(this); + root_->set_input_event_handler(this); bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(root_)); bitmap_uploader_->Init(shell_); bitmap_uploader_->SetColor(g_background_color); @@ -123,8 +126,16 @@ class PDFView : public mus::WindowTreeDelegate, DrawBitmap(); } + void OnWindowDestroyed(mus::Window* view) override { + DCHECK_EQ(root_, view); + root_ = nullptr; + bitmap_uploader_.reset(); + } + + // mus::InputEventHandler: void OnWindowInputEvent(mus::Window* view, - const mus::mojom::EventPtr& event) override { + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) override { if (event->key_data && (event->action != mus::mojom::EVENT_TYPE_KEY_PRESSED || event->key_data->is_char)) { @@ -153,12 +164,6 @@ class PDFView : public mus::WindowTreeDelegate, } } - void OnWindowDestroyed(mus::Window* view) override { - DCHECK_EQ(root_, view); - root_ = nullptr; - bitmap_uploader_.reset(); - } - // web_view::mojom::FrameClient: void OnConnect(web_view::mojom::FramePtr frame, uint32_t change_id, diff --git a/content/renderer/mus/compositor_mus_connection.cc b/content/renderer/mus/compositor_mus_connection.cc index 9e0813e..e22e778 100644 --- a/content/renderer/mus/compositor_mus_connection.cc +++ b/content/renderer/mus/compositor_mus_connection.cc @@ -99,7 +99,7 @@ void CompositorMusConnection::OnConnectionLost( void CompositorMusConnection::OnEmbed(mus::Window* root) { DCHECK(compositor_task_runner_->BelongsToCurrentThread()); root_ = root; - root_->AddObserver(this); + root_->set_input_event_handler(this); if (window_surface_binding_) { root->AttachSurface(mus::mojom::SURFACE_TYPE_DEFAULT, std::move(window_surface_binding_)); @@ -108,7 +108,8 @@ void CompositorMusConnection::OnEmbed(mus::Window* root) { void CompositorMusConnection::OnWindowInputEvent( mus::Window* window, - const mus::mojom::EventPtr& event) { + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) { DCHECK(compositor_task_runner_->BelongsToCurrentThread()); scoped_ptr<blink::WebInputEvent> web_event = event.To<scoped_ptr<blink::WebInputEvent>>(); @@ -118,8 +119,7 @@ void CompositorMusConnection::OnWindowInputEvent( routing_id_, web_event.get(), &info); if (ack_state != INPUT_EVENT_ACK_STATE_NOT_CONSUMED) return; - // TODO(sad): Do something more useful once we can do async acks. - base::Closure ack = base::Bind(&base::DoNothing); + base::Closure ack; const bool send_ack = WebInputEventTraits::WillReceiveAckFromRenderer(*web_event); if (send_ack) { @@ -127,8 +127,10 @@ void CompositorMusConnection::OnWindowInputEvent( // thread-safe and lives on the compositor thread. For ACKs that are passed // to the main thread we pass them back to the compositor thread via // OnWindowInputEventAckOnMainThread. - ack = base::Bind( - &CompositorMusConnection::OnWindowInputEventAckOnMainThread, this, ack); + ack = + base::Bind(&CompositorMusConnection::OnWindowInputEventAckOnMainThread, + this, *ack_callback->get()); + ack_callback->reset(); } main_task_runner_->PostTask( FROM_HERE, diff --git a/content/renderer/mus/compositor_mus_connection.h b/content/renderer/mus/compositor_mus_connection.h index f7ee6be..7b0f696 100644 --- a/content/renderer/mus/compositor_mus_connection.h +++ b/content/renderer/mus/compositor_mus_connection.h @@ -7,8 +7,8 @@ #include "base/bind.h" #include "base/macros.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/window.h" -#include "components/mus/public/cpp/window_observer.h" #include "components/mus/public/cpp/window_tree_connection.h" #include "components/mus/public/cpp/window_tree_delegate.h" #include "third_party/WebKit/public/web/WebInputEvent.h" @@ -25,7 +25,7 @@ class InputHandlerManager; // explicited suffixed with OnMainThread. class CompositorMusConnection : public mus::WindowTreeDelegate, - public mus::WindowObserver, + public mus::InputEventHandler, public base::RefCountedThreadSafe<CompositorMusConnection> { public: // Created on main thread. @@ -64,9 +64,10 @@ class CompositorMusConnection void OnConnectionLost(mus::WindowTreeConnection* connection) override; void OnEmbed(mus::Window* root) override; - // WindowObserver implementation: + // InputEventHandler implementation: void OnWindowInputEvent(mus::Window* window, - const mus::mojom::EventPtr& event) override; + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) override; const int routing_id_; mus::Window* root_; diff --git a/ui/views/mus/platform_window_mus.cc b/ui/views/mus/platform_window_mus.cc index 5111b70..e8a5350 100644 --- a/ui/views/mus/platform_window_mus.cc +++ b/ui/views/mus/platform_window_mus.cc @@ -28,6 +28,7 @@ PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, DCHECK(delegate_); DCHECK(mus_window_); mus_window_->AddObserver(this); + mus_window_->set_input_event_handler(this); // We need accelerated widget numbers to be different for each // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t @@ -47,6 +48,7 @@ PlatformWindowMus::~PlatformWindowMus() { if (!mus_window_) return; mus_window_->RemoveObserver(this); + mus_window_->set_input_event_handler(nullptr); mus_window_->Destroy(); } @@ -166,12 +168,6 @@ void PlatformWindowMus::OnWindowPredefinedCursorChanged( last_cursor_ = cursor; } -void PlatformWindowMus::OnWindowInputEvent(mus::Window* view, - const mus::mojom::EventPtr& event) { - scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); - delegate_->DispatchEvent(ui_event.get()); -} - void PlatformWindowMus::OnWindowSharedPropertyChanged( mus::Window* window, const std::string& name, @@ -205,4 +201,12 @@ void PlatformWindowMus::OnWindowSharedPropertyChanged( delegate_->OnWindowStateChanged(state); } +void PlatformWindowMus::OnWindowInputEvent( + mus::Window* view, + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) { + scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); + delegate_->DispatchEvent(ui_event.get()); +} + } // namespace views diff --git a/ui/views/mus/platform_window_mus.h b/ui/views/mus/platform_window_mus.h index 69c6dd3..f3e2a1c 100644 --- a/ui/views/mus/platform_window_mus.h +++ b/ui/views/mus/platform_window_mus.h @@ -9,6 +9,7 @@ #include <vector> #include "base/macros.h" +#include "components/mus/public/cpp/input_event_handler.h" #include "components/mus/public/cpp/window_observer.h" #include "ui/platform_window/platform_window.h" #include "ui/views/mus/mus_export.h" @@ -17,7 +18,8 @@ namespace views { class VIEWS_MUS_EXPORT PlatformWindowMus : public NON_EXPORTED_BASE(ui::PlatformWindow), - public mus::WindowObserver { + public mus::WindowObserver, + public NON_EXPORTED_BASE(mus::InputEventHandler) { public: PlatformWindowMus(ui::PlatformWindowDelegate* delegate, mus::Window* mus_window); @@ -57,14 +59,17 @@ class VIEWS_MUS_EXPORT PlatformWindowMus mus::Window* lost_focus) override; void OnWindowPredefinedCursorChanged(mus::Window* window, mus::mojom::Cursor cursor) override; - void OnWindowInputEvent(mus::Window* view, - const mus::mojom::EventPtr& event) override; void OnWindowSharedPropertyChanged( mus::Window* window, const std::string& name, const std::vector<uint8_t>* old_data, const std::vector<uint8_t>* new_data) override; + // mus::InputEventHandler: + void OnWindowInputEvent(mus::Window* view, + mus::mojom::EventPtr event, + scoped_ptr<base::Closure>* ack_callback) override; + ui::PlatformWindowDelegate* delegate_; mus::Window* mus_window_; mus::mojom::ShowState show_state_; |