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 "ash/ash_touch_exploration_manager_chromeos.h" | 5 #include "ash/ash_touch_exploration_manager_chromeos.h" |
6 | 6 |
7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
8 #include "ash/common/system/tray/system_tray_notifier.h" | 8 #include "ash/common/system/tray/system_tray_notifier.h" |
9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/display/display_manager.h" |
10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/root_window_settings.h" |
11 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/wm/window_state_aura.h" |
12 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
13 #include "base/command_line.h" | 16 #include "base/command_line.h" |
14 #include "chromeos/audio/chromeos_sounds.h" | 17 #include "chromeos/audio/chromeos_sounds.h" |
15 #include "chromeos/audio/cras_audio_handler.h" | 18 #include "chromeos/audio/cras_audio_handler.h" |
16 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
17 #include "ui/chromeos/touch_exploration_controller.h" | 20 #include "ui/chromeos/touch_exploration_controller.h" |
18 #include "ui/wm/public/activation_client.h" | 21 #include "ui/wm/public/activation_client.h" |
19 | 22 |
20 namespace ash { | 23 namespace ash { |
21 | 24 |
22 AshTouchExplorationManager::AshTouchExplorationManager( | 25 AshTouchExplorationManager::AshTouchExplorationManager( |
23 RootWindowController* root_window_controller) | 26 RootWindowController* root_window_controller) |
24 : root_window_controller_(root_window_controller), | 27 : root_window_controller_(root_window_controller), |
25 audio_handler_(chromeos::CrasAudioHandler::Get()) { | 28 audio_handler_(chromeos::CrasAudioHandler::Get()) { |
26 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 29 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
27 Shell::GetInstance()->activation_client()->AddObserver(this); | 30 Shell::GetInstance()->activation_client()->AddObserver(this); |
| 31 display::Screen::GetScreen()->AddObserver(this); |
28 UpdateTouchExplorationState(); | 32 UpdateTouchExplorationState(); |
29 } | 33 } |
30 | 34 |
31 AshTouchExplorationManager::~AshTouchExplorationManager() { | 35 AshTouchExplorationManager::~AshTouchExplorationManager() { |
32 SystemTrayNotifier* system_tray_notifier = | 36 SystemTrayNotifier* system_tray_notifier = |
33 WmShell::Get()->system_tray_notifier(); | 37 WmShell::Get()->system_tray_notifier(); |
34 if (system_tray_notifier) | 38 if (system_tray_notifier) |
35 system_tray_notifier->RemoveAccessibilityObserver(this); | 39 system_tray_notifier->RemoveAccessibilityObserver(this); |
36 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 40 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 41 display::Screen::GetScreen()->RemoveObserver(this); |
37 } | 42 } |
38 | 43 |
39 void AshTouchExplorationManager::OnAccessibilityModeChanged( | 44 void AshTouchExplorationManager::OnAccessibilityModeChanged( |
40 AccessibilityNotificationVisibility notify) { | 45 AccessibilityNotificationVisibility notify) { |
41 UpdateTouchExplorationState(); | 46 UpdateTouchExplorationState(); |
42 } | 47 } |
43 | 48 |
44 void AshTouchExplorationManager::SetOutputLevel(int volume) { | 49 void AshTouchExplorationManager::SetOutputLevel(int volume) { |
45 if (volume > 0) { | 50 if (volume > 0) { |
46 if (audio_handler_->IsOutputMuted()) { | 51 if (audio_handler_->IsOutputMuted()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void AshTouchExplorationManager::PlayEnterScreenEarcon() { | 86 void AshTouchExplorationManager::PlayEnterScreenEarcon() { |
82 WmShell::Get()->accessibility_delegate()->PlayEarcon( | 87 WmShell::Get()->accessibility_delegate()->PlayEarcon( |
83 chromeos::SOUND_ENTER_SCREEN); | 88 chromeos::SOUND_ENTER_SCREEN); |
84 } | 89 } |
85 | 90 |
86 void AshTouchExplorationManager::HandleAccessibilityGesture( | 91 void AshTouchExplorationManager::HandleAccessibilityGesture( |
87 ui::AXGesture gesture) { | 92 ui::AXGesture gesture) { |
88 WmShell::Get()->accessibility_delegate()->HandleAccessibilityGesture(gesture); | 93 WmShell::Get()->accessibility_delegate()->HandleAccessibilityGesture(gesture); |
89 } | 94 } |
90 | 95 |
| 96 void AshTouchExplorationManager::OnDisplayMetricsChanged( |
| 97 const display::Display& display, |
| 98 uint32_t changed_metrics) { |
| 99 aura::Window* root_window = root_window_controller_->GetRootWindow(); |
| 100 if (ash::GetRootWindowSettings(root_window)->display_id == display.id()) |
| 101 UpdateTouchExplorationState(); |
| 102 } |
| 103 |
91 void AshTouchExplorationManager::OnWindowActivated( | 104 void AshTouchExplorationManager::OnWindowActivated( |
92 aura::client::ActivationChangeObserver::ActivationReason reason, | 105 aura::client::ActivationChangeObserver::ActivationReason reason, |
93 aura::Window* gained_active, | 106 aura::Window* gained_active, |
94 aura::Window* lost_active) { | 107 aura::Window* lost_active) { |
95 UpdateTouchExplorationState(); | 108 UpdateTouchExplorationState(); |
96 } | 109 } |
97 | 110 |
98 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( | 111 void AshTouchExplorationManager::SetTouchAccessibilityAnchorPoint( |
99 const gfx::Point& anchor_point) { | 112 const gfx::Point& anchor_point) { |
100 if (touch_exploration_controller_) { | 113 if (touch_exploration_controller_) { |
101 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( | 114 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint( |
102 anchor_point); | 115 anchor_point); |
103 } | 116 } |
104 } | 117 } |
105 | 118 |
106 void AshTouchExplorationManager::UpdateTouchExplorationState() { | 119 void AshTouchExplorationManager::UpdateTouchExplorationState() { |
107 // Comes from components/exo/shell_surface.cc. | 120 // Comes from components/exo/shell_surface.cc. |
108 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; | 121 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; |
109 | 122 |
110 // See crbug.com/603745 for more details. | 123 // See crbug.com/603745 for more details. |
111 const bool pass_through_surface = | 124 const bool pass_through_surface = |
112 wm::GetActiveWindow() && | 125 wm::GetActiveWindow() && |
113 wm::GetActiveWindow()->name() == kExoShellSurfaceWindowName; | 126 wm::GetActiveWindow()->name() == kExoShellSurfaceWindowName; |
114 | 127 |
115 const bool spoken_feedback_enabled = | 128 const bool spoken_feedback_enabled = |
116 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 129 WmShell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
117 | 130 |
118 if (!pass_through_surface && spoken_feedback_enabled && | 131 if (spoken_feedback_enabled) { |
119 !touch_exploration_controller_.get()) { | 132 if (!touch_exploration_controller_.get()) { |
120 touch_exploration_controller_.reset(new ui::TouchExplorationController( | 133 touch_exploration_controller_ = |
121 root_window_controller_->GetRootWindow(), this)); | 134 base::MakeUnique<ui::TouchExplorationController>( |
122 } else if (!spoken_feedback_enabled || pass_through_surface) { | 135 root_window_controller_->GetRootWindow(), this); |
| 136 } |
| 137 if (pass_through_surface) { |
| 138 aura::Window* root_window = root_window_controller_->GetRootWindow(); |
| 139 int64_t display_id = ash::GetRootWindowSettings(root_window)->display_id; |
| 140 const gfx::Rect& work_area = ash::Shell::GetInstance() |
| 141 ->display_manager() |
| 142 ->GetDisplayForId(display_id) |
| 143 .work_area(); |
| 144 touch_exploration_controller_->SetExcludeBounds(work_area); |
| 145 } else { |
| 146 touch_exploration_controller_->SetExcludeBounds(gfx::Rect()); |
| 147 } |
| 148 } else { |
123 touch_exploration_controller_.reset(); | 149 touch_exploration_controller_.reset(); |
124 } | 150 } |
125 } | 151 } |
126 | 152 |
127 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { | 153 bool AshTouchExplorationManager::VolumeAdjustSoundEnabled() { |
128 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 154 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
129 chromeos::switches::kDisableVolumeAdjustSound); | 155 chromeos::switches::kDisableVolumeAdjustSound); |
130 } | 156 } |
131 | 157 |
132 } // namespace ash | 158 } // namespace ash |
OLD | NEW |