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

Side by Side Diff: ash/magnifier/magnification_controller.cc

Issue 2641733002: Initial patch set to implement improved touch support for screen magnification (Closed)
Patch Set: Address comments. Created 3 years, 10 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 | chrome/app/generated_resources.grd » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/magnifier/magnification_controller.h" 5 #include "ash/magnifier/magnification_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/accelerators/accelerator_controller.h" 10 #include "ash/common/accelerators/accelerator_controller.h"
11 #include "ash/common/accessibility_delegate.h" 11 #include "ash/common/accessibility_delegate.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 12 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ash/display/root_window_transformers.h" 14 #include "ash/display/root_window_transformers.h"
15 #include "ash/host/ash_window_tree_host.h" 15 #include "ash/host/ash_window_tree_host.h"
16 #include "ash/host/root_window_transformer.h" 16 #include "ash/host/root_window_transformer.h"
17 #include "ash/root_window_controller.h" 17 #include "ash/root_window_controller.h"
18 #include "ash/screen_util.h" 18 #include "ash/screen_util.h"
19 #include "ash/shell.h" 19 #include "ash/shell.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/synchronization/waitable_event.h" 21 #include "base/synchronization/waitable_event.h"
22 #include "base/timer/timer.h" 22 #include "base/timer/timer.h"
23 #include "chromeos/chromeos_switches.h"
23 #include "ui/aura/client/cursor_client.h" 24 #include "ui/aura/client/cursor_client.h"
24 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
25 #include "ui/aura/window_tree_host.h" 26 #include "ui/aura/window_tree_host.h"
26 #include "ui/base/ime/input_method.h" 27 #include "ui/base/ime/input_method.h"
27 #include "ui/base/ime/input_method_observer.h" 28 #include "ui/base/ime/input_method_observer.h"
28 #include "ui/base/ime/text_input_client.h" 29 #include "ui/base/ime/text_input_client.h"
29 #include "ui/compositor/dip_util.h" 30 #include "ui/compositor/dip_util.h"
30 #include "ui/compositor/layer.h" 31 #include "ui/compositor/layer.h"
31 #include "ui/compositor/layer_animation_observer.h" 32 #include "ui/compositor/layer_animation_observer.h"
32 #include "ui/compositor/scoped_layer_animation_settings.h" 33 #include "ui/compositor/scoped_layer_animation_settings.h"
33 #include "ui/display/display.h" 34 #include "ui/display/display.h"
34 #include "ui/display/screen.h" 35 #include "ui/display/screen.h"
35 #include "ui/events/event.h" 36 #include "ui/events/event.h"
36 #include "ui/events/event_handler.h" 37 #include "ui/events/event_handler.h"
38 #include "ui/events/gesture_event_details.h"
37 #include "ui/gfx/geometry/point3_f.h" 39 #include "ui/gfx/geometry/point3_f.h"
38 #include "ui/gfx/geometry/point_conversions.h" 40 #include "ui/gfx/geometry/point_conversions.h"
39 #include "ui/gfx/geometry/point_f.h" 41 #include "ui/gfx/geometry/point_f.h"
40 #include "ui/gfx/geometry/rect_conversions.h" 42 #include "ui/gfx/geometry/rect_conversions.h"
41 #include "ui/wm/core/compound_event_filter.h" 43 #include "ui/wm/core/compound_event_filter.h"
42 #include "ui/wm/core/coordinate_conversion.h" 44 #include "ui/wm/core/coordinate_conversion.h"
43 45
44 namespace { 46 namespace {
45 47
46 const float kMaxMagnifiedScale = 4.0f; 48 const float kMaxMagnifiedScale = 4.0f;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Returns the size of the root window. 186 // Returns the size of the root window.
185 gfx::Size GetHostSizeDIP() const; 187 gfx::Size GetHostSizeDIP() const;
186 188
187 // Correct the given scale value if necessary. 189 // Correct the given scale value if necessary.
188 void ValidateScale(float* scale); 190 void ValidateScale(float* scale);
189 191
190 // ui::EventHandler overrides: 192 // ui::EventHandler overrides:
191 void OnMouseEvent(ui::MouseEvent* event) override; 193 void OnMouseEvent(ui::MouseEvent* event) override;
192 void OnScrollEvent(ui::ScrollEvent* event) override; 194 void OnScrollEvent(ui::ScrollEvent* event) override;
193 void OnTouchEvent(ui::TouchEvent* event) override; 195 void OnTouchEvent(ui::TouchEvent* event) override;
196 void OnGestureEvent(ui::GestureEvent* event) override;
194 197
195 // Moves the view port when |point| is located within 198 // Moves the view port when |point| is located within
196 // |x_panning_margin| and |y_pannin_margin| to the edge of the visible 199 // |x_panning_margin| and |y_pannin_margin| to the edge of the visible
197 // window region. The view port will be moved so that the |point| will be 200 // window region. The view port will be moved so that the |point| will be
198 // moved to the point where it has |x_target_margin| and |y_target_margin| 201 // moved to the point where it has |x_target_margin| and |y_target_margin|
199 // to the edge of the visible region. 202 // to the edge of the visible region.
200 void MoveMagnifierWindowFollowPoint(const gfx::Point& point, 203 void MoveMagnifierWindowFollowPoint(const gfx::Point& point,
201 int x_panning_margin, 204 int x_panning_margin,
202 int y_panning_margin, 205 int y_panning_margin,
203 int x_target_margin, 206 int x_target_margin,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 void MagnificationControllerImpl::OnTouchEvent(ui::TouchEvent* event) { 686 void MagnificationControllerImpl::OnTouchEvent(ui::TouchEvent* event) {
684 aura::Window* target = static_cast<aura::Window*>(event->target()); 687 aura::Window* target = static_cast<aura::Window*>(event->target());
685 aura::Window* current_root = target->GetRootWindow(); 688 aura::Window* current_root = target->GetRootWindow();
686 if (current_root == root_window_) { 689 if (current_root == root_window_) {
687 gfx::Rect root_bounds = current_root->bounds(); 690 gfx::Rect root_bounds = current_root->bounds();
688 if (root_bounds.Contains(event->root_location())) 691 if (root_bounds.Contains(event->root_location()))
689 point_of_interest_ = event->root_location(); 692 point_of_interest_ = event->root_location();
690 } 693 }
691 } 694 }
692 695
696 void MagnificationControllerImpl::OnGestureEvent(ui::GestureEvent* event) {
697 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
698 chromeos::switches::kEnableTouchSupportForScreenMagnifier)) {
699 return;
700 }
701
702 const ui::GestureEventDetails& details = event->details();
703 if (details.type() == ui::ET_GESTURE_SCROLL_UPDATE &&
704 details.touch_points() == 2) {
705 gfx::Rect viewport_rect_in_dip = GetViewportRect();
706 viewport_rect_in_dip.Offset(details.scroll_x() * -1,
oshima 2017/02/09 07:15:44 - details.scroll_x()
yawano 2017/02/10 05:32:47 Done.
707 details.scroll_y() * -1);
708 const gfx::Rect& viewport_rect_in_pixel =
oshima 2017/02/09 07:15:44 IIRC, it returns a object, so it shouldn't be refe
yawano 2017/02/10 05:32:47 Done.
709 ui::ConvertRectToPixel(root_window_->layer(), viewport_rect_in_dip);
710 MoveWindow(viewport_rect_in_pixel.origin(), false);
711 event->SetHandled();
712 } else if (details.type() == ui::ET_GESTURE_PINCH_UPDATE &&
713 details.touch_points() == 3) {
714 float scale = GetScale() * details.scale();
715
716 if (scale < kMinMagnifiedScaleThreshold) {
oshima 2017/02/09 07:15:45 or min/max to up you tho.
yawano 2017/02/10 05:32:47 Done.
717 scale = kMinMagnifiedScaleThreshold;
718 } else if (scale > kMaxMagnifiedScaleThreshold) {
719 scale = kMaxMagnifiedScaleThreshold;
720 }
721
722 point_of_interest_ = event->root_location();
723 SetScale(scale, false);
724 event->SetHandled();
725 }
726 }
727
693 void MagnificationControllerImpl::MoveMagnifierWindowFollowPoint( 728 void MagnificationControllerImpl::MoveMagnifierWindowFollowPoint(
694 const gfx::Point& point, 729 const gfx::Point& point,
695 int x_panning_margin, 730 int x_panning_margin,
696 int y_panning_margin, 731 int y_panning_margin,
697 int x_target_margin, 732 int x_target_margin,
698 int y_target_margin) { 733 int y_target_margin) {
699 DCHECK(root_window_); 734 DCHECK(root_window_);
700 bool start_zoom = false; 735 bool start_zoom = false;
701 736
702 const gfx::Rect window_rect = GetViewportRect(); 737 const gfx::Rect window_rect = GetViewportRect();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 892
858 //////////////////////////////////////////////////////////////////////////////// 893 ////////////////////////////////////////////////////////////////////////////////
859 // MagnificationController: 894 // MagnificationController:
860 895
861 // static 896 // static
862 MagnificationController* MagnificationController::CreateInstance() { 897 MagnificationController* MagnificationController::CreateInstance() {
863 return new MagnificationControllerImpl(); 898 return new MagnificationControllerImpl();
864 } 899 }
865 900
866 } // namespace ash 901 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698