Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #if defined(USE_X11) | |
| 13 #include <X11/Xlib.h> | |
| 14 #endif | |
| 15 | |
| 12 namespace aura { | 16 namespace aura { |
| 13 | 17 |
| 14 void EnvInputStateController::UpdateStateForMouseEvent( | 18 void EnvInputStateController::UpdateStateForMouseEvent( |
| 15 const Window* window, | 19 const Window* window, |
| 16 const ui::MouseEvent& event) { | 20 const ui::MouseEvent& event) { |
| 17 switch (event.type()) { | 21 switch (event.type()) { |
| 18 case ui::ET_MOUSE_PRESSED: | 22 case ui::ET_MOUSE_PRESSED: |
| 19 Env::GetInstance()->set_mouse_button_flags(event.button_flags()); | 23 Env::GetInstance()->set_mouse_button_flags(event.button_flags()); |
| 20 break; | 24 break; |
| 21 case ui::ET_MOUSE_RELEASED: | 25 case ui::ET_MOUSE_RELEASED: |
| 22 Env::GetInstance()->set_mouse_button_flags( | 26 Env::GetInstance()->set_mouse_button_flags( |
| 23 event.button_flags() & ~event.changed_button_flags()); | 27 event.button_flags() & ~event.changed_button_flags()); |
| 24 break; | 28 break; |
| 25 default: | 29 default: |
| 26 break; | 30 break; |
| 27 } | 31 } |
| 28 | 32 |
| 29 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED && | 33 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED && |
| 30 !(event.flags() & ui::EF_IS_SYNTHESIZED)) { | 34 !(event.flags() & ui::EF_IS_SYNTHESIZED)) { |
| 31 SetLastMouseLocation(window, event.root_location()); | 35 SetLastMouseLocation(window, event.root_location()); |
| 36 } else if (event.type() == ui::ET_MOUSE_MOVED && | |
| 37 (event.flags() & ui::EF_IS_SYNTHESIZED) && | |
| 38 event.HasNativeEvent()) { | |
| 39 #if defined(USE_X11) | |
| 40 // EnterNotify XEvents create synthesized ET_MOUSE_MOVED events from which | |
| 41 // we also need to update the mouse location. | |
| 42 XEvent* xev = event.native_event(); | |
| 43 if (xev->type == EnterNotify) { | |
| 44 SetLastMouseLocation(window, event.root_location()); | |
| 45 } | |
| 46 #endif // defined(USE_X11) | |
|
sadrul
2017/07/04 17:16:49
Can you just set the mouse location without having
Kevin McNee
2017/07/05 13:52:27
Done.
Although, I think I could've worded that co
Kevin McNee
2017/07/05 14:08:46
Done.
| |
| 32 } | 47 } |
| 33 } | 48 } |
| 34 | 49 |
| 35 void EnvInputStateController::UpdateStateForTouchEvent( | 50 void EnvInputStateController::UpdateStateForTouchEvent( |
| 36 const ui::TouchEvent& event) { | 51 const ui::TouchEvent& event) { |
| 37 switch (event.type()) { | 52 switch (event.type()) { |
| 38 case ui::ET_TOUCH_PRESSED: | 53 case ui::ET_TOUCH_PRESSED: |
| 39 touch_ids_down_ |= (1 << event.pointer_details().id); | 54 touch_ids_down_ |= (1 << event.pointer_details().id); |
| 40 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | 55 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
| 41 break; | 56 break; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 if (client) { | 88 if (client) { |
| 74 gfx::Point location_in_screen = location_in_root; | 89 gfx::Point location_in_screen = location_in_root; |
| 75 client->ConvertPointToScreen(root_window, &location_in_screen); | 90 client->ConvertPointToScreen(root_window, &location_in_screen); |
| 76 Env::GetInstance()->set_last_mouse_location(location_in_screen); | 91 Env::GetInstance()->set_last_mouse_location(location_in_screen); |
| 77 } else { | 92 } else { |
| 78 Env::GetInstance()->set_last_mouse_location(location_in_root); | 93 Env::GetInstance()->set_last_mouse_location(location_in_root); |
| 79 } | 94 } |
| 80 } | 95 } |
| 81 | 96 |
| 82 } // namespace aura | 97 } // namespace aura |
| OLD | NEW |