Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: ui/views/mus/platform_window_mus.cc

Issue 1979573002: Move mus::InputEventHandler implementation and tests from PlatformWindowMus to NativeWidgetMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@native_widget_mus5
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/mus/platform_window_mus.cc
diff --git a/ui/views/mus/platform_window_mus.cc b/ui/views/mus/platform_window_mus.cc
index 99fa1709e15c27778b7590380753f89b4aeb8c8a..72cb892d1a9f9c77cf500c6332058bad6307da41 100644
--- a/ui/views/mus/platform_window_mus.cc
+++ b/ui/views/mus/platform_window_mus.cc
@@ -23,44 +23,6 @@ namespace {
static uint32_t accelerated_widget_count = 1;
-// Handles acknowledgement of an input event, either immediately when a nested
-// message loop starts, or upon destruction.
-class EventAckHandler : public base::MessageLoop::NestingObserver {
- public:
- explicit EventAckHandler(
- std::unique_ptr<base::Callback<void(EventResult)>> ack_callback)
- : ack_callback_(std::move(ack_callback)) {
- DCHECK(ack_callback_);
- base::MessageLoop::current()->AddNestingObserver(this);
- }
-
- ~EventAckHandler() override {
- base::MessageLoop::current()->RemoveNestingObserver(this);
- if (ack_callback_) {
- ack_callback_->Run(handled_ ? EventResult::HANDLED
- : EventResult::UNHANDLED);
- }
- }
-
- void set_handled(bool handled) { handled_ = handled; }
-
- // base::MessageLoop::NestingObserver:
- void OnBeginNestedMessageLoop() override {
- // Acknowledge the event immediately if a nested message loop starts.
- // Otherwise we appear unresponsive for the life of the nested message loop.
- if (ack_callback_) {
- ack_callback_->Run(EventResult::HANDLED);
- ack_callback_.reset();
- }
- }
-
- private:
- std::unique_ptr<base::Callback<void(EventResult)>> ack_callback_;
- bool handled_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(EventAckHandler);
-};
-
} // namespace
PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
@@ -71,7 +33,6 @@ PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
mus_window_destroyed_(false) {
DCHECK(delegate_);
DCHECK(mus_window_);
- 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
@@ -93,11 +54,7 @@ PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
bitmap_uploader_.get()));
}
-PlatformWindowMus::~PlatformWindowMus() {
- if (!mus_window_)
- return;
- mus_window_->set_input_event_handler(nullptr);
-}
+PlatformWindowMus::~PlatformWindowMus() {}
void PlatformWindowMus::Show() {}
@@ -151,19 +108,4 @@ ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() {
return nullptr;
}
-void PlatformWindowMus::OnWindowInputEvent(
- mus::Window* view,
- const ui::Event& event_in,
- std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
- // Take ownership of the callback, indicating that we will handle it.
- EventAckHandler ack_handler(std::move(*ack_callback));
-
- std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in);
- delegate_->DispatchEvent(event.get());
- // NOTE: |this| may be deleted.
-
- ack_handler.set_handled(event->handled());
- // |ack_handler| acks the event on destruction if necessary.
-}
-
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698