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

Side by Side Diff: ui/aura/env_input_state_controller.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 EF_IS_SYNTHESIZED condition to call in PreDispatchMouseEvent; fixes WindowEventDispatcherTest.S… Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « ui/aura/env_input_state_controller.h ('k') | ui/aura/window_event_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/aura/env_input_state_controller.h"
6
7 #include "ui/aura/client/screen_position_client.h"
8 #include "ui/aura/env.h"
9 #include "ui/events/event.h"
10 #include "ui/gfx/geometry/point.h"
11
12 namespace aura {
13
14 void EnvInputStateController::UpdateStateForMouseEvent(
15 const Window* window, ui::MouseEvent* event) const {
16 switch (event->type()) {
17 case ui::ET_MOUSE_PRESSED:
18 Env::GetInstance()->set_mouse_button_flags(event->button_flags());
19 break;
20 case ui::ET_MOUSE_RELEASED:
21 Env::GetInstance()->set_mouse_button_flags(
22 event->button_flags() & ~event->changed_button_flags());
23 break;
24 default:
25 break;
26 }
27
28 if (!(event->flags() & ui::EF_IS_SYNTHESIZED))
29 SetLastMouseLocation(window, event->root_location());
30 }
31
32 void EnvInputStateController::UpdateStateForTouchEvent(ui::TouchEvent* event) {
33
34 switch (event->type()) {
35 case ui::ET_TOUCH_PRESSED:
36 touch_ids_down_ |= (1 << event->touch_id());
37 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
38 break;
39
40 // Handle ET_TOUCH_CANCELLED only if it has a native event.
41 case ui::ET_TOUCH_CANCELLED:
42 if (!event->HasNativeEvent())
43 break;
44 // fallthrough
45 case ui::ET_TOUCH_RELEASED:
46 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^
47 (1 << event->touch_id());
48 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
49 break;
50
51 case ui::ET_TOUCH_MOVED:
52 break;
53
54 default:
55 NOTREACHED();
56 break;
57 }
58 }
59
60 void EnvInputStateController::SetLastMouseLocation(
61 const Window* root_window, const gfx::Point& location_in_root) const {
62 client::ScreenPositionClient* client =
63 client::GetScreenPositionClient(root_window);
64 if (client) {
65 gfx::Point location_in_screen = location_in_root;
66 client->ConvertPointToScreen(root_window, &location_in_screen);
67 Env::GetInstance()->set_last_mouse_location(location_in_screen);
68 } else {
69 Env::GetInstance()->set_last_mouse_location(location_in_root);
70 }
71 }
72
73 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/env_input_state_controller.h ('k') | ui/aura/window_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698