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

Side by Side Diff: ui/aura/env_input_state_controller.cc

Issue 2779093004: Update event states in Env when target window has been destroyed. (Closed)
Patch Set: rebase Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/aura/mus/window_tree_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/env_input_state_controller.h" 5 #include "ui/aura/env_input_state_controller.h"
6 6
7 #include "ui/aura/client/screen_position_client.h" 7 #include "ui/aura/client/screen_position_client.h"
8 #include "ui/aura/env.h" 8 #include "ui/aura/env.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/gfx/geometry/point.h" 10 #include "ui/gfx/geometry/point.h"
11 11
12 namespace aura { 12 namespace aura {
13 13
14 void EnvInputStateController::UpdateStateForMouseEvent( 14 void EnvInputStateController::UpdateStateForMouseEvent(
15 const Window* window, 15 const Window* window,
16 const ui::MouseEvent& event) { 16 const ui::MouseEvent& event) {
17 switch (event.type()) { 17 switch (event.type()) {
18 case ui::ET_MOUSE_PRESSED: 18 case ui::ET_MOUSE_PRESSED:
19 Env::GetInstance()->set_mouse_button_flags(event.button_flags()); 19 Env::GetInstance()->set_mouse_button_flags(event.button_flags());
20 break; 20 break;
21 case ui::ET_MOUSE_RELEASED: 21 case ui::ET_MOUSE_RELEASED:
22 Env::GetInstance()->set_mouse_button_flags( 22 Env::GetInstance()->set_mouse_button_flags(
23 event.button_flags() & ~event.changed_button_flags()); 23 event.button_flags() & ~event.changed_button_flags());
24 break; 24 break;
25 default: 25 default:
26 break; 26 break;
27 } 27 }
28 28
29 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED && 29 // If |window| is null, we are only using |event| to update event states, so
30 // we shouldn't update mouse location.
sadrul 2017/05/01 15:27:55 Can you move this into SetLastMouseLocation() inst
riajiang 2017/05/01 16:19:59 Done.
31 if (window && event.type() != ui::ET_MOUSE_CAPTURE_CHANGED &&
30 !(event.flags() & ui::EF_IS_SYNTHESIZED)) { 32 !(event.flags() & ui::EF_IS_SYNTHESIZED)) {
31 SetLastMouseLocation(window, event.root_location()); 33 SetLastMouseLocation(window, event.root_location());
32 } 34 }
33 } 35 }
34 36
35 void EnvInputStateController::UpdateStateForTouchEvent( 37 void EnvInputStateController::UpdateStateForTouchEvent(
36 const ui::TouchEvent& event) { 38 const ui::TouchEvent& event) {
37 switch (event.type()) { 39 switch (event.type()) {
38 case ui::ET_TOUCH_PRESSED: 40 case ui::ET_TOUCH_PRESSED:
39 touch_ids_down_ |= (1 << event.pointer_details().id); 41 touch_ids_down_ |= (1 << event.pointer_details().id);
(...skipping 16 matching lines...) Expand all
56 58
57 default: 59 default:
58 NOTREACHED(); 60 NOTREACHED();
59 break; 61 break;
60 } 62 }
61 } 63 }
62 64
63 void EnvInputStateController::SetLastMouseLocation( 65 void EnvInputStateController::SetLastMouseLocation(
64 const Window* root_window, 66 const Window* root_window,
65 const gfx::Point& location_in_root) const { 67 const gfx::Point& location_in_root) const {
66 client::ScreenPositionClient* client = 68 client::ScreenPositionClient* client =
sadrul 2017/05/01 15:27:55 Early return here if window is nullptr (but only f
riajiang 2017/05/01 16:19:59 Done.
67 client::GetScreenPositionClient(root_window); 69 client::GetScreenPositionClient(root_window);
68 if (client) { 70 if (client) {
69 gfx::Point location_in_screen = location_in_root; 71 gfx::Point location_in_screen = location_in_root;
70 client->ConvertPointToScreen(root_window, &location_in_screen); 72 client->ConvertPointToScreen(root_window, &location_in_screen);
71 Env::GetInstance()->set_last_mouse_location(location_in_screen); 73 Env::GetInstance()->set_last_mouse_location(location_in_screen);
72 } else { 74 } else {
73 Env::GetInstance()->set_last_mouse_location(location_in_root); 75 Env::GetInstance()->set_last_mouse_location(location_in_root);
74 } 76 }
75 } 77 }
76 78
77 } // namespace aura 79 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/mus/window_tree_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698