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

Unified Diff: ui/aura/mus/mus_mouse_location_updater.h

Issue 2657283003: mash: make Env::last_mouse_location() accurate for Mus (Closed)
Patch Set: cleanup Created 3 years, 11 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/aura/mus/mus_mouse_location_updater.h
diff --git a/ui/aura/mus/mus_mouse_location_updater.h b/ui/aura/mus/mus_mouse_location_updater.h
new file mode 100644
index 0000000000000000000000000000000000000000..b05772273d7e7dbd9e7b3b236a4b107829b7ce05
--- /dev/null
+++ b/ui/aura/mus/mus_mouse_location_updater.h
@@ -0,0 +1,48 @@
+// Copyright 2017 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_AURA_MUS_MUS_MOUSE_LOCATION_UPDATER_H_
+#define UI_AURA_MUS_MUS_MOUSE_LOCATION_UPDATER_H_
+
+#include "base/macros.h"
+#include "base/message_loop/message_loop.h"
+
+namespace ui {
+class Event;
+}
+
+namespace aura {
+
+// MusMouseLocationUpdater is responsible for updating
+// Env::last_mouse_location(), as well as determining when
+// Env::last_mouse_location() should use
+// WindowTreeClient::GetCursorScreenPoint(). While processing an event
+// Env uses the value from the current event, otherwise Env uses
+// WindowTreeClient::GetCursorScreenPoint(). If a nested message loop is
+// started while processing an event Env uses GetCursorScreenPoint().
+class MusMouseLocationUpdater : public base::MessageLoop::NestingObserver {
+ public:
+ MusMouseLocationUpdater();
+ ~MusMouseLocationUpdater() override;
+
+ // Called from WindowEventDispatcher on starting/stopping processing of
+ // events.
+ void OnEventProcessingStarted(const ui::Event& event);
+ void OnEventProcessingFinished();
+
+ private:
+ void StopObserving();
+
+ // base::MessageLoop::NestingObserver:
+ void OnBeginNestedMessageLoop() override;
+
+ // Set to true once a valid mouse event is encountered.
+ bool observing_message_loop_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(MusMouseLocationUpdater);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_MUS_MUS_MOUSE_LOCATION_UPDATER_H_

Powered by Google App Engine
This is Rietveld 408576698