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

Side by Side Diff: ui/chromeos/touch_exploration_controller.cc

Issue 2525113002: Rename WindowTreeHost functions to indicate pixels/dips. (Closed)
Patch Set: win Created 4 years 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/window_unittest.cc ('k') | ui/views/mus/desktop_window_tree_host_mus.h » ('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 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 "ui/chromeos/touch_exploration_controller.h" 5 #include "ui/chromeos/touch_exploration_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); 55 root_window->GetHost()->GetEventSource()->AddEventRewriter(this);
56 } 56 }
57 57
58 TouchExplorationController::~TouchExplorationController() { 58 TouchExplorationController::~TouchExplorationController() {
59 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); 59 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this);
60 } 60 }
61 61
62 void TouchExplorationController::SetTouchAccessibilityAnchorPoint( 62 void TouchExplorationController::SetTouchAccessibilityAnchorPoint(
63 const gfx::Point& anchor_point) { 63 const gfx::Point& anchor_point) {
64 gfx::Point native_point = anchor_point; 64 gfx::Point native_point = anchor_point;
65 root_window_->GetHost()->ConvertPointToNativeScreen(&native_point); 65 root_window_->GetHost()->ConvertDIPToScreenInPixels(&native_point);
66 66
67 anchor_point_ = gfx::PointF(native_point.x(), native_point.y()); 67 anchor_point_ = gfx::PointF(native_point.x(), native_point.y());
68 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET; 68 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET;
69 } 69 }
70 70
71 void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) { 71 void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) {
72 exclude_bounds_ = bounds; 72 exclude_bounds_ = bounds;
73 } 73 }
74 74
75 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( 75 ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
(...skipping 10 matching lines...) Expand all
86 return ui::EVENT_REWRITE_CONTINUE; 86 return ui::EVENT_REWRITE_CONTINUE;
87 } 87 }
88 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event); 88 const ui::TouchEvent& touch_event = static_cast<const ui::TouchEvent&>(event);
89 89
90 // Let TouchAccessibilityEnabler process the unrewritten event. 90 // Let TouchAccessibilityEnabler process the unrewritten event.
91 if (touch_accessibility_enabler_) 91 if (touch_accessibility_enabler_)
92 touch_accessibility_enabler_->HandleTouchEvent(touch_event); 92 touch_accessibility_enabler_->HandleTouchEvent(touch_event);
93 93
94 if (!exclude_bounds_.IsEmpty()) { 94 if (!exclude_bounds_.IsEmpty()) {
95 gfx::Point location = touch_event.location(); 95 gfx::Point location = touch_event.location();
96 root_window_->GetHost()->ConvertPointFromNativeScreen(&location); 96 root_window_->GetHost()->ConvertScreenInPixelsToDIP(&location);
97 bool in_exclude_area = exclude_bounds_.Contains(location); 97 bool in_exclude_area = exclude_bounds_.Contains(location);
98 if (in_exclude_area) { 98 if (in_exclude_area) {
99 if (state_ == NO_FINGERS_DOWN) 99 if (state_ == NO_FINGERS_DOWN)
100 return ui::EVENT_REWRITE_CONTINUE; 100 return ui::EVENT_REWRITE_CONTINUE;
101 if (touch_event.type() == ui::ET_TOUCH_MOVED || 101 if (touch_event.type() == ui::ET_TOUCH_MOVED ||
102 touch_event.type() == ui::ET_TOUCH_PRESSED) { 102 touch_event.type() == ui::ET_TOUCH_PRESSED) {
103 return ui::EVENT_REWRITE_DISCARD; 103 return ui::EVENT_REWRITE_DISCARD;
104 } 104 }
105 // Otherwise, continue handling events. Basically, we want to let 105 // Otherwise, continue handling events. Basically, we want to let
106 // CANCELLED or RELEASE events through so this can get back to 106 // CANCELLED or RELEASE events through so this can get back to
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 if (edge & TOP_EDGE) { 894 if (edge & TOP_EDGE) {
895 delegate_->SetOutputLevel(100); 895 delegate_->SetOutputLevel(100);
896 return; 896 return;
897 } 897 }
898 if (edge & BOTTOM_EDGE) { 898 if (edge & BOTTOM_EDGE) {
899 delegate_->SetOutputLevel(0); 899 delegate_->SetOutputLevel(0);
900 return; 900 return;
901 } 901 }
902 902
903 location = gesture->location(); 903 location = gesture->location();
904 root_window_->GetHost()->ConvertPointFromNativeScreen(&location); 904 root_window_->GetHost()->ConvertScreenInPixelsToDIP(&location);
905 float volume_adjust_height = 905 float volume_adjust_height =
906 root_window_->bounds().height() - 2 * kMaxDistanceFromEdge; 906 root_window_->bounds().height() - 2 * kMaxDistanceFromEdge;
907 float ratio = (location.y() - kMaxDistanceFromEdge) / volume_adjust_height; 907 float ratio = (location.y() - kMaxDistanceFromEdge) / volume_adjust_height;
908 float volume = 100 - 100 * ratio; 908 float volume = 100 - 100 * ratio;
909 if (VLOG_on_) { 909 if (VLOG_on_) {
910 VLOG(1) << "\n Volume = " << volume 910 VLOG(1) << "\n Volume = " << volume
911 << "\n Location = " << location.ToString() 911 << "\n Location = " << location.ToString()
912 << "\n Bounds = " << root_window_->bounds().right(); 912 << "\n Bounds = " << root_window_->bounds().right();
913 } 913 }
914 delegate_->SetOutputLevel(static_cast<int>(volume)); 914 delegate_->SetOutputLevel(static_cast<int>(volume));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 } 996 }
997 997
998 if (gesture != ui::AX_GESTURE_NONE) 998 if (gesture != ui::AX_GESTURE_NONE)
999 delegate_->HandleAccessibilityGesture(gesture); 999 delegate_->HandleAccessibilityGesture(gesture);
1000 } 1000 }
1001 1001
1002 int TouchExplorationController::FindEdgesWithinBounds(gfx::Point point, 1002 int TouchExplorationController::FindEdgesWithinBounds(gfx::Point point,
1003 float bounds) { 1003 float bounds) {
1004 // Since GetBoundsInScreen is in DIPs but point is not, then point needs to be 1004 // Since GetBoundsInScreen is in DIPs but point is not, then point needs to be
1005 // converted. 1005 // converted.
1006 root_window_->GetHost()->ConvertPointFromNativeScreen(&point); 1006 root_window_->GetHost()->ConvertScreenInPixelsToDIP(&point);
1007 gfx::Rect window = root_window_->GetBoundsInScreen(); 1007 gfx::Rect window = root_window_->GetBoundsInScreen();
1008 1008
1009 float left_edge_limit = window.x() + bounds; 1009 float left_edge_limit = window.x() + bounds;
1010 float right_edge_limit = window.right() - bounds; 1010 float right_edge_limit = window.right() - bounds;
1011 float top_edge_limit = window.y() + bounds; 1011 float top_edge_limit = window.y() + bounds;
1012 float bottom_edge_limit = window.bottom() - bounds; 1012 float bottom_edge_limit = window.bottom() - bounds;
1013 1013
1014 // Bitwise manipulation in order to determine where on the screen the point 1014 // Bitwise manipulation in order to determine where on the screen the point
1015 // lies. If more than one bit is turned on, then it is a corner where the two 1015 // lies. If more than one bit is turned on, then it is a corner where the two
1016 // bit/edges intersect. Otherwise, if no bits are turned on, the point must be 1016 // bit/edges intersect. Otherwise, if no bits are turned on, the point must be
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 return "TWO_FINGER_TAP"; 1190 return "TWO_FINGER_TAP";
1191 } 1191 }
1192 return "Not a state"; 1192 return "Not a state";
1193 } 1193 }
1194 1194
1195 float TouchExplorationController::GetSplitTapTouchSlop() { 1195 float TouchExplorationController::GetSplitTapTouchSlop() {
1196 return gesture_detector_config_.touch_slop * 3; 1196 return gesture_detector_config_.touch_slop * 3;
1197 } 1197 }
1198 1198
1199 } // namespace ui 1199 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/window_unittest.cc ('k') | ui/views/mus/desktop_window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698