OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/renderer_host/input/touch_emulator.h" | 5 #include "content/browser/renderer_host/input/touch_emulator.h" |
6 | 6 |
7 #include "content/browser/renderer_host/input/motion_event_web.h" | 7 #include "content/browser/renderer_host/input/motion_event_web.h" |
8 #include "content/browser/renderer_host/input/web_input_event_util.h" | 8 #include "content/browser/renderer_host/input/web_input_event_util.h" |
9 #include "content/common/input/web_touch_event_traits.h" | 9 #include "content/common/input/web_touch_event_traits.h" |
10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Time between two consecutive mouse moves, during which second mouse move | 40 // Time between two consecutive mouse moves, during which second mouse move |
41 // is not converted to touch. | 41 // is not converted to touch. |
42 const double kMouseMoveDropIntervalSeconds = 5.f / 1000; | 42 const double kMouseMoveDropIntervalSeconds = 5.f / 1000; |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 TouchEmulator::TouchEmulator(TouchEmulatorClient* client) | 46 TouchEmulator::TouchEmulator(TouchEmulatorClient* client) |
47 : client_(client), | 47 : client_(client), |
48 gesture_provider_(GetGestureProviderConfig(), this), | 48 gesture_provider_(GetGestureProviderConfig(), this), |
49 enabled_(false), | 49 enabled_(false), |
50 allow_pinch_(false), | |
51 emulated_stream_active_sequence_count_(0), | 50 emulated_stream_active_sequence_count_(0), |
52 native_stream_active_sequence_count_(0) { | 51 native_stream_active_sequence_count_(0) { |
53 DCHECK(client_); | 52 DCHECK(client_); |
54 ResetState(); | 53 ResetState(); |
55 | 54 |
56 bool use_2x = gfx::Screen::GetNativeScreen()-> | 55 bool use_2x = gfx::Screen::GetNativeScreen()-> |
57 GetPrimaryDisplay().device_scale_factor() > 1.5f; | 56 GetPrimaryDisplay().device_scale_factor() > 1.5f; |
58 float cursor_scale_factor = use_2x ? 2.f : 1.f; | 57 float cursor_scale_factor = use_2x ? 2.f : 1.f; |
59 cursor_size_ = InitCursorFromResource(&touch_cursor_, | 58 cursor_size_ = InitCursorFromResource(&touch_cursor_, |
60 cursor_scale_factor, | 59 cursor_scale_factor, |
(...skipping 24 matching lines...) Expand all Loading... |
85 void TouchEmulator::ResetState() { | 84 void TouchEmulator::ResetState() { |
86 last_mouse_event_was_move_ = false; | 85 last_mouse_event_was_move_ = false; |
87 last_mouse_move_timestamp_ = 0; | 86 last_mouse_move_timestamp_ = 0; |
88 mouse_pressed_ = false; | 87 mouse_pressed_ = false; |
89 shift_pressed_ = false; | 88 shift_pressed_ = false; |
90 suppress_next_fling_cancel_ = false; | 89 suppress_next_fling_cancel_ = false; |
91 pinch_scale_ = 1.f; | 90 pinch_scale_ = 1.f; |
92 pinch_gesture_active_ = false; | 91 pinch_gesture_active_ = false; |
93 } | 92 } |
94 | 93 |
95 void TouchEmulator::Enable(bool allow_pinch) { | 94 void TouchEmulator::Enable() { |
96 if (!enabled_) { | 95 if (!enabled_) { |
97 enabled_ = true; | 96 enabled_ = true; |
98 ResetState(); | 97 ResetState(); |
99 } | 98 } |
100 allow_pinch_ = allow_pinch; | |
101 UpdateCursor(); | 99 UpdateCursor(); |
102 } | 100 } |
103 | 101 |
104 void TouchEmulator::Disable() { | 102 void TouchEmulator::Disable() { |
105 if (!enabled_) | 103 if (!enabled_) |
106 return; | 104 return; |
107 | 105 |
108 enabled_ = false; | 106 enabled_ = false; |
109 UpdateCursor(); | 107 UpdateCursor(); |
110 CancelTouch(); | 108 CancelTouch(); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 point.rotationAngle = 0.f; | 427 point.rotationAngle = 0.f; |
430 point.position.x = mouse_event.x; | 428 point.position.x = mouse_event.x; |
431 point.screenPosition.x = mouse_event.globalX; | 429 point.screenPosition.x = mouse_event.globalX; |
432 point.position.y = mouse_event.y; | 430 point.position.y = mouse_event.y; |
433 point.screenPosition.y = mouse_event.globalY; | 431 point.screenPosition.y = mouse_event.globalY; |
434 | 432 |
435 return true; | 433 return true; |
436 } | 434 } |
437 | 435 |
438 bool TouchEmulator::InPinchGestureMode() const { | 436 bool TouchEmulator::InPinchGestureMode() const { |
439 return shift_pressed_ && allow_pinch_; | 437 return shift_pressed_; |
440 } | 438 } |
441 | 439 |
442 } // namespace content | 440 } // namespace content |
OLD | NEW |