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

Unified Diff: ui/aura/window_event_dispatcher.cc

Issue 2025843003: Introduce aura::Env controller to abstract away changes to aura::Env Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new files to gyp build 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
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_event_dispatcher.cc
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc
index 8b2228096f0cfd241ac23db11598536bfde9c161..28a625240c78d674bbbae4ce01923300b3306806 100644
--- a/ui/aura/window_event_dispatcher.cc
+++ b/ui/aura/window_event_dispatcher.cc
@@ -17,6 +17,7 @@
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
+#include "ui/aura/env_input_state_controller.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_targeter.h"
@@ -48,19 +49,6 @@ Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
return consumer ? static_cast<Window*>(consumer) : NULL;
}
-void SetLastMouseLocation(const Window* root_window,
- const gfx::Point& location_in_root) {
- client::ScreenPositionClient* client =
- client::GetScreenPositionClient(root_window);
- if (client) {
- gfx::Point location_in_screen = location_in_root;
- client->ConvertPointToScreen(root_window, &location_in_screen);
- Env::GetInstance()->set_last_mouse_location(location_in_screen);
- } else {
- Env::GetInstance()->set_last_mouse_location(location_in_root);
- }
-}
-
bool IsEventCandidateForHold(const ui::Event& event) {
if (event.type() == ui::ET_TOUCH_MOVED)
return true;
@@ -88,6 +76,7 @@ WindowEventDispatcher::WindowEventDispatcher(WindowTreeHost* host)
dispatching_held_event_(nullptr),
observer_manager_(this),
transform_events_(true),
+ env_controller_(new EnvInputStateController),
repost_event_factory_(this),
held_event_factory_(this) {
ui::GestureRecognizer::Get()->AddGestureEventHelper(this);
@@ -204,12 +193,7 @@ void WindowEventDispatcher::ReleasePointerMoves() {
}
gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const {
- gfx::Point location = Env::GetInstance()->last_mouse_location();
- client::ScreenPositionClient* client =
- client::GetScreenPositionClient(window());
- if (client)
- client->ConvertPointFromScreen(window(), &location);
- return location;
+ return env_controller_->GetLastMouseLocationInRoot(window());
}
sadrul 2016/05/31 18:27:02 Let's keep this here, and remove that from env_con
void WindowEventDispatcher::OnHostLostMouseGrab() {
@@ -219,7 +203,7 @@ void WindowEventDispatcher::OnHostLostMouseGrab() {
void WindowEventDispatcher::OnCursorMovedToRootLocation(
const gfx::Point& root_location) {
- SetLastMouseLocation(window(), root_location);
+ env_controller_->SetLastMouseLocation(window(), root_location);
// Synthesize a mouse move in case the cursor's location in root coordinates
// changed but its position in WindowTreeHost coordinates did not.
@@ -268,7 +252,7 @@ ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit(
ui::EventType type) {
if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED &&
!(event.flags() & ui::EF_IS_SYNTHESIZED)) {
- SetLastMouseLocation(window(), event.root_location());
+ env_controller_->SetLastMouseLocation(window(), event.root_location());
}
if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate() ||
@@ -752,7 +736,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchLocatedEvent(
(event->IsMouseEvent() || event->IsScrollEvent()) &&
!(event->flags() & ui::EF_IS_SYNTHESIZED)) {
if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)
- SetLastMouseLocation(window(), event->root_location());
+ env_controller_->SetLastMouseLocation(window(), event->root_location());
synthesize_mouse_move_ = false;
}
@@ -778,7 +762,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
if (move_hold_count_) {
if (!(event->flags() & ui::EF_IS_SYNTHESIZED) &&
event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) {
- SetLastMouseLocation(window(), event->root_location());
+ env_controller_->SetLastMouseLocation(window(), event->root_location());
}
held_move_event_.reset(new ui::MouseEvent(*event, target, window()));
event->SetHandled();
@@ -851,17 +835,16 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
// sent to the wrong target.
if (!(event->flags() & ui::EF_IS_NON_CLIENT) && !mouse_pressed_handler_)
mouse_pressed_handler_ = target;
- Env::GetInstance()->set_mouse_button_flags(event->button_flags());
break;
case ui::ET_MOUSE_RELEASED:
mouse_pressed_handler_ = NULL;
- Env::GetInstance()->set_mouse_button_flags(
- event->button_flags() & ~event->changed_button_flags());
break;
default:
break;
}
+ env_controller_->PreDispatchMouseEvent(event);
sadrul 2016/05/31 18:27:02 Looking at all the various places that explicitly
+
return PreDispatchLocatedEvent(target, event);
}
@@ -871,7 +854,6 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
switch (event->type()) {
case ui::ET_TOUCH_PRESSED:
touch_ids_down_ |= (1 << event->touch_id());
- Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
break;
// Handle ET_TOUCH_CANCELLED only if it has a native event.
@@ -882,7 +864,6 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
case ui::ET_TOUCH_RELEASED:
touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^
(1 << event->touch_id());
- Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
break;
case ui::ET_TOUCH_MOVED:
@@ -898,6 +879,8 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
break;
}
+ env_controller_->PreDispatchTouchEvent(event, touch_ids_down_);
+
ui::TouchEvent orig_event(*event, target, window());
if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(&orig_event,
target)) {
« no previous file with comments | « ui/aura/window_event_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698